# 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}

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

```\cleardoublepage
\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.

```\cleardoublepage
\phantomsection
The extra command (`\phantomsection`) gives hyperref something to “hold on to” when making the link.
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.