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??
Asked
Active
Viewed 252 times
1 Answers
4
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:
- 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. - 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:
- Run
latexto "scan" your document (especially the citing macros) and put things in order - Run
biber(orbibtex) to update the bibliography, and define the content all the\cite-like macros (\citep{bibtexkey},\citet...). - Re-run
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.
ebosi
- 11,692
LaTeXlooks for figures and memorize their page number; and during the second, it updates the ToC and LoF.) – ebosi Oct 17 '16 at 08:11pdflatex FILENAME pdflatex FILENAME bibtex FILENAME pdflatex FILENAMEpdflatex FILENAMEDid 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