¶ Writing & documents

Automatic table of contents, captions and cross-references

How to generate in Word and Writer a table of contents, a list of figures and cross-references that update themselves, avoiding page numbers typed by hand.

In a thirty-page document, a hand-written table of contents is already wrong at the first revision: you add a paragraph, everything shifts by half a page and the numbers no longer match. The same goes for sentences such as «see table 4 on page 12»: insert a table earlier and the reference becomes false.

Word and LibreOffice Writer can handle all of this on their own. There is only one condition: the document must be built with the right styles and features.

The prerequisite: headings with styles

The table of contents does not read large or bold text: it reads heading styles (Heading 1, Heading 2, Heading 3) or, more precisely, their outline level. If the headings in your document are ordinary paragraphs formatted by hand, the table of contents will come out empty.

A quick check is to open the navigation pane (in Word View › Navigation Pane, in Writer the Navigator with F5): if all the headings appear there in the correct hierarchy, the table of contents will work.

Inserting the table of contents

Word: place the cursor where you want the table of contents and use References › Table of Contents. The automatic style is fine to start with; with Custom Table of Contents you choose how many levels to include, whether to show right-aligned page numbers and with which leader character.

Writer: Insert › Table of Contents and Index › Table of Contents, Index or Bibliography. On the Type tab you decide how many levels to evaluate; on the Entries tab you change the composition of each line, for example adding the chapter number.

In both programs, in the exported PDF the table of contents entries become clickable links.

Updating

The table of contents does not update in real time. Before saving the final version:

  • in Word, click in the table and choose Update Table, selecting «Update entire table»; or select everything and press F9 to update all fields;
  • in Writer, Tools › Update › Update All.

Never edit the text of the table of contents by hand: at the first update your changes disappear. If an entry is wrong, fix the heading in the document.

Numbered captions

For figures, tables and equations you use captions, which the program numbers automatically:

  • Word: right-click the image or References › Insert Caption. You choose the label (Figure, Table, Equation) and the position, above or below. With Numbering you can include the chapter number: «Figure 3.2».
  • Writer: right-click the object and Insert Caption. Categories correspond to separate counters for illustrations, tables, text and drawings.

Typing «Figure 1» by hand under an image produces text the program does not recognise: no automatic numbering and no list of figures.

List of figures and tables

Once captions are inserted with the correct feature, the list of figures is generated like the table of contents:

  • in Word with References › Insert Table of Figures, choosing the label;
  • in Writer with the same menu as the table of contents, selecting the «Table of Figures» or «Index of Tables» type.

It is useful in technical documents with many diagrams, in data-heavy reports and in manuals.

Cross-references

A cross-reference is a pointer to an element that displays up-to-date information about it: its number, the heading text or the page.

Word: References › Cross-reference. You choose the type (Heading, Figure, Table, Numbered item, Bookmark), the specific item and what to show: «Only label and number», «Page number», «Heading text». Leaving the hyperlink option enabled makes the reference clickable.

Writer: Insert › Cross-reference. On the Cross-references tab you choose the type, for example «Headings» or «Table», the item and the format: «Number», «Page», «Reference» for the text.

A typical example:

As shown in Table 4 on page 12, response times…

Here «Table 4» and «12» are two references to the same object, one to its number and one to its page. If the table moves, both update.

Frequent mistakes

Problem Cause Solution
Empty or incomplete table of contents Headings without heading styles Apply the Heading 1-3 styles
«Error! Reference source not found» The target element was deleted Recreate the reference
Old page numbers Fields not updated Update everything before exporting
Captions numbered twice Number typed by hand on top of the field Delete the manual number
Odd entries in the table of contents Ordinary paragraphs with an outline level assigned Fix the level in the style

In short

  • Table of contents, list of figures and cross-references work only if headings and captions use the dedicated features.
  • The navigation pane is the quickest way to check the heading structure.
  • Fields do not update on their own: update everything before exporting or printing.
  • Do not edit the table of contents text by hand: fix the heading in the document.
  • Cross-references can show number, text or page and stay correct after every change.
MM
Marco Marzaduri

Marco Marzaduri works in cybersecurity, digital forensics and web development. A computer science graduate, he combines rigorous technical analysis with attention to the people who use technology.

Read also