Formatting Headings for Inclusion in a Table of Contents
Fixing a TOC doesn't take long if you know what steps to take. But it's even better if you know what formatting to avoid in the first place!
So here’s a perennial problem: You make a long document, like a book, then build a table of contents (Layout > Table of Contents)… and the headings show up in the TOC with extra formatting and characters! Specifically, much of the local formatting or character styles you applied to a heading in the document gets pulled into the TOC, even when you wish it didn’t. And, worse, if you inserted any forced line breaks (Shift-Return/Enter) in the heading — usually in order to make it look better as it breaks across two or more lines — also come along for the ride!
For example, here’s a problematic TOC:

The first chapter head has a shift-return in it, so it breaks across two lines — we only want it on one line in the TOC. The third, fourth, and fifth lines have some underlining in it, picked up from local formatting in the document.
Unfortunately, these are the facts of life. There’s no way to make a TOC and automatically strip out the stuff you don’t want. But you can remove the undesirable dross relatively quickly, or even set up the headings in a way that they won’t require so much clean-up later.
Strip the Formatting
Any local character formatting applied to a portion of a paragraph gets included in the TOC. If you select the whole paragraph and apply the local formatting (like changing color or size), it’s ignored in the TOC. That’s why in lines 3 and 4 of the example above, the formatting — color or underlining — appears.
Character styles, however, always get sucked into the TOC, whether you apply them to a letter or the whole paragraph. That’s why the text in the fifth line is all messed up. Note that the formatting even extends out to the page number!
One of the easiest ways to remove the formatting after you create the TOC is to select all the text in the story (the TOC) and click the Clear Overrides button at the bottom of the Paragraph Styles panel. That removes any local formatting. Now, to remove the character styles, click None in the Character Styles panel.
Of course that removes all the formatting! If you need to remove some formatting but keep other formatting, I would suggest checking out the “Type > Remove Local Formatting” feature in the Blatner Tools plug-in suite.
Remove Soft Returns
If you have used soft returns (Shift-return/enter) to force a line of text to break from one line to the next, you’ll probably want to remove those in the TOC. The reason they show up is that they are real characters, albeit invisible ones (along with tabs, column brakes, spaces, and so on).
If they’re already in your TOC, you can strip them out using Edit > Find/Change. In the Find What field, type ^n (caret-n). Leave the Change To field blank. Set the Search pop-up menu to Story (so it just applies to the table of contents), and click Change All.
However, even better advice: Avoid using the soft returns in the headings to begin with. Instead, use paragraph or character formatting to manage the line breaks. For example, you could try using Balanced Ragged Lines to break the heading better. Or adjust the left and right paragraph margins. Or use No Break or some other local formatting that doesn’t involve adding actual characters.
Using formatting to adjust line breaks is better because then you won’t have to take this extra find/change step. And if you later export the text as XML or RTF or HTML or whatever, you don’t need to worry about those extra characters, too!
It’d be nice if there were a way to make a perfectly formed table of contents every time. But in my experience, TOCs almost always require fiddling, fixing, and finagleing. That’s why it’s best to create them as a last step… the fewer times you need to fff them, the better.
This article was last modified on December 20, 2021
This article was first published on February 4, 2010
