5

I am new to this community and the LaTeX environment.

I am learning the markup language and the use of the programmes.

In one of my first tests I got a trouble. The pdflatex compiler made not a problem but if I view my .pdf document, I don't have a Table Of Contents.

See below for a piece of my source code.

Does anyone know the solution for this?

Source Code of the beginning of my (Dutch) book:

\documentclass[a4paper,12pt]{book} %Zet documentklasse    
%Nu kies ik de te laden pakketten  
\usepackage{fancyhdr} 
\usepackage[dutch]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%\usepackage{graphicx}
%Hieronder komt de hoofd- & voettekst
\pagestyle{fancy}%Selecteer de paginastijl
\fancyhf{}%Maak de kop- en voetteksten leeg
\fancyhead[RO,LE]{\thepage}%Zet als koptekst de paginanummers

%Hieronder komt de info over het boek 
\title{Debian met Orca; alleen als je blind bent}
\author{Jordy Deweer}
\date{Maart 2016}

\begin{document}
\pagenumbering{gobble} 
\maketitle
Copyright (C)2016 Alle rechten voorbehouden.

\pagenumbering{arabic}
\tableofcontents

\section{Inleiding}
  • 2
    Welcome, try again. Does it work now? – Johannes_B Mar 27 '16 at 15:40
  • 3
    There's a \end{document} missing at the -- well -- end of the document ;-). And as Johannes said: Compile twice. The ToC and other stuff need at least two runs to be updated. After the first run, it's empty – user31729 Mar 27 '16 at 15:40
  • 1
    There's \textcopyright to display the Copyright symbol, by the way – user31729 Mar 27 '16 at 15:49
  • Thanks to all! I know that there wasn't added a \end{document}-command, but this wasn't the full document. This was only the most interesting piece! I have a lot more code and text in the book. – Jordy Deweer Mar 28 '16 at 8:38
7

One of many things one has to learn about LaTeX is that certain operations -- such as the creation of the table of contents and cross-referencing call-outs -- take more than one compilation round to complete fully. This is because LaTeX assembles the components of certain typographic objects -- such as the table of contents -- in stages, writing intermediate results to the files \jobname.aux and \jobname.toc (and, depending on the complexity, still more auxiliary files) at the end of each compilation run, and then reading those intermediate results back into memory at the start of the next compilation run. (The reasons for this asynchronous behavior are explicable nowadays mostly by referring to the sheer longevity of TeX, LaTeX, and friends. When TeX and LaTeX were first created, CPUs were still quite slow, RAM very expensive (and hence scarce), and operating systems generally not smart enough to allow all required computations to be performed in a single compilation round.)

The upshot? Whenever one adds or deletes structural elements -- such as \chapter and \section directives -- to a document, one must recompile the document twice to make sure that the structural changes are fully incorporated in the table of contents.

If having to remember to compile twice is a significant burden, do look into using front-end software that automatically performs as many rounds of compilation as are need to fully update the table of contents, the cross-references, the bibliography and all citation call-outs, etc. Unless your document is extremely long and/or your computer is very slow, each compilation run should take up very little noticeable time. Put differently, there's usually not much of a downside these days to running two compilation rounds each and every time.

If you compile the code shown below twice, you'll get the following look for the Table of Contents page:

enter image description here

\documentclass[a4paper,12pt]{book} 

%Nu kies ik de te laden pakketten
\usepackage{fancyhdr}
\usepackage[dutch]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%\usepackage{graphicx}

%Hieronder komt de hoofd- & voettekst
\pagestyle{fancy}%Selecteer de paginastijl
\fancyhf{}%Maak de kop- en voetteksten leeg
\fancyhead[RO,LE]{\thepage}%Zet als koptekst de paginanummers

%Hieronder komt de info over het boek
\title{Debian met Orca; alleen als je blind bent}
\author{Jordy Deweer}
\date{Maart 2016}

\begin{document}
\frontmatter
\pagenumbering{roman}
\maketitle
\thispagestyle{empty}
Copyright \textcopyright\ 2016 Alle rechten voorbehouden.

\tableofcontents

\mainmatter % automatic page break
\chapter{Introduction} % just for this example
\section{Inleiding}
\end{document}
  • Thanks to all! I know that there wasn't a \end{document}-command, but this was very normal. It isn't my full document, but just a little piece of it! I used a \newpage -command to add a new page after the Table of Contents. Is that a good choice? – Jordy Deweer Mar 28 '16 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.