Image: Ahlapot, Getty Images/iStockphoto

WWord’s table of contents (TOC) feature is powerful and flexible but getting the results you need isn’t always possible using its built-in options. Often, you must modify the underlying field code to get certain results. That’s what Giovanni ran into. He wants to remove page numbers from an annotation. Fortunately, the solution is simple, if you know how to modify the TOC’s underlying field code.

A field code is a set of instructions that you can modify—smart text, of a kind. The results aren’t literal text, but the field code displays text. You can customize a field code by adding switches. Often, a switch is the only way to make certain customizations. Switches are just more instructions.

I’m using Office 365 on a Windows 10 64-bit system, but this solution will work in older versions. However, it isn’t supported by the browser version, although you can update an existing TOC. You can work with any document or download the demonstration .docx and .doc files.

TOC basics

Word offers two ways to insert a TOC:

  • Using the Table of Contents option on the References tab offers a gallery with a few pre-defined TOCs, and access to customizing options.
  • Using Quick Parts on the Insert tab lets you enter the TOC’s underlying field code manually.

Both offer options that allow you to customize all levels of your TOC. However, neither option lets you omit page numbers from a specific level. You can, however, remove all page numbering, which is something you probably won’t want to do often.

Use the Reference tab

If you plan ahead, you may know that you want to omit page numbers and create the TOC accordingly–for the most part. For instance, the simple document shown in Figure A needs a TOC. We’ve already applied Heading 1 to the section text and Heading 4 to the annotation text. (Using built-in styles isn’t strictly necessary to create a TOC, but it’s the easiest way.) We don’t want page numbers displayed for annotations; currently, we have only two levels: Heading 1 and Heading 4.

Figure A

Let’s add a TOC to this simple document.

First, let’s use the Reference tab to insert a TOC and see if we can turn off page number:

  1. Position your cursor within the document where you want the TOC to be.
  2. Click the References tab.
  3. In the Table of Contents group, click Table of Contents, and choose Custom Table of Contents from the dropdown. Notice that the Print Preview display (Figure B) doesn’t display Heading 4 (the style we used for the annotations). This feature defaults to three levels, Heading 1, Heading 2, and Heading 3.
  4. To add the annotations to the TOC, click Options. In the resulting dialog, enter 4 in the TOC level control to the right of Heading 4 (Figure C), and click OK. You might consider removing levels 2 and 3 because Heading 2 and Heading 3 are in use, but I recommend that you don’t. You might add them later, and when the TOC doesn’t update to show those levels, you might not remember why.
  5. Uncheck the Show page numbers option (Figure D). Before clicking OK, notice that the preview now displays Heading 4.
  6. Click OK to return to the document. Figure E shows the resulting TOC. All page numbers are gone, but we want to remove the page number only for the annotation level.

Figure B

The default TOC doesn’t include the annotations (Heading 4 text).

Figure C

Add a level for the annotations.

Figure D

Disabling page numbering disables it for the entire TOC.

Figure E

Without page numbers, this TOC isn’t useful.

Without page numbers, the TOC isn’t particularly useful. In fact, it’s not obvious that it is a TOC. Before you continue, delete the TOC by right-clicking anywhere inside the TOC to select it. Then, press Delete twice.

Insert a field code

The References tab doesn’t allow you to remove page numbering from a specific level. Inserting the TOC field code will have similar results.

To insert the field code manually, do the following:

  1. Position the cursor where you want the TOC to be.
  2. Click the Insert tab.
  3. In the Text group, click Quick Parts and choose Field from the resulting dropdown.
  4. In the Field Names list, choose TOC. The Table of Contents button will display the same dialog used previously (when you added Heading 4 and unchecked the page numbering option), but don’t click the button now.
  5. Click OK to see the TOC shown in Figure F.

Figure F

This TOC displays page numbers.

The annotations are included this time because you added Heading 4 in the previous section. You can use both methods to create the TOC with or without page numbers. However, neither method lets you remove page numbers from a specific level–Heading 1 or Heading 4.

Remove page numbers from annotations

For better or worse, the built-in page numbering option is all-or-nothing. However, you can directly alter the field code to disable page numbering for specific levels. If field codes are new to you, don’t worry—you’ll catch on quickly.

Before we make any changes, let’s examine the field code itself. To do so, right-click anywhere inside the TOC and choose Toggle Field Codes. Figure G shows the resulting field code. The default code that we added earlier has little to distinguish itself. (If you insert the TOC using the References tab, the field code will display more information.)

Figure G

A basic TOC field code.

We’ll use the
switch to remove page numbers from the fourth level (the annotations) using the following format:


The switch is
and the first and last parameters identify the levels. In this case, we’ll use
4-4 because we’re omitting page numbers only from level 4. If you enter 1-4, you’d omit page numbers from levels 1 through 4. You must enter both boundaries–
4 won’t work.

To modify the field code, insert the cursor between TOC and and enter
4-4. Add a space character to separate the new switch from the format switch, as shown in Figure H.

Figure H

Add the

To display the results of the code, shown in Figure I. right-click the field code and choose Update field. As you can see, adding the
switch removes page numbers for level 4—the annotations.

Figure I

The new TOC no longer displays page numbers for the annotations.

Alter field code for more flexibility

Sometimes the only way to get what you want when customizing a TOC is to alter the TOC’s underlying field code. There’s almost nothing you can’t accomplish with the right switch and some creative planning.

Send me your question about Office

I answer readers’ questions when I can, but there’s no guarantee. Don’t send files unless requested; initial requests for help that arrive with attached files will be deleted unread. You can send screenshots of your data to help clarify your question. When contacting me, be as specific as possible. For example, “Please troubleshoot my workbook and fix what’s wrong” probably won’t get a response, but “Can you tell me why this formula isn’t returning the expected results?” might. Please mention the app and version that you’re using. I’m not reimbursed by TechRepublic for my time or expertise when helping readers, nor do I ask for a fee from readers I help. You can contact me at

Most likely, you’ll want the annotation text to have the same formatting as the rest of the text. To simplify this example, I skipped doing so. To learn how to do this, read Use a custom style to annotate a Word table of contents.

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays