\includeonly{filename1, filename2 ...}



When writing a large document, it is sometimes useful to work on selected sections of the document. In LaTeX, the command


will result in only the files specified between the brackets being compiled (note no spaces in the list and without file name extension '.tex'). It is paired with the \include command: the \includeonly command should only be placed in the preamble of the LaTeX file, whilst the \include commands should only be placed in the main body. If \includeonly is not specified in the preamble, LaTeX will assume that all \include commands should be evaluated.

The syntax for an \include command is pretty simple:


Notice that the following are not equivalent: \include{filename.tex} does nothing while \include{filename} works. Note, however, that \input{filename.tex} and \input{filename} are in fact equivalent - but as explained below \input is not what is needed here)

but note \include differs slightly from \input:

1. it may only be used after the \begin{document} command

2. it acts like \clearpage \input{} \clearpage

3. if filename does not exist, it will not cause a crash

4. a file added via \include may not contain another \include (i.e., \include is not recursive). However, \input commands are acceptable within included files.