Table of contents
In a LaTeX document the table of contents can be automatically generated, and modified to fit a specific style, this article explain how
Introduction
To create the table of contents is straightforward, the command \tableofcontents
does the job. Sections, subsections and chapters are included in the table of contents. To manually add entries, for example when you want an unnumbered section, use the command \addcontentsline
as shown in the following example:
\documentclass{article}
\usepackage{blindtext}
\usepackage{titlesec}
\title{Sections and Chapters}
\author{Gubert Farnsworth}
\date{ }
\begin{document}
\maketitle
\tableofcontents
\section{Introduction}
This is the first section.
\blindtext
\addcontentsline{toc}{section}{Unnumbered Section}
\section*{Unnumbered Section}
\blindtext
\section{Second Section}
\blindtext
\end{document}
This example produces the following output:
Change the title of the table of contents
The default title for the table of contents is Contents; it can be changed into whatever you need as the following example demonstrates:
\documentclass{article}
\title{Sections and Chapters}
\author{Gubert Farnsworth}
\date{ }
\renewcommand*\contentsname{Summary}
\begin{document}
\maketitle
\tableofcontents
\section{Introduction}
This is the first section.
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Etiam lobortisfacilisis sem. Nullam nec mi et
neque pharetra sollicitudin. Praesent imperdietmi nec ante.
Donec ullamcorper, felis non sodales...
\addcontentsline{toc}{section}{Unnumbered Section}
\section*{Unnumbered Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem. Nullam nec mi et neque pharetra
sollicitudin. Praesent imperdiet mi necante...
\section{Second Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem. Nullam nec mi et neque pharetra
sollicitudin. Praesent imperdiet mi necante...
\end{document}
This example produces the following output:
The line \renewcommand*\contentsname{Summary}
will write "Summary" instead of the default value. If you are using the package babel for international language support, the aforementioned command must be placed inside the braces of
\addto\captionsenglish{ }
Instead of English in \captionenglish
write the name of the language you set in babel.
Further reading
For more information see:
- Creating a document in LaTeX
- Bold, italics and underlining
- International language support
- Cross referencing sections and equations
- Indices
- Glossaries
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
- Page numbering
- Single sided and double sided documents
- Multiple columns
- Counters
- Font sizes, families, and styles