While you can manually add an entry to the TOC by
\addcontentsline, the order of commands can be important, especially
- if you use
hyperref, to get the hyperlink above the heading, not below
- or if you add a section to the TOC, which is done by a macro but several pages long, such as by
\bibliography. A wrong order would add the last page to the TOC
- ensure the required page break before
for hyperref, add an anchor for the target
If you need that several times, you could define a macro for it.
Regarding the commands:
\cleardoublepage ends the page, prints out remaining floats if necessary, and ensures that the following text starts on a right hand page, as chapters in books commonly do, if in twoside mode.
\clearpage, in contrast, would start the new page on a left or a right side.
\phantomsection is a command of the
hyperref package, which creates an anchor at this location, similar to
\hypertarge, which can be referred to -
\addcontentsline does it implicitely. Without
\addcontentsline would refer to the previous anchor which could be undesired.
tocbibind makes putting commonly added chapters/sections (bibliography, TOC, index) to the TOC easier. It's integrated in the
memoir class, while KOMA-Script classes support this purpose by class options such as