[Tex/LaTex] Long table of contents makes page numbers wrong

compilingpage-numberingtable of contents

I have created a table of contents page using \tableofcontents and I have enough chapters and sections that it fills an entire page and goes into another.

The problem is that since it takes a second page all of the page numbering is off by 1.

Is there a way that I can fix that?

Best Answer

Creating a table of contents (ToC) needs at least two LaTeX runs: The first run to collect the data for the ToC and write it into an auxiliary file, the second run to actually typeset the ToC. In case the ToC itself takes more than one page, a third LaTeX run is needed (which will use the auxiliary data from the second run).