[Tex/LaTex] Adding table of contents to contents – wrong page numeration

table of contents

I want the "Table of contents" position to appear in the table of contents. I'm using \addcontentsline to add this position, but the page numeration seems a bit odd.

I have a table of contents beggining at the page 3 (and it takes 2 pages). But using this combination of commands:

\newpage
\addcontentsline{toc}{chapter}{Table of contents}
\tableofcontents
\chapter{First chapter}

I get following output:

Table of contents..... 2 (should be 3!)
First chapter......... 5

When I use something like this

\newpage
\tableofcontents
\addcontentsline{toc}{chapter}{Table of contents}
\chapter{First chapter}

I also get the numeration wrong:

Table of contents..... 4 (should be 3!)
First chapter......... 5

How can I add the "table of contents" position to TOC correctly?

Best Answer

While I'm not sure why one would want to add a TOC entry for the table of contents, there can be a case where this is wanted: institutions that don't know better than imposing hilarious requirements for theses.

If you load the tocbibind package with

\usepackage{tocbibind}

not only the table of contents will appear automatically, but also the list of figures, the list of tables, the bibliography and the index.

Just in case, it's easy to avoid the TOC in the TOC by adding the nottoc option:

\usepackage[nottoc]{tocbibind}

Why didn't your method work? Because you probably are using a two-sided setup. So the \newpage will simply end the current page (1) and \addcontentsline{toc}{chapter}{Table of contents} appears at page 2, but \tableofcontents starts on the next right hand page, which is number 3.

The "manual" method should be

\cleardoublepage
\addcontentsline{toc}{chapter}{\contentsname}
\tableofcontents

but a higher level method is preferable; for instance, tocbibind works correctly also with hyperref, while the manual method requires another intervention.


Note that with the memoir class the declaration

\tableofcontents

adds the TOC in the TOC; the \tableofcontents* variant doesn't.