I am writing a long document with many chapters. They are all included from a root document using \input{chapterX.tex} etc. Compiling everything takes pretty long.

As a workaround to make compilation faster, I typically comment out most \input commands and include only the chapter I'm currently working on. But that's a bad method because then the references to chapters that are not currently included won't work, and the table of contents is almost empty.

I'm wondering if there is a method that does precompilation? Ideally, it would detect that, while I am working on chapter1.tex, nothing in chapter2.tex etc. has changed, and reuse the results from previous compilation runs.

Is that possible? It would be like separate compilation units in languages like C.

  • 1
    For others finding this in the future, consider using the package newclude if you want to use \include and \includeonly, as two answers suggested. Standard \include is very finicky about component source file locations; newclude redefines it to avoid path problems, and provides other potentially useful benefits. – Mars May 21 '19 at 18:00

You can't precompile chapters, but you can use the \includeonly mechanism to ensure that your cross-references and page numbers stay correct while choosing to only include parts of your source.

  • Great, that's pretty much what I wanted. Thanks! – Frank Aug 18 '10 at 19:49

Extending Joseph's answer a bit: This mean that you use \include and not \input for including the desired chapters. See here for example usage.


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.