[Tex/LaTex] Making a table of contents for a book

table of contents

I'd like to know how to create a table of contents in LaTeX. For example, if I were to write a book, I would want something like this

Contents

    Chapter 1
      1.1 Real Analysis .............. 1
      1.2 Role of LUB Axiom........... 3

How do I create this? I'd like to know.

Best Answer

A table of contents (ToC) is produced by inserting \tableofcontents at the appropriate place in your document.

\documentclass{book}

\begin{document}

\tableofcontents

\chapter{(Chapter Name)}

\section{Real Analysis}

\section{Role of LUB Axiom}

\end{document}

Note that you need at least two LaTeX runs to produce the ToC (LaTeX collects the data for the ToC in the first run and typesets it in the second run). If the ToC itself comprises several pages, a third LaTeX run may be necessary to get the ToC's page references right.