Illustration: Lisa Hornung, Getty Images/iStockPhoto

I’d love to see Microsoft Word’s table of contents feature lose a bit of its mystery. A lot of people never use it because it intimidates them, or they think they don’t have time to learn.

The good news is, it’s easy to use when the user’s needs fit Word’s default expectations. You style the headings appropriately; click a few buttons, and you have a table of contents. Throw in a monkey wrench or two, and the casual user is stymied. The good news is that most wrenches can be accommodated once you understand how the apparatus works, and that’s not as difficult or time-consuming as you might think. In this article, I’m going to deal with a simple monkey wrench, and show you just how far a little knowledge can go.

LEARN MORE: Microsoft 365 for business

I’m using Microsoft 365, but you can use earlier versions. You can work with your own document or download the demonstration .docx file. This article isn’t appropriate for the browser edition.

The problem with Word’s table of contents

If you’ve used the table of contents feature before, you know that Word uses the built-in header styles to generate a table of contents. It’s automatic, and all you have to do is apply the headings: Word does all the work behind the scenes. All is right with the world until you require something beyond automated mode, which can switch you into head-scratching mode.

Now, let’s consider a simple request that Word, at first, doesn’t seem to handle. Suppose you have several headings throughout a document. You used Heading 1 to style each heading. When you run the table of contents, Word includes every heading from every section—that’s what you’d expect. However, that isn’t what you need; you want only the first heading in each section to be included. Before we try to accomplish the seemingly impossible, let’s review the easy stuff.

Use automated table of contents feature

Let’s work through the automated feature in case you’re not familiar with how it works. Even if you are, reviewing this feature is a good start. The simple document in Figure A comprises two sections. Each section has a few headings styled with Heading 1. (I enabled Show/Hide so you can see the section break.)

Figure A

If you’re working from scratch, and you don’t know how to insert a section break, here’s how:

  1. Position the cursor where you want to insert the break.
  2. Click the Layout tab.
  3. From the Breaks option (in the Page Setup group), choose one of the section break options. I used Continuous in order to keep everything on the same page (keeping things simple).

Now, let’s illustrate how the automated feature works using our simple document:

  1. Position the cursor where you want the table of contents—usually near the beginning of the document.
  2. Click the Reference table.
  3. From the Table of Contents dropdown (in the Table of Contents group), choose the first built-in thumbnail, Automatic Table 1 (Figure B).

The new table of contents is at the top of the page, as shown in Figure C. At this point, you would probably create a page break between the table of contents and the document, but we’re not going to do so for this simple demonstration.

Figure B

Figure C

Using the automated feature, all you had to do was apply built-in heading styles, in this case, Heading 1, and choose a predefined table of contents. I recommend using the automated feature when you can. Now, let’s move on to a more complicated requirement.

Accommodate the monkey wrench

When you insert the table of contents, Word uses all text styled with one of the built-in heading styles. In this case, we kept things simple and used only one heading level, Heading 1.

However, would you be surprised to learn that the automated feature can easily handle our monkey wrench? The key is understanding the relationship between the built-in styles and the feature itself.

In our case, we only want to include the first Heading 1 heading in the table of contents. The solution is a simple style trick. We’ll use direct formatting to create a style that’s the same as Heading 1. When formatting the document, use Heading 1 only for the first heading in each section. Use the custom style for all the rest. Both styles will be identical in the formatting they apply; only the names will be different.

When Word looks for headings to include in the table of contents, it will find only the one Heading 1-styled heading at the beginning of each section. It will ignore the rest (in each section) even though they look identical.

The demonstration file already contains H1 Custom. However, I recommend you go through the motions of creating it yourself as follows:

  1. Remove the formatting from a heading that you don’t want to include—change it to Normal.
  2. Apply the following format directly (it’s the same as Heading 1):
    Font: Calibri Light (Heading)
    Size: 16
    Color: Accent 1 (Blue, Accent 1, Darker 25%); it’s in the fifth row from the left, and the fourth row down.
    Spacing: Before 12, After 0
  3. With the directly formatted heading selected, open the Styles pane (if necessary) by clicking the Styles group’s dialog launcher.
  4. At the bottom, click the New Style option (Figure D).
  5. In the resulting dialog, enter the style name, H1 Custom.
  6. From the Style for following paragraph dropdown, choose Normal (Figure E). Don’t base the new style on Heading 1.
  7. Click OK. (If you’re working with the demonstration file, Word won’t let you create a new style using the same name, so don’t worry when you see the warning.)

Figure D

Figure E

After creating the new style, you can use the Format Painter or the Styles Pane to reformat the remaining headers. All of the headers will look the same, but as you browse through them, you will see that only the first is Heading 1 and the remaining headers in each section are H1 Custom.

SEE: How to add an automated signature to a Microsoft Word document (TechRepublic)

If it feels like you’ve worked hard, that’s OK. Once you’re more familiar with styles beyond applying, you’ll feel differently. You will think differently, and the solutions will come easier to you. It’s difficult to work blindly—not understanding exactly why you’re doing what you’re doing.

The moment of truth

Let’s recap a bit. You created a custom style that looks like Heading 1 and named it H1 Custom. Then, you applied the custom style to the headings you don’t want in the table of contents. Now it’s time to see if it worked!

Return to the original table of contents and click Update Table. When prompted, select Update the Entire Table, and click OK. Figure F shows the updated table of contents; it shows only two Heading 1 headers.

Figure F

If you’re wondering why we needed the section break, the truth is, we didn’t. Its only real purpose is to show that they’re not an encumbrance. Word will include all the Heading 1 headings, whether they’re in different sections or not, but adding the section break makes the rule a bit more realistic.

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