Your support for our advertisers helps cover the cost of hosting, research, and maintenance of this document

Formatting Information — An introduction to typesetting with LATEX

### Chapter 2: Basic structures

All auto-numbered headings (parts, chapters, sections, subsections, etc) get entered in the Table of Contents (ToC) automatically. You don’t have to print a ToC, but if you want to, add the command \tableofcontents at the point where you want it printed (usually after the Abstract or Summary).

Entries for the ToC are recorded each time you typeset your document, and only reproduced the next time you typeset it, so you need to run LATEX an extra time to ensure that all ToC page-number references are correctly resolved. This should be done automatically by your editor as needed, whenever you click the , , , or button or menu entry (see Figure 1.4).

The commands \listoffigures and \listoftables work in exactly the same way as \tableofcontents to automatically list all your tables and figures. If you use them, they normally go after the \tableofcontents command.

We’ve already seen in § 2.6 how to use the optional argument to the sectioning commands to add text to the ToC which is slightly different from the one printed in the body of the document. It is also possible to add extra lines to the ToC, to force extra or unnumbered section headings to be included.

1. Add the \tableofcontents command to your document, after the \maketitle command but before the Abstract.

2. Typeset the document.

If you are using your editor’s Build to typeset the document, it should re-run LATEX if necessary, to make sure the Table of Contents is updated to reflect any changes you have made (for example in section numbering, or adding, deleting, or moving sections or chapters around.

3. If the Table of Contents does not reflect your document structure, you need to typeset it one more time, to bring it up to date.

The \tableofcontents command normally shows only numbered section headings, and only down to the level defined by the tocdepth counter (see § 2.6.1), but you can add extra entries with the \addcontentsline command. For example if you use an unnumbered section heading command to start a preliminary piece of text like a Foreword or Preface, you can write:

\subsection*{Preface}

\addtocontents{toc}{\par\hrule\vspace{6pt}}