Word's table of contents feature is both flexible and complex; it offers a number of options for controlling structure and format. Moslehuddin ran into a problem when generating a table of contents after upgrading to Word 2016: The 2016 table of contents contains only the first heading level instead of two, which is what he wants. Fortunately, displaying both header levels is easy to do without resorting to a complete do-over. In this article, we'll review the underlying field code that determines what the table of contents displays.
I'm using Office 365 (Word 2016) on a Windows 10 64-bit system but these instructions will work in earlier versions. You can download the demonstration .docx or .doc files or work with your own document. Note that this technique won't work in the browser edition. This article assumes you know how to insert a field code. If you don't, you might read How to insert a table of contents into a Word document first. (That introductory article has instructions for Word 2007 and 2003, but the instructions for 2007 will be similar for 2016.)
SEE: 10 all-purpose keyboard shortcuts to boost your Word efficiency (free TechRepublic PDF)
A little about field codes
Word's table of contents feature inserts a field code that generates the table you see. The table is the result of that field and its many options, called switches. It's similar to entering a formula into an Excel cell and seeing the result of that formula rather than the formula itself.
The field identifies what it does, but switches allow you to customize the field's results. For a list of TOC field switches, see the table at the end of this article. Most of them, you'll never use, but it's good to know they're available.
Only one level
The simple two-page document shown in Figure A begins with a table of contents that displays only the first-level headings, even though the document contains two heading levels. It's important to note before we continue that Word's table of contents feature works seamlessly with Word's built-in heading styles. You can use other styles for your headings, but you'll have to work harder to generate a table of contents. Our example relies on the built-in Heading 1 and Heading 2 styles. (The Galleries heading is formatted with the Title style, so the table of contents doesn't include it.)
The example file displays only one heading level in the table of contents.
Right now, you can't see or modify the underlying field's switches. To do so, you must toggle the table to displays its underlying code instead of its results. First, select the entire table of contents; remember, Word doesn't treat the table of contents as ordinary text. When you hover over the table of contents, Word shades the entire table. Click inside to display the icons shown in Figure B. Click the stacked dots to select the entire table. With the table of contents selected, press Shift+F9 to display its underlying code, as shown in Figure C. (If you're using an earlier version, you must select the table of contents manually and press Shift+F9.)
You must select the table of contents first.
Toggle the table of contents to see the underlying field code.
This simple table of contents uses only a few switches: \o "1-1", \h, and \z. Referring to Table A, we can quickly discern that the table of contents includes only level 1 headings because of the \o "1-1" switch. To modify the switch, replace the second 1 with 2, as shown in Figure D.
Modify the switch parameter.
Now you're ready to toggle the field back to a meaningful table of contents. To do so, click Update Table, click the Update Entire Table option (Figure E), and then click OK. The last step is to toggle the field back to the text table by pressing Shift+F9. After doing so, you should see both levels 1 and 2 in the table of contents, as shown in Figure F. (In earlier versions, there's no Update Table icon; you must right-click the table of contents.)
Update the entire table.
The table of contents now displays level 1 and 2 headings.
Includes captioned items but omits element numbers. For instance, the table of contents would display Gallery Options...2 for an item on page 2 with the caption Figure 1: Gallery Options.
|\b||Bookmarks a section to display only those headings.|
|\c||Lists figures, tables, charts, and other items numbered by a SEQ field.|
|\d||Specifies the number of characters that separate the sequence numbers and page numbers. Combine this switch with \s.|
|\f||Generates a table from TC fields.|
|\h||Turns each entry into a hyperlink to the associated section. If you delete this switch, the field hyperlinks only the page numbers.|
|\l||Generates a table of contents using TC fields that assign entries to specified levels.|
|\n||Omits page numbers. For instance, \n 3-4 omits page numbers from levels 3 and 4. If you specify no range, the table of contents contains no page numbers.|
|\o||Specifies the heading levels included. The default is usually "1-3"; "1-1" would include only heading 1.|
|\p||Specifies a character used to separate entries and page numbers. You can use up to five characters; quotation marks are required. The default is leader dots.|
|\s||Includes an additional number, such as a chapter number, before the page number. The additional number must be the result of an SEQ field.|
|\t||Generates a table of contents from styled paragraphs other than the built-in heading styles. Combine with \o to combine custom and built-in heading styles. You can also use this switch to display annotations under headings.|
|\u||Generates a table of contents using the applied paragraph outline level.|
|\w||Preserves tabs in table entries.|
|\x||Preserves newline characters in table entries.|
|\z||Hides tab leaders and page numbers in Web Layout view.|
This isn't the only way to change levels, but after the fact, it's probably the easiest. You might never need most of the switches, but knowing they exist and how to toggle between the field code and its results so you can modify the switches is the key to getting exactly what you need.
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 firstname.lastname@example.org.
- 30 things you should never do in Microsoft Office (free TechRepublic PDF)
- How to create custom galleries and categories to control organization in Word docs (TechRepublic)
- Create an Excel data table to compare multiple results (TechRepublic)
- Office Q&A: How to use color to identify incoming Outlook messages (TechRepublic)
- Microsoft adds new mail, calendar, mobile features across its various Outlook clients (ZDNet)
Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.