# [texhax] optionally compiling parts of a document

Neal H. Walfield neal at walfield.org
Sun Dec 2 23:16:20 CET 2012

```Hi, Uwe,

At Sun, 2 Dec 2012 22:49:24 +0100,
Uwe Lück wrote:
> It seems to me that you are confusing \include with \input,
> trying to issue \include conditionally. Instead, you still must issue
> \include for /each/ "segment" (chapter). What to "actually include"
> is controlled by \includeonly. So your "segment" macro only should
> determine the file name. Separately from that, you must transform
> \segmentsToInclude into the proper input for the \includeonly macro,
> which must happen in the document preamble already.

The reason that I use \include is that I want to use the .aux files of
the not included files.  So, you are right: I need to unconditionally
use \include and use \includeonly to control what gets included.

Unfortunately, \includeonly needs to be issued before the files are
\included.  Right now, I only know the names when the segments are
encountered.  I need to rethink my approach.  Perhaps I should just
steal the .aux inclusion machinery.

FWIW, replacing the use of \include with \inputdoesn't help.  I still
get an infinite recursion.