How to Format a Table of Contents in a .docx File
Learn how to style a table of contents so its fonts, spacing, leader dots and tab stops survive updates, with checks to confirm the layout holds.
A table of contents that looks sharp on the first draft often falls apart after the next edit. You adjust a font, update the table, and suddenly the dots are gone, the spacing has collapsed, and every subsection sits flush with its chapter. If you are working on a Word-format (.docx) file and want the table to look finished without redoing it each time, the problem is usually not the table itself. It is where the formatting was applied.
This guide is for anyone who needs a clean, consistent table of contents in a .docx file: students finishing a thesis, team members preparing a report, or anyone who inherited a document with a messy contents page. The short answer is to style the table of contents through its level styles, not through individual lines. You will get a layout that keeps its look when you update it.
The sections below cover what to check before you start, the steps for setting fonts, spacing, indents and leader dots, and how to confirm the result. The steps describe general operations that work in most desktop office suites, plus the UniDoc web editor for files you want to open in a browser.
Why does my table of contents lose its formatting? The short answer
Most formatting loss comes from applying changes directly to the entries instead of to the styles that control them. Put your changes in the styles, and updates will keep them.
| Your situation | What to do | Why |
|---|---|---|
| Spacing or fonts reset after an update | Change the table of contents level styles, not single lines | An update rebuilds each entry from its style, so direct edits are removed |
| Dots are missing or page numbers drift to the wrong spot | Set a right-aligned tab stop with a dot leader at the right margin | The tab stop controls where the page number and leader dots sit |
| Subsections look like chapters | Set a different left indent for each level style | Indents show the hierarchy at a glance |
| Page numbers are wrong but the styling is right | Update page numbers only | This refreshes numbers without rebuilding the entry text |
| You want to fix the file in a browser | Open the .docx in the UniDoc web editor at app.unidoc.top and check after saving | Word-compatible editing lets you review the layout without a desktop install |
Before you start
Check these items first. Each one prevents a problem that would otherwise show up only after you have spent time styling the table.
- Heading styles. The table of contents is built from headings. If chapter titles were typed in bold with a larger font, the table will not pick them up. Apply your heading styles to every chapter and section title first.
- Heading levels. Make sure subsections use the next level down, such as Heading 2 under Heading 1. Skipped levels produce a flat or confusing table.
- A copy of the file. Save a duplicate before you change styles. If the layout goes wrong, you can compare against the copy.
- Page layout settings. Confirm margins and page size are final. Changing them later moves the right edge that your tab stop depends on.
- Direct formatting. Look for lines you manually bolded, resized or spaced in the current table. Clear that formatting, because it will override the styles you set.
Formatting the table of contents in a .docx file, step by step
- Confirm the headings are correct. Scroll through the document and check that each chapter and section uses a heading style. This ensures the table includes the right entries before you touch its look.
- Open the table of contents level styles. In most desktop office suites, the entries use built-in styles named for their level, such as TOC 1 and TOC 2. Editing these styles changes every entry at that level in one step.
- Set the font, size and color for each level. Use a larger or bolder font for level 1 and a smaller one for level 2 so the hierarchy is clear. Keep the font family the same across levels for a cleaner look.
- Set spacing before and after each entry. Add a small amount of space before level 1 entries to separate chapters, and keep level 2 spacing tighter. Line spacing set in the style applies to all entries at that level.
- Set a left indent for each level. Indent level 2 entries further than level 1 so subsections sit under their parent chapter. Use the same indent amount for every subsection so the column stays even.
- Add a right tab stop with a dot leader. Place a right-aligned tab stop at the right margin and choose a dot leader. This is what draws the dotted line between each title and its page number, and it stays aligned when the numbers change width.
- Update the table and choose what to refresh. Update the table after your changes. If you only changed styling and the headings have not moved, choose to update page numbers only so the entry text is not rebuilt.
- Save a copy in .docx format. Save the finished file as .docx so it opens with the same layout in other editors. If you need a PDF for sharing, export it after you have checked the table.
Check the result
Once the table is updated, check these points. Problems are much easier to fix when you catch them right after an update.
| Check | How to see it | If it's wrong |
|---|---|---|
| Leader dots line up | Look at the right edge of every line in the table | Adjust the tab stop position or the leader type in the entry style |
| Subsections are indented | Compare a level 2 entry with its chapter | Change the left indent in the level 2 style |
| Page numbers match the pages | Jump to three or four headings and compare | Update page numbers only, then check again |
| Formatting survives an update | Update the table once more and compare with the previous version | Move any remaining direct formatting into the styles and clear it from the lines |
| Fonts are consistent | Scroll through the table and watch for lines that look different | Clear direct formatting on those lines so they follow the style |
If the layout changes after you save and reopen the file in a different editor, the styles may be rendered slightly differently. Compare the table again in that editor and adjust the styles there, then keep one master copy so you know which version is final.
🎯 Which approach fits you?
If you are formatting one report for a single deadline, styling the level styles in your current editor is usually enough. If several people edit the same document, put all styling in the styles and agree on which person updates the table. This keeps one consistent version and avoids overwritten lines.
❓ FAQ
1. Why do my table of contents changes disappear after I update?
Updating rebuilds each entry from its style, so any direct formatting you applied to individual lines is replaced. Move your changes into the level styles, then update again to confirm they stay.
2. Should I update the whole table or only the page numbers?
Update page numbers only when the headings and their order have not changed and you only need the numbers corrected. Update the whole table when you have added, removed or renamed headings, since the entry text needs to be rebuilt.
3. Can I format a table of contents in a browser editor?
Yes, you can open a .docx file in the UniDoc web editor at app.unidoc.top and review the layout there. Check the leader dots, indents and page numbers after you save, because how each editor displays fields can differ slightly.
4. Why do the leader dots disappear when I change the font size?
The dots depend on the tab stop position, so a larger font or longer title can push the page number past the stop. Move the right tab stop closer to the margin or shorten the longest titles.
5. Will my table of contents keep its layout when I export to PDF?
It usually keeps most of its layout, but check the page numbers and dots in the exported file before you share it. Small shifts can happen when fonts are substituted, so review the PDF as a final step.
📝 Summary
A table of contents keeps its look when its formatting lives in the level styles rather than on individual lines. Set fonts, spacing, indents and a dot-leader tab stop once, then update and check the result. Save a .docx copy so the layout holds in other editors.


