9

I'm writing my thesis using memoir.cls, with a top-level document for preamble and front matter and the like, and a source file per chapter, organised like this:

\documentclass{memoir}

\begin{document}
  \include{intro}
  \include{a}
  \include{b}
  \include{conclusion}
\end{document}

To compile only the part of the document I'm working on at the moment, I use \includeonly, as you'd expect. Now, if I \includeonly{a} or \includeonly{conclusion} I get the output I expect, but if it's intro or b that's \includeonly-ed, the chapter opens on the left-hand side rather than the right-hand side as it should. There seems to be a stray \newpage getting inserted somehow.

Does anyone know what's causing this?

  • 2
    Perhaps you should try \usepackage{newclude}. This prevents additional pagebreaks from the \include command. – user31729 Feb 25 '14 at 15:21
  • Edit: Does this happen with memoir class only? – user31729 Feb 25 '14 at 15:28
  • what exactly are in those included files? – daleif Feb 25 '14 at 15:50
  • 1
    I can see why this is annoying - but does the improper pagination really matter when you're working on a chapter at a time rather than the whole document? – Ethan Bolker Feb 25 '14 at 15:54
  • 1
    It is not only memoir that does this, book does the same – daleif Feb 25 '14 at 15:56
9
\documentclass{memoir}
%\includeonly{a}
\begin{document}

  \include{intro}
  \include{a}
  \include{b}
  \include{conclusion}
\end{document}

intro.tex

\chapter{intro}
intro

a.tex

\chapter{aa}
aa

b.tex

\chapter{bb}
bb

conclusion.tex

\chapter{conc}
conc

If you process the full document then uncomment the \includeonly you get just chapter 2 from a.tex.

First LaTeX checks the recorded data for the skipped chapter 1 and it ends on page 1 so the page counter is set to 1, then the included a.tex is input, the \chapter is seen which does \cleardoublepage so a blank page is thrown to skip page 2 and then the chapter heading starts on page 3. this is a right hand page it has an odd page number and the odd page header footer and margins as set in the class. It is the second page in the stack as the first page output is page 2 (as you have specified to omit page 1) so if printing on paper rather than viewing on screen you need to take care of your printer settings.

This means that if you want \includeonly to work consistently you need to make sure that every chapter ends on an even page, so that the chapter head of the following chapter never needs to throw a blank page. If you add \cleardoublepage to the end of each file then the blank page will be recorded as part of the previous chapter so when you \includeonly{a} then page 3 will be the first page printed, so the parity is kept.

  • updated with coding scheme that keeps the parity of pages. – David Carlisle Feb 25 '14 at 17:37
  • @ebo normally \cleardoublepage is not needed as the included files start with a command such as \chapter which automatically force the correct page parity. – David Carlisle Jun 24 '16 at 14:37
  • Is there any way to automate the insertion of \cleardoublepage at the end of each chapter file? – jpmath Jan 18 '17 at 13:02
  • Thank you very much! Unfortunately, that did not work for me (maybe the \cleardoublepage must be really inside the chapter file to be considered properly?) – jpmath Jan 18 '17 at 13:42
  • @jpmath oh yes that's exactly what I said in my answer:-) I'll delete the comment. – David Carlisle Jan 18 '17 at 13:51

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.