4

Context: When I write a large document, I write each chapter in a different file. All these subfiles are then included (using \include{<subfile name>}) in a main file to constitute my document.

When I work on a specific chapter, I use the \includeonly command to only compile this specific chapter (and thus speed-up the compilation).

\documentclass{scrbook}
    \includeonly{%here, chap2 only will be compiled
%       chap1,
        chap2,
%       chap3
    }
\begin{document}
    \include{chap1}
    \include{chap2}
    \include{chap3}
\end{document}

Problem: As made obvious by its name, the \includeonly command only includes listed subfiles in the compiled document. This makes that in my case, the document produced contains only one chapter.

However, I'd like to have all chapters included in the document produced.

Question: How to make LaTeX update only one chapter (shorter compiling time) while still producing a .pdf that contains every chapter (full document)?


Note: I want the "\updateonly" command to be versatile, i.e. to easily change the chapter(s) to be updated (or even recompile everything). I would also like to keep auxiliary data untouched (macro definition, cited references, hyperlinks [those from not updated chapters pointing on elements of the updated chapter might obviously be broken, though], acronyms, etc.)

  • 3
    there is no standard way to do this. – David Carlisle Jun 19 '17 at 19:45
  • You can have a separate document for each chapter and combine them into one document using pdfpages. – Michael Fraiman Jun 19 '17 at 20:22
  • @MichaelFraiman Thank you. I imagined this solution - however, I don't find it "versatile" enough as is. I'm also not quite sure how I could generate one ToC and one Bibliography based on multiple separate documents... – ebosi Jun 19 '17 at 20:47
  • @ebo do you need bibliography and toc mid-production? – Michael Fraiman Jun 19 '17 at 21:23
  • 1
    ther was a long and somewhat fractious series of questions earlier in the year with someone asking questions while trying to implement a system like this, but all the questions were doomed to have unsatisfactory answers as the facility isn't really implementable. I'll see if I can find the link... – David Carlisle Jun 19 '17 at 22:11
2

Just think that adding a page in a chapter changes all page numbers... adding a figure may change table of figures and extend it to a new page... a citation may change the order of all citations... So, you can not do what you ask for. LaTeX supposed to be clever typesetting system because it uses every letter to decide what to do with rhe whole document.

  • I am aware that not updating some chapters of my document would mean these chapter (namely page numbers, hyperlinks, toc, etc.) not up-to-date anymore. I also know that updating these information basically means recompiling those chapters (what I'd like to avoid). I'm thus rather focusing on including the content of these chapters in the produced document. That is, trading a large (and potentially frequent) compilation time against a bit of not up-to-date minor information. (Note that each chapter starts on a new (right) page, what would things a bit easier.) – ebosi Jun 19 '17 at 20:53
  • This is not completely true: \include can help. But when page numbers change, the document has to be fully typeset. – egreg Jun 19 '17 at 21:04
  • Yes... it starts in a new page... but it could need a new empy page before and different numbers for every page... LaTeX can not know that you don't care about the wrong numbers... the extra pages etc... It has to give an updated document using the changes it sees ... I can understand your point... but this is something that not needed to almost anybody (than you)... everybody can work with the only updated chapter or with the whole book... The functionality you ask for is too complicated for what offers... May be a script could do that... but not LaTeX... LaTeX has to be more "correct" – koleygr Jun 19 '17 at 21:06
  • Just think that the numbers of the equations could be all defferent... etc... LaTeX has to do a serious job... and can not decide that you don't need serious job for the moment... – koleygr Jun 19 '17 at 21:08
  • I thought that the answer "Your request can not be done" was an acceptable answer in this question... This is why I gave it as an answer... If someone ask "How can LaTeX ignore all my mistakes and typos and provide a perfect pdf?" an acceptable answer is "This can not be done!"... But I will avoid giving such answers in the future... Sorry – koleygr Jun 19 '17 at 21:29

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.