[texhax] optionally compiling parts of a document

Pierre MacKay pierre.mackay at comcast.net
Mon Dec 3 01:14:11 CET 2012


I do this all the time, and control it by whether there is a filename to 
be input.  If I don't want the input, I test for EOF and then close the 
input register.  If I do want it I close the input register and then 
reopen it.  Works every time, but, of course, it isn't LaTeX.  All that 
is needed is to include or exclude the input file from the source 
directory you are using.

\openin\announceread=rh-Sheridan
\ifeof\announceread
\closein\announceread
\GTskip{2}  % Skip the Sheridan lines and leave a space
\else
\closein\announceread
\input rh-Sheridan  % Read the input lines from rh-Sheridan.tex
\fi

  Note that \closein has to be used in each branch so that the read, if 
wanted, will start at the beginning of the file.  Is this allowed in 
LaTeX? I don't know, but it ought to be.

Pierre MacKay




More information about the texhax mailing list