How to Create a Word Table of Contents Without Page Numbers for Main Headings
Question details
The user wants to generate a Table of Contents (TOC) where page numbers and dot leaders are hidden for the main section headings but remain visible for the subsection headings.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Formatting a professional document's Table of Contents to create a cleaner layout with specific numbering rules for different heading levels.
- Observed behavior
- By default, the Table of Contents applies page numbers and dot leaders to all included heading levels uniformly, requiring advanced customization to apply selectively.
Ensure your document is properly structured using built-in heading styles (Heading 1 for main sections, Heading 2 for subsections) before attempting to customize the Table of Contents.
Use TOC Field Codes to Omit Page Numbers Selectively
You can modify the underlying TOC field code using the \n switch, which allows you to specify exactly which heading levels should not display page numbers.
In Word processing software, a Table of Contents is generated using a special field code. By toggling the visibility of this code, you can add parameters (switches) that change its behavior. The \n switch specifically controls page number visibility.
Press Alt + F9 (or Fn + Alt + F9 on some laptops) on your keyboard. This will reveal the field codes in your document. Your Table of Contents will change from regular text to a code block that looks something like { TOC \o "1-3" \h \z \u }.
Click inside the TOC brackets and type the switch \n followed by the heading levels you want to exclude page numbers for. For example, to hide page numbers only for Heading 1, type \n 1-1. Your modified code should look like this: { TOC \o "1-3" \n 1-1 \h \z \u }.
Press Alt + F9 again to hide the field codes and return to the normal document view. The Table of Contents will not look different until you update it.
Right-click anywhere on your Table of Contents and select 'Update Field'. If prompted, choose 'Update entire table'. The page numbers and dot leaders for your main headings will now be successfully removed.

Remove Page Numbers for the Entire Table of Contents
Use this method if you decide you want a cleaner look and prefer to remove page numbers from all heading levels in your Table of Contents.
Easily Customize Your Table of Contents with WPS Writer
WPS Writer offers full compatibility with Word's TOC field codes, allowing you to seamlessly customize heading levels, omit page numbers, and design professional documents without the heavy subscription fees.
- 1. Insert Table of Contents: Open your document in WPS Writer, navigate to the 'Reference' tab, and click 'Table of Contents' to insert a standard TOC.
- 2. Toggle Field Codes: Right-click the generated Table of Contents and select 'Toggle Field Codes'.
- 3. Add the Exclusion Switch: Insert \n 1-1 into the field code to remove page numbers for your primary headings.
- 4. Update the Field: Right-click again, toggle the field codes back, and select 'Update Field' to apply your clean, customized layout.

Frequently Asked Questions
Why did the page numbers reappear after I updated my Table of Contents?
If you manually highlight and delete page numbers in the Table of Contents, Word will restore them the next time the table is updated. To permanently remove page numbers for specific levels, you must edit the TOC field code using the \n switch.
What does the \n 1-1 switch do in a TOC field code?
The \n switch instructs the document to omit page numbers for the specified heading levels. The '1-1' portion targets exactly Heading 1. If you wanted to omit page numbers for Headings 1 and 2, you would use \n 1-2.
Can I remove the dot leaders but keep the page numbers?
Yes. You can customize the dot leaders by going to the References tab, clicking Table of Contents, selecting Custom Table of Contents, and changing the 'Tab leader' dropdown setting to '(none)'.
Will this formatting carry over if I export the document to PDF?
Yes. When you use field codes to format your Table of Contents, the visual layout—including the hidden page numbers and dot leaders—will be perfectly preserved when you export or 'Save As' a PDF.




