1

I have a document using the memoir class in which I have broken up the chapters using \include. Inside those chapters, I use the \chapter{...} command, which prints the chapter at the correct place.

When I use \tableofcontents, however, it doesn't include any of the included chapters. How can I get the chapters to show up in the table of contents?

Here is a MWE demonstrating the problem:

\documentclass{memoir}
\begin{document}

\tableofcontents

Here is some text before the include

\include{MWEchapter1}

Here is some text after the include

\end{document}

MWEchapter1.tex is as follows:

\chapter{MWE Chapter}

Here is some text in the MWE Chapter.

This produces the following: Table Of Contents, missing the chapter Chapter inclusion End Text

As you can see, the chapter is missing from the contents section, even though it has been included in the document.

I know, as a work-around, I can stick the \chapter commands outside the files, but that removes the reorganizational ability that I have right now with the \include

Also, this is similar to the question "\tableofcontents and multiple files from \include". Unfortunately, that solves the question specifically for revtext4.

  • Take a look at my answer here, which works for me and may solve your problem tex.stackexchange.com/questions/123058/… – Ethan Bolker Oct 15 '14 at 2:11
  • 1
    Welcome to TeX.SX!. When asking questions it is better to provide a full minimal working example (MWE) both in order to demonstrate what you are trying to do and to help others help you. The MWE should like like \documentclass...\begin{document}...\end{document}, it should compile and contain close to the minimal amount of code needed to explain/demonstrate what you are asking. This saves a lot of time for everyone. – Andrew Oct 15 '14 at 2:40
  • @andrew I will add a MWE when i get a chance. I posted this right before my time was needed elsewhere and I didn't want to make one and not have time to make sure it demonstrated what I needed. And thanks for the intro – Gilbrilthor Oct 15 '14 at 2:56
3

While creating my minimal working example, I realized my mistake. LaTeX displays the table of contents using the .toc file that is built on the first pass through the document. Therefore, the first pass will not include the chapters that were not processed from before.

To fix this issue, run the LaTeX command used to process the .tex file again. This will pick up the changes since the last run. For my MWE, it was the command pdflatex mweMain.tex.

I haven't worked with LaTeX in quite some time and had forgotten that documents with header material built from later in the document must be run multiple times.

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.