Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 18 down vote accepted

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.

share|improve this answer
    
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.

share|improve this answer
    
Oops, missed the use of \input in the question: thanks. –  Joseph Wright Aug 18 '10 at 19:46
    
Glad to help :). This site really rocks! –  Bran the Blessed Aug 18 '10 at 19:49
3  
And here is a page that explains the crucial difference between \include and \input: web.science.mq.edu.au/~rdale/resources/writingnotes/… . To summarise, each file that you \include will generate a separate *.aux file, and those *.aux files are always read. –  Jukka Suomela Aug 18 '10 at 20:01
    
See also tex.stackexchange.com/questions/246/… –  Joseph Wright Aug 18 '10 at 21:00
4  
@BrantheBlessed, the example has a broken link. –  LWZ Apr 24 '13 at 17:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.