Creating a table of contents
A book commonly begins with a table of contents, so let's create one based on our numbered headings:
- In our previous document, let's remove the options
landscape
andtwocolumn
. - Remove the
setspace
package, that is, delete this line:\usepackage[onehalfspacing]{setspace}
- Add the command
\tableofcontents
right after\begin{document}
.Our code shall now look like this:
\documentclass[a4paper,12pt]{book} \usepackage[english]{babel} \usepackage{blindtext} \usepackage[a4paper, inner=1.5cm, outer=3cm, top=2cm, bottom=3cm, bindingoffset=1cm]{geometry} \begin{document} \tableofcontents \chapter{Exploring the page layout} In this chapter we will study the layout of pages. \section{Some filler text} \blindtext \section{A lot more filler text} More dummy text will follow. \subsection{Plenty of filler text} \blindtext[10] \end{document}
- Compile the code twice. Afterward, the first page of your output will contain this table:
...