# [texhax] the command \includeonly{} in LaTeX

David Romano romanod at math.grinnell.edu
Thu Feb 1 22:32:38 CET 2007

Thank you Phil - I see; I had thought \includeonly allowed one to process
selected files that are included in the body of the main file so that
they have the correct cross-references.  For example, I'd like to
able to print a section of a book so that it has the right
cross-references, but without having to process the entire book.  Is
there a straightforward way to do this?

By accident, I just found that if I 1) put all the files in the
\includeonly and put all the corresponding \inlcude commands in the body
of the main file, 2) process the main file, then 3) remove all the
\include commands but one, and 4) reprocess the main file, then apparently
the .aux file from the first processing informs the output of the second
processing and I get what I'd like.  (But this seems like a work-around.)

Thanks again,
David Romano

On Thu, 1 Feb 2007, Philip G. Ratcliffe wrote:

>> When I try to use the
>> \includeonly and \include commands in a root file, I get a
>> "There were
>> undefinded references" message despite having the file which
>> contains the
>> \label command among the files used in the \includeonly
>> command.
>> [snip]
>> ------file label.tex
>> \begin{enumerate}
>> \item
>> Labeled text.
>> \label{test}
>> \end{enumerate}
>> --------------------
>> ------file reference.tex
>> Where is \ref{test}?
>> --------------------
>> ------file main.tex
>> \documentclass[11pt]{article}
>> \includeonly{
>> label,
>> reference
>> }
>> \begin{document}
>> \include{reference}
>> \end{document}
>> --------------------
>
> It's the file label.tex that hasn't been input or included that's the
> problem.  You need an \include{label} in your main  file.
>
> Note that \includeonly only tells LaTeX which of the ALREADY \include'd
> files to really include. It unfortunately does NOT complain if a file is
> missing.
>
> Cheers,  Phil Ratcliffe
>
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/