×
Klik hier om ShareLaTeX te gebruiken in het Engels

[edit] ShareLaTeX guides

[edit] LaTeX Basics

[edit] Mathematics

[edit] Figures and tables

[edit] References and Citations

[edit] Languages

[edit] Document structure

[edit] Formatting

[edit] Fonts

[edit] Presentations

[edit] Commands

[edit] Field specific

[edit] Class files

In a LaTeX document the table of contents can be automatically generated, and modified to fit a specific style, this article explain how

[edit] Introduction

To create the table of contents is straightforward, the command \tableofcontents does the job:

\documentclass{article}
\usepackage[utf8]{inputenc}
 
\title{Sections and Chapters}
\author{Gubert Farnsworth}
\date{ }
 
\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}

TableOfContentsEx1.png

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 example.

Note: For the table of contents to work properly you must compile the document twice or use latexmk -pdf

  Open an example in ShareLaTeX

[edit] Change the title of the table of contents

The default title for the table of contents is "Contents", this can be changed into whatever you need.

\documentclass{article}
\usepackage[utf8]{inputenc}
 
\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}

TableOfContentsEx2.png

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.

  Open an example in ShareLaTeX

[edit] Further reading

For more information see: