Customize Table of Contents Field Codes and Formatting in Word for Mac
Question details
Customize a table of contents in Word for Mac using field codes and styles that retain formatting after updates.

- Product
- Microsoft Word for Mac
- Device & OS
- macOS
- Scenario
- The user wants to control TOC hyperlinks, bookmark scope, text colors, and page numbers for selected levels.
- Observed behavior
- Direct formatting applied to generated TOC entries may be removed when the table is updated.
Check which heading levels your table of contents includes and decide which levels need page numbers or different formatting. If you want to limit the table to part of the document, select that content and create a bookmark through Insert > Bookmark.
Edit TOC field switches and update the table
Use field switches to control hyperlinks, page numbers, and the scope of an existing table of contents.
Click the table of contents, then right-click or Control-click and choose Toggle Field Codes. If that command is unavailable, select the field and try Shift+F9; on some Macs, use Fn+Shift+F9.
In the displayed TOC field, add \h to create hyperlinks. Add \n "2-3" to omit page numbers for levels 2 through 3, adjusting the range as needed. For example, the field may read { TOC \o "1-3" \h \n "2-3" }.
To include entries only from a bookmarked portion of the document, add \b followed by the bookmark name, such as \b ChapterOne, to the TOC field.
Right-click or Control-click the TOC field and choose Update Field, then update the entire table if prompted. Toggle field codes again if needed and check the links and page numbers.

Modify TOC styles to preserve formatting
Use TOC styles instead of direct formatting when you want level-specific colors and fonts to survive updates.
Create separate tables for different level ranges
Use separate TOC fields when different parts of the document need different level ranges or field settings.
Create and edit documents with tables of contents in WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface for editing documents and working with tables of contents. Its Microsoft Word format compatibility helps you move existing documents into WPS Writer. It does not repair Word for Mac field-code or style issues.

Frequently Asked Questions
Why does my table of contents lose formatting when I update it?
Word regenerates TOC entries during an update, so direct formatting can be overwritten. Use Format > Style to modify TOC 1, TOC 2, and the other relevant TOC styles instead.
How do I make TOC entries hyperlinks in Word for Mac?
Toggle the TOC field code, add the \h switch inside the existing field, and choose Update Field. Update the entire table if prompted.
Can I remove page numbers for only some TOC levels?
Yes. Add a range to the \n switch in the TOC field. For example, \n "2-3" omits page numbers for levels 2 and 3 while leaving other levels unaffected.
How can I show a table of contents for just one section?
Select the section and create a named bookmark through Insert > Bookmark. Then add \b followed by that bookmark name to the TOC field and update the table.




