Written by Allen Wyatt (last updated December 11, 2025)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365
Lindsay has a lengthy document (130 pages) where each page has a heading that appears in the TOC. He would like to insert a three-character code in each heading that will appear in the TOC immediately to the left of the right-justified page number. He's not been able to achieve this and would live to find a solution.
The way to accomplish this task depends on exactly where you want the three-character code to appear. It is clear that the code should appear in the TOC, and where it should appear in the TOC (just to the left of the page number), but it is unclear whether the code should also be visible in the headings. So, I'm going to look at both scenarios.
There is one thing you should realize as you work through this tip—I'm assuming you already know how to do basic TOC functions, such as inserting a TOC and updating existing TOCs.
The standard way of creating a TOC is based on heading styles within a document. When you insert the TOC, Word grabs all the paragraphs formatted with the first three heading styles—Heading 1, Heading 2, and Heading 3—and places them in the TOC. These paragraphs are, in turn, formatted using the first three TOC styles—TOC 1, TOC 2, and TOC 3.
Because the heading in the TOC is formatted with a different style than was used for the actual heading, you can modify the appropriate styles to control how the heading looks in each place.
For instance, let's say that this is your actual heading in the document:
Important Information ABC
Format this heading using the Heading 1 style and make sure that there is a tab character between "Information" and the three-character code ("ABC").
Now, modify the TOC 1 style to include two tab stops. The first should be a left-justified tab stop indicating where you want the three-character code to appear. The second should a right-justified tab stop indicating where you want the page number to appear.
Now, generate your TOC, and the code and page number should be positioned for each TOC element based on the tab stops you set. If you had previously inserted the TOC before you made changes in the TOC 1 style, you'll need to update the TOC. (Make sure you update the entire table, not just the page numbers.)
If the code and page number still don't align as you specified with your tab stops, then you need to make a change to the field used to generate the TOC. Position the insertion point within the TOC and then press Alt+F9. You should see the TOC replaced with the field code used to generate the TOC. It will look very similar to the following:
{ TOC \o "1-3" \h \z \u }
Change the code to add the \w switch, in this manner:
{ TOC \o "1-3" \h \z \u \w }
With the insertion point still within the field code, again press Alt+F9. The TOC should again appear, but the tabbing should now be correct. This is because the \w switch instructs Word to not delete any tab characters from the headings it places in the TOC.
Speaking of the headings, if you look back at them, you may notice that the tab character between the title ("Important Important") and the three-character code ("ABC") means that the horizontal position of the code within the heading may seem strange. That's because the tab means that the following text jumps to the position of the next tab stop. If the Heading 1 style doesn't have any tab stops specified, then the default tab-stop spacing (1/2 inch) is used. You can, of course, modify the tab stops within the Heading 1 style to minimize the horizontal displacement of the code.
Things may seem trickier if you don't want the three-character code to appear in the heading. However, it is actually a simple step from the concepts discussed in the previous section.
Make sure you set up everything as already described, but also create a new character style. (Not a paragraph style, mind you, but a character style.) Name this style something meaningful, such as "Hide Code." The only thing that is necessary within the style definition is to set the font color to white.
Next, go to each heading that includes a three-character code, select the code, and apply the Hide Code style to that text. The code will seem to disappear from the heading, but it will remain in the TOC, even if you update it. This is because character formatting, including formatting applied by a style, is ignored in when pulling headings into the TOC.
You might wonder why you cannot define the Hide Code style to be hidden text, rather than using a white font color. This is because, in testing, it seems that any hidden text is not transferred from the heading to the TOC entry; it is ignored by Word entirely.
There is an important caveat to note in these instructions, and you may have already recognized it. The horizontal ordering of elements within headings cannot be different from what you want in your TOC. In other words, you cannot order items as "code, title" in the heading and have it appear in the order "title, code, page number" in the TOC.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11163) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365.
The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2019. Spend more time working and less time trying to figure it all out! Check out Word 2019 For Dummies today!
If you need to create a specialized table of contents, you need to know how to add TOC entries to your document. It's ...
Discover MoreWord can handle very large documents, but some people find it preferable to break large documents into multiple ...
Discover MoreLinda's got a document that includes a table of contents that is based on headings in the document. When the headings ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments