Time for action – adding a table of contents

We shall create a table of contents based on our numbered headings.

  1. Let's remove the options landscape and twocolumn. We also don't load the setspace package. Add the command \tableofcontents right after \begin{document}. Our code shall now be:
    \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} ...

Get LaTeX Beginners Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.