# Full page figure and TOC

When adding full page figures to books on latex, has anyone had experience where it messes up their TOC numbering? If so, how do you fix this??

• Welcome to TeX.SX! You mean Table of Contents (i.e. chapters linked with their page number), or List of Figures (Figure numbers & titles linked with their page number)? Have you tried to compile twice? (During the first run, `LaTeX` looks for figures and memorize their page number; and during the second, it updates the ToC and LoF.) – ebosi Oct 17 '16 at 8:11
• if the numbering in the table of contents is wrong (after re-running latex until it stabilises) then either there is an error in your input and we can't suggest how to fix it unless you show what you did, or at least, what the error was, or there is a latex bug that you should report (but again we'd need a test file) – David Carlisle Oct 17 '16 at 8:34
• Hi both, @ebo made the best suggestion. Compiling my source file as `pdflatex FILENAME pdflatex FILENAME bibtex FILENAME pdflatex FILENAME` pdflatex FILENAME Did the trick. Basically, to start with, my latex code just had a few figures, some of which happened to span a page (no special flags for float environments). I think this threw the numbering off; compiling twice somewhow helped! – thestatnoob Oct 17 '16 at 10:15

For both the Table of Contents (`toc`, linking chapters, sections, etc. with their page numbers) and the List of Figures (`lof`, linking figure numbers and titles with their page number), you need to compile your document twice in order to get the information updated in your produced document (the `pdf` in your case).

Indeed, these commands (`\tableofcontents` and `\listoffigures` respectively) basically works as following:

1. During the first run of compilation (via the bash command `latex <yourDocumentName>.tex`, `pdflatex <yourDocumentName>.tex`, `lualatex <yourDocumentName>.tex`, etc. you type in your terminal), the macro `\tableofcontents` "scans" the entire document, and memorize where is each figure/section.
2. At the second run, the macro creates a ToC/LoF based on memorized information, or "update" the existing one if any.

Thus, a generally recommended compiling flow is following:
`pdflatex <filename>.tex bibtex <filename> pdflatex <filename>.tex pdflatex <filename>.tex` (replace `bibtex` with `biber` according to the program you use)

That means:

1. Run `latex` to "scan" your document (especially the citing macros) and put things in order
2. Run `biber` (or `bibtex`) to update the bibliography, and define the content all the `\cite`-like macros (`\citep{bibtexkey}`, `\citet`...).
3. Re-run `latex` while expanding all citation macros, and memorize what is where (figures, chapters, sections, etc.). Since content might have been modified (expansion of citation macros), some elements might have moved to a new page and thus the ToC is not up-to-date anymore.
4. Final run of `latex`: since no content have been added since last compilation, it just updates the ToC, LoF, etc. (One compilation more might be necessary if, for example, the ToC expands from one to two pages.)

Note that you can skip steps 1 and 2 if you are not using any bibliographical references.