Word Hacks [Electronic resources]

Andrew Savikas

نسخه متنی -صفحه : 162/ 48
نمايش فراداده

Hack 25 Include Only Part of a Heading in a TOC

Give your headings more flexibility while keeping the table of contents (TOC) under control.

Tables of content can provide useful roadmaps for navigating long documents. Typically, a TOC displays a document's headings alongside the page numbers on which they appear. Sometimes, however, you may want only part of a heading to appear in the TOC.

For example, consider the document shown in Figure 3-47. The title is included on the same line as the chapter number, but in the TOC only the chapter number should appear, as shown in Figure 3-48.

Figure 3-47. Chapter numbers and titles appear on the same line

Figure 3-48. Only the chapter number should be included in the TOC

Accomplishing this task became much easier in Word 2002, but it's still a bit tricky. How you implement these "run-in headings" depends on which version of Word you're using.

3.13.1 Word 2002 and Higher

Microsoft included a feature in Word 2002 to make it easier to include only part of a heading in the TOC. A new type of formatting mark, called a StyleSeparator, creates a hidden barricade between portions of text in a paragraph. As the name implies, this mark lets you use two different paragraph styles within the same paragraph (and you avoid the Char Char problem [Hack #55] typically encountered with multiple paragraph styles applied within the same paragraph).

Immediately following a heading, you can insert one of these new StyleSeparators to create, in effect, a new paragraph that starts on the same line as the heading, as shown in Figure 3-49. Thus, you can apply a paragraph style independent of the heading, which means it won't appear in the TOC.

By default, you can access the StyleSeparator only from the Commands tab of the Customize dialog. Select ToolsCustomize, then select All Commands in the Categories column, as shown in Figure 3-49. Once you've located the InsertStyleSeparator command in the Commands list, you can place it on the menu or toolbar of your choice [Hack #1] while you've got the Customize dialog open.

Figure 3-49. Locating the InsertStyleSeparator command

To create a run-in heading (such as those shown in Figure 3-47) using a StyleSeparator, put your cursor anywhere in the heading paragraph, then select the InsertStyleSeparator command you just placed on a menu or toolbar. If you've got paragraph marks turned on [Hack #1], you'll notice that the one at the end of the heading paragraph is no longer visible.

Documents that include StyleSeparators will still open and function correctly if you send them to someone using Word 2000. Word 2000 interprets the separators as hidden paragraph marks. When you get the document back, however, Word leaves the StyleSeparators as hidden paragraph marks (which they suspiciously resemble anyway).

3.13.2 Word 2000

To get the run-in-heading effect in Word 2000, you need to do a bit more legwork.

First, select ToolsOptions, click the View tab, and check the "Paragraph marks" box. Next, make sure you uncheck the "Hidden text" box, then click the OK button.

Select the trailing paragraph mark for the first heading you'd like to run in. Then select FormatFont, check the Hidden box, and press the OK button (or press Ctrl-Shift-H). Now you've got two paragraphs on the same line, as shown in Figure 3-47. You can style the second paragraph with its own paragraph style, independent of the heading, which means it won't appear in the TOC.

It would be tedious work to apply this hack to every heading in a document, but you can simplify it with a Find and Replace.

In the "Find what" box, put ^p.

Click the More button if the Format button isn't visible.

With your cursor in the "Find what" box, click the Format button, select Style, and select Heading 1 (or the heading style that you'd like to run in).

In the "Replace with" box, put ^&.

With your cursor in the "Replace with" box, click the Format button, choose Font, and check the Hidden box.

Click the Replace All button.