25.1.4 \contentsline

Synopsis:

\contentsline{unit}{text}{pagenumber}

Used internally by LaTeX to typeset an entry of the table of contents, list of figures, or list of tables (see Table of contents, list of figures, list of tables). Authors do not directly enter \contentsline commands.

Usually adding material to these lists is done automatically by the commands \chapter, \section, etc. for the table of contents, or by the \caption command inside of a \figure or \table environment (see figure and see table). Thus, where the root file is thesis.tex, and contains the declaration \tableofcontents, the command \chapter{Chapter One} produces something like this in the file thesis.toc.

\contentsline {chapter}{\numberline {1}Chapter One}{3}

If the file contains the declaration \listoffigures then a figure environment involving \caption{Test} will produce something like this in thesis.lof.

\contentsline {figure}{\numberline {1.1}{\ignorespaces Test}}{6}

To manually add material, use \addcontentsline{filetype}{unit}{text}, where filetype is toc, lof, or lot (see \addcontentsline).

For manipulating how the \contentline material is typeset, see the tocloft package.

Note that the hyperref package changes the definition of \contentsline (and \addcontentsline) to add more arguments, to make hyperlinks. This is the source of the error Argument of \contentsline has an extra } when one adds/remove the use of package hyperref and a compilation was already run. Fix this error by deleting the .toc or .lof or .lot file, and running LaTeX again.


Unofficial LaTeX2e reference manual