[Tex/LaTex] How to use \include with \tableofcontents in memoir class

chaptersincludememoirpdftextable of contents

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:



Here is some text before the include


Here is some text after the include


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.

Best Answer

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.