Configure Word Table of Contents Styles with TOC Field Codes
Question details
Configure which custom styles appear at each level of a Word table of contents and investigate unexpected paragraph formatting.

- Product
- Microsoft Word
- Device & OS
- Windows 10
- Scenario
- A document uses custom title and header styles that need to be included at specific table of contents levels.
- Observed behavior
- Word does not retain the selected custom styles in the Table of Contents dialog, and ordinary paragraphs appear with heading formatting after the table is updated.
Identify the exact names of the paragraph styles to include and the TOC level each should use. Click a sample paragraph and check its style in Home > Styles.
Map styles to TOC levels with the Word TOC field code
Use the TOC field's \t switch when the Table of Contents Options dialog does not retain your style selections.
Click the existing table of contents and press Alt+F9 to display field codes in the document.
In the existing TOC field, replace the \o switch with a \t mapping. For example, use { TOC \t "Heading 1,1" \h } to include Heading 1 at TOC level 1. For custom styles, use their exact names, such as { TOC \t "Custom Title,1,Custom Header,2" \h }.
Click inside the TOC field and press F9. If prompted, choose Update entire table, then press Alt+F9 to show the table instead of the field code.
If ordinary paragraphs still appear as headings, click an affected paragraph and check Home > Styles. Apply the intended body-text style if it has an incorrect heading or custom style.

Work with styled documents in WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface for working with Word documents. Open compatible files in WPS Writer to continue editing and ease your migration from Microsoft Office; it does not repair Word's TOC settings.

Frequently Asked Questions
How do I include more than one custom style in the TOC?
Press Alt+F9 and add each style name and level to the \t switch, for example: \t "Custom Title,1,Custom Header,2". Click the field and press F9 to update it.
Why are ordinary paragraphs appearing in my table of contents?
They may have a style included in the TOC mapping. Click an affected paragraph and check Home > Styles, then apply the appropriate body-text style if needed.
How can I show the table again after editing its field code?
Press Alt+F9 to toggle field codes back to their results. If the table has not refreshed, click it and press F9.
What is the difference between the \o and \t switches?
The \o switch includes built-in heading levels in a specified range, while \t maps named styles to TOC levels. Remove \o if you want the field to use only the styles specified by your \t mapping.




