How to Center a Word Table of Contents and Remove Page Numbers
Question details
The user wants to format a Word document's Table of Contents (TOC) so that all heading levels are centered and the page numbers are hidden, ensuring these settings persist even after the TOC is updated.

- Product
- Word Processor
- Device & OS
- not provided
- Scenario
- Customizing the appearance of a Table of Contents for specific document formatting and layout requirements.
- Observed behavior
- By default, TOC entries are left-aligned and include page numbers. Manual centering is lost when the TOC updates, requiring a permanent style modification.
Before making changes to your Table of Contents, ensure your document headings are properly structured using the built-in Heading 1, Heading 2, and Heading 3 styles so the TOC generates accurately.
Modify Field Codes and Update TOC Styles
The most reliable way to hide page numbers and center text permanently is by editing the TOC field code and updating the default TOC paragraph styles.
Table of Contents formatting is governed by field codes and specialized paragraph styles (TOC 1, TOC 2, etc.). Editing these ensures your changes are not overwritten when the table refreshes.
Press Alt + F9 on your keyboard to reveal the underlying field codes in your document.
Locate the TOC field code (e.g., { TOC \o "1-3" \h \z \u }). Inside the closing brace, add the \n switch to suppress page numbers. Then, press Alt + F9 again to hide the codes.
Open the Styles pane. Find the 'TOC 1' style, right-click it, and select 'Modify'. Under the Formatting options, click the 'Center' alignment button and apply the changes. Repeat this for 'TOC 2' through 'TOC 9' if needed.
Right-click your Table of Contents and select 'Update Field' to apply and verify your new formatting.

Use a VBA Macro to Center All TOC Levels
If you have a document with multiple TOC levels, using a quick VBA macro can instantly center all TOC 1 through TOC 9 styles without requiring manual modification for each level.
Easily Customize Table of Contents Formatting in WPS Writer
WPS Writer provides an intuitive interface for inserting and customizing a Table of Contents. You can easily modify TOC styles, hide page numbers, and center your entries to meet your document's specific layout needs without dealing with complex field codes.
- 1. Insert a Table of Contents: Open your document in WPS Writer, navigate to the 'References' tab, and click 'Table of Contents' to select a layout.
- 2. Disable Page Numbers: Select 'Insert Table of Contents' to open the advanced settings. Uncheck the 'Show page numbers' option to hide them instantly.
- 3. Modify TOC Alignment: In the same settings window, click 'Modify' to select and change the paragraph styles for each TOC level, setting the alignment to Center before clicking OK.

Frequently Asked Questions
Why does my Table of Contents lose its centered alignment when I update it?
This happens because the TOC reverts to its default paragraph styles whenever it is updated. To fix this permanently, you must modify the underlying 'TOC 1', 'TOC 2', etc., styles via the Styles pane instead of just highlighting the text and centering it directly.
What does the \n switch do in a TOC field code?
The \n switch tells the word processor to omit page numbers from the generated Table of Contents. It applies to all heading levels unless specifically restricted by a number range.
Can I hide page numbers for only specific heading levels?
Yes, you can hide page numbers for specific levels by adding the level range to the switch. For example, adding '\n 1-1' inside the field code will suppress page numbers only for Level 1 headings while keeping them for other levels.




