Fix: Table of Contents Not Updating in LaTeX
Your LaTeX table of contents shows old section names, wrong page numbers, or is missing new sections entirely. This is one of the most common 'bugs' that isn't really a bug — it's how LaTeX works. The table of contents is built from the previous compilation's data, so it's always one compile behind. Bibby AI handles multi-pass compilation automatically, so your TOC is always up to date without manual intervention.
Understanding Why the TOC Is Outdated
LaTeX writes TOC data during compilation and reads it on the NEXT compile. This means you always need at least two passes:
% How LaTeX builds the table of contents:
%
% Pass 1: LaTeX encounters \tableofcontents
% -> Reads main.toc from PREVIOUS compile
% -> Encounters \section, \subsection, etc.
% -> Writes NEW .toc file with current data
%
% Pass 2: LaTeX encounters \tableofcontents
% -> Reads the UPDATED main.toc
% -> TOC is now correct!
% Minimal example:
\documentclass{article}
\begin{document}
\tableofcontents
\section{Introduction}
\label{sec:intro}
Some text here.
\section{Methods} % <-- just added this
\label{sec:methods}
New section content.
\end{document}
% After adding "Methods", you MUST compile TWICE
% for it to appear in the TOC.Forcing a Complete TOC Refresh
If your TOC is stuck or corrupted, delete auxiliary files and recompile from scratch:
% Method 1: Delete .toc and .aux files, then recompile
% In terminal:
% rm main.toc main.aux
% pdflatex main.tex
% pdflatex main.tex
% Method 2: Use latexmk (handles all passes automatically)
% latexmk -pdf main.tex
% Common TOC issues and fixes:
% Issue: Unnumbered sections not in TOC
% \section*{} does NOT appear in TOC by default.
% To add it manually:
\section*{Acknowledgments}
\addcontentsline{toc}{section}{Acknowledgments}
% Issue: TOC depth too shallow
% By default, only sections and subsections show.
% To include subsubsections:
\setcounter{tocdepth}{3}
% Issue: Want to exclude a section from TOC
% Some document classes support:
\section*{Appendix Notes} % unnumbered = no TOCCustomizing the Table of Contents
Fine-tune your TOC appearance with these common customizations:
% Use the tocloft package for TOC customization:
\usepackage{tocloft}
% Change the TOC title:
\renewcommand{\contentsname}{Table of Contents}
% Adjust spacing between entries:
\setlength{\cftbeforesecskip}{6pt}
% Add dots between title and page number:
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
% Custom formatting for section entries:
\renewcommand{\cftsecfont}{\bfseries}
\renewcommand{\cftsecpagefont}{\bfseries}
% Example with hyperlinked TOC entries:
\usepackage{hyperref}
\hypersetup{
colorlinks = true,
linkcolor = blue,
urlcolor = blue,
citecolor = blue
}
% Now TOC entries are clickable links to sections💡 Tips
- •The golden rule: always compile twice after structural changes (adding/removing/renaming sections).
- •Bibby AI handles multi-pass compilation automatically, so your TOC is always current without manual double-compiling.
- •Use latexmk instead of raw pdflatex — it automatically determines how many passes are needed.
- •If your TOC page numbers are off by one or two, a third compilation pass usually fixes it.
Try This in Bibby AI
Write LaTeX faster with AI auto-complete and instant compilation.
Start Writing Free