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
\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
\chapter{First chapter}


I also get the numeration wrong:

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


-
\usepackage{tocbibind}; but I can't understand why one would put a TOC entry for the table of contents itself. Or use \cleardoublepage instead of \newpage. –  egreg Jun 23 '13 at 13:02
Why? I just need to, I have such requirements for my work. Package tocbibind works great, thanks! –  Gacek Jun 23 '13 at 13:08

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

-

As egreg mentioned in the comment there is the package tocbibind by PEter Wilson that supports inclusion of a the headings that are by default not showing up in the ToC. Via package options you can direct which of them should appar and which should be left out.

To explain why you approach doesn't work: the \addcontentsline will derive its page number from the placement it was put in the document. Now if you put it in front of \tableofcontents then the number wil be off by one, because the chapter inside the ToC will start a new page. If you put it after, then it will be wrong if the ToC has several pages. So its placement really needs to go into the definition of \tableofcontents and this is what the package does.

-

The best solution is using a feature of the document class, if the class supports this:

For other classes, package tocbibind can be used, as already explained in other answers and comments.

Also the \addcontentsline method will work, if it is put in the right place, either inside the definition of \tableofcontents or at the beginning of the .toc file. Example code for the latter:

\documentclass{report}

% if babel is loaded, e.g.:
% }

\AtBeginDocument{%
}%
}

\begin{document}
Title page\newpage
\tableofcontents*
\chapter{Introduction}
\end{document}


After the first run, the .toc file starts with

\addcontentsline {toc}{chapter}{\contentsname }
\contentsline {chapter}{\numberline {1}Introduction}{3}


The second run reads the .toc file and executes the \addcontentsline and the .toc will contain the \contentsline entry for the table of contents:

\addcontentsline {toc}{chapter}{\contentsname }
\contentsline {chapter}{\numberline {1}Introduction}{3}


After the third run, the table of contents if finished:

Remarks:

• The example also shows, how the standard name Contents can be changed into Table of contents.

• egreg's method is simpler, because it does not require an additional LaTeX run:

\cleardoublepage