[Tex/LaTex] Keep chapter number of chapters inserted with \include

chaptersincludenumberingsectioning

Okay, I've puzzled over this for a while and I can't work it out.

I have a document with several chapters, using the memoir class. I've separated each chapter into separate files, and I'm including them using \input.

I did this because at times I may want to produce a file with just chapter 2, or just chapter 3 and not the others. But when I do this, the chapters get renumbered.

How can I make my file customizable, so if I want to, I can make a pdf with just Chapter 2, or just Chapter 3, and no 1?

Best Answer

You should use \include instead of \input, and then in the preamble say with \includeonly which of the included files you want in your pdf file, like this:

\documentclass{memoir}
\includeonly{chapter1,chapter3}
\begin{document}
\include{chapter1}
\include{chapter2}
\include{chapter3}
\end{document}

The first run(s) of pdflatex should be done without the \includeonly in order to get all the references right.

Related Question