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??
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
Indeed, these commands (
\listoffigures respectively) basically works as following:
- During the first run of compilation (via the bash command
lualatex <yourDocumentName>.tex, etc. you type in your terminal), the macro
\tableofcontents"scans" the entire document, and memorize where is each figure/section.
- 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
biber according to the program you use)
latexto "scan" your document (especially the citing macros) and put things in order
bibtex) to update the bibliography, and define the content all the
\cite-like macros (
latexwhile 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.
- 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.