UK TeX FAQ -- question label tocbibind

### Bibliography, index, etc., in TOC

The standard LaTeX classes (and many others) use `\``section*` or `\``chapter*` for auto-generated parts of the document (the tables of contents, lists of figures and tables, the bibliography and the index). As a result, these items aren’t numbered (which most people don’t mind), and (more importantly) they don’t appear in the table of contents.

The correct solution (as always) is to have a class of your own that formats your document according to your requirements. The macro to do the job (`\``addcontentsline`) is fairly simple, but there is always an issue of ensuring that the contents entry quotes the correct page. Supposing that our the document is chapter-based (class report or book, for example), the text:

>     \bibliography{frooble}
>     \addcontentsline{toc}{chapter}{Bibliography}

will produce the wrong answer if the bibliography is more than one page long. Instead, one should say:

>     \cleardoublepage
>     \addcontentsline{toc}{chapter}{Bibliography}
>     \bibliography{frooble}

(Note that `\``cleardoublepage` does the right thing, even if your document is single-sided — in that case, it’s a synonym for `\``clearpage`). Ensuring that the entry refers to the right place is trickier still in a `\``section`-based class.

If you are using hyperref (which will link entries in the table of contents to the relevant place in the file), a slight adjustment is necessary:

>     \cleardoublepage
>     \phantomsection
>     \addcontentsline{toc}{chapter}{Bibliography}
>     \bibliography{frooble}

The extra command (`\``phantomsection`) gives hyperref something to “hold on to” when making the link.

The common solution, therefore, is to use the tocbibind package, which provides many facilities to control the way these entries appear in the table of contents.

Classes of the KOMA-script bundle provide this functionality as a set of class options (e.g., `bibtotoc` to add the bibliography to the table of contents); the memoir class includes tocbibind itself.

`hyperref.sty`
  macros/latex/contrib/hyperref (or browse the directory); catalogue entry
`KOMA script bundle`
  macros/latex/contrib/koma-script (or browse the directory); catalogue entry
`memoir.cls`
  macros/latex/contrib/memoir (or browse the directory); catalogue entry
`tocbibind.sty`
  macros/latex/contrib/tocbibind (or browse the directory); catalogue entry

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=tocbibind