Skip to main content
Create a table of contents (TOC) that stays in sync as your document grows.

Basic TOC

basic-toc.tex
\documentclass{report}
\usepackage[colorlinks=true,linkcolor=blue]{hyperref}

\begin{document}
\tableofcontents

\chapter{Introduction}
\section{Background}
\subsection{Scope}

\chapter{Methods}
\section{Dataset}
\section{Evaluation}
\end{document}
Compile at least twice so LaTeX can resolve TOC entries and page numbers.

Control Depth

toc-depth.tex
\setcounter{tocdepth}{2}    % 0=chapter, 1=section, 2=subsection
\setcounter{secnumdepth}{3} % controls numbering depth

Add Unnumbered Headings to TOC

addcontentsline.tex
\chapter*{Acknowledgments}
\addcontentsline{toc}{chapter}{Acknowledgments}