TeX/includeonly

From Wikibooks, open books for an open world
< TeX
Jump to: navigation, search

< TeX

Synopsis[edit]

\includeonly{filename1.tex, filename2.tex, ...}

Description[edit]

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

\includeonly{filename1.tex,filename2.tex,...}

will result in only the files specified between the brackets being compiled (note no spaces in the list). 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:

\include{filename.tex}
\include{filename}

(the two are equivalent)

(A remark by a random user: At least with Kile-TeXLive-Ubuntu, I found they 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.

http://www-hermes.desy.de/latex/ltx-165.html

Examples[edit]