Tables of contents

« Table of contents

« Numbering in action

The Table of contents (TOC) is not a Numbered List. It simply copies the text of the headings in page number order, including any numbering that may be applied. If the headings have numbers, the TOC generator copies those numbers. The generator automatically applies TOC Styles 1 to 9 to format the TOC. The generator sets the styles to Automatically Update, which enables it to automatically set their formatting according to hard-coded defaults chosen by the TOC format setting. If you want to prevent this, set your TOC format to From Template. Word will then leave the formatting of your TOC styles alone.

Simple and stable: not much goes wrong with TOCs for this reason. The only catch is that the entire TOC is a field itself, and if you don't know this, you can mangle it.

The TOC field supports a variety of switches, enabling you to fine-tune its format. For details, see: Customizing your table of contents with switches.

The generator actually generates the page numbers in the TOC by inserting a hidden bookmark at every Heading in the document. In the TOC itself, Word 97 generates a hyperlinked PAGEREF field for each page number, referencing the appropriate heading (if you click on the page number it takes you to the Heading). In Word 2000 it generates a more complex hyperlinked field, which allows you to click on the text in the TOC to go to the referenced Heading.

Either way, you can see these hyperlink fields by right-clicking any page number and selecting Toggle Field Codes.You can see the hidden bookmarks by selecting any Heading in the document, selecting Insert>Bookmark, and ticking the Show Hidden Bookmarks checkbox.The hidden bookmark applied to the heading you are in will be selected in the dialog, and its name will tally with that in the relevant field in the TOC itself.

When you update the TOC (by selecting it, pressing F9, and choosing Update entire Table), all the hidden bookmarks that have been applied to the Headings are deleted and recreated – you can see that their names have changed, if you look. However, prior to Word 97, the hidden bookmarks were not deleted when you regenerated the TOC; instead, a new set of bookmarks was created each time;so you could very quickly end up with hundreds of redundant bookmarks, leading to a huge increase in file size and, frequently, to document corruption.

You can convert the entire TOC to ordinary text. If you do, the styles remain applied and the entries are all converted to hard text. People sometimes do this to prevent document corruption. In Word 6, if you re-generated the TOC too many times, the document would corrupt, so people would convert the TOC to hard text to prevent this happening. This is no longer so necessary in Word 95 and above, but you may find it in up-converted documents. The problem with the technique is that when the document gets to a different computer, the page numbers in the TOC may be wrong.

You will rarely see problems with TOC numbering. If you do, unless the user has manually typed the wrong numbers into the TOC, the problem exists in the body of the document, not in the TOC. If you regenerate the TOC, you remove any manually typed numbers, unless they are in the body of the document. In fact, the TOC is an excellent device for looking for numbering problems in the body of the document. Since you have to check the TOC anyway before you publish, you might as well look for numbering problems while you are at it.