> ## Documentation Index
> Fetch the complete documentation index at: https://resources.latex-cloud-studio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Table of Contents in LaTeX

> Build and customize a table of contents in LaTeX. Control depth, numbering, and links for long-form documents.

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

## Basic TOC

```latex basic-toc.tex theme={null}
\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}
```

<Info>
  Compile at least twice so LaTeX can resolve TOC entries and page numbers.
</Info>

## Control Depth

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

## Add Unnumbered Headings to TOC

```latex addcontentsline.tex theme={null}
\chapter*{Acknowledgments}
\addcontentsline{toc}{chapter}{Acknowledgments}
```

## Related Pages

* [Hyperlinks](/learn/latex/document-structure/hyperlinks)
* [Multi-file projects](/learn/latex/document-structure/multi-file-projects)
* [Managing large documents](/learn/latex/how-to/large-documents)
