[tex-live] Ignoring portion of LaTeX code; the \par problem.
Dan Luecking
luecking at uark.edu
Tue Apr 6 18:00:19 CEST 2010
On Sun Apr 4, 2010 at 19:37:00 CEST Michaël
Cadilhac <michael at cadilhac.name> wrote:
> My goal today is to write a command that would include another TeX
>file, but not its document environment. For instance, I would want to
>use it like:
>
>document.tex:
>\documentclass{article}
>% Lots of includes and configurations.
>\begin{document}
> Text.
>\end{document}
>
>appendix.tex:
>\usepreambleof{document.tex}
>\begin{document}
> Other text.
>\end{document}
>
> The goal there is to be able to move the appendix close to any
>document.tex, and the appendix would take the form of the document.
>
> My first tries were focused on just ignoring code. But while I had no
>succeed in defining \document=\iffalse and \enddocument=\fi, for
>whatever reason, I might have found some bugs on my way, seemingly
>linked to TeXlive.
One possibility:
% appendix.tex
\let\originaldocument\document
\let\document\endinput
\input document.tex
\let\document\originaldocument
\begin{document}
Other text.
\end{document}
Making \enddocument=\fi doesn't work because
after \iffalse, TeX never sees \enddocument, only
\end{document}, which it ignores as instructed by
\iffalse.
There are also commands that are not allowed to come
between \iffalse and \fi which can also lead to errors:
anything defined with the \outer prefix (\outer\def...).
It is standard that the token \par as well as blank lines
(which are automatically converted to the token \par) are
not allowed in the argument of a macro, unless it has been
defined with \long\def. Not a bug, but rather intentional
design.
Regards,
Dan
Daniel H. Luecking
Department of Mathematical Sciences
Fayetteville, Arkansas
http://www-cs-faculty.stanford.edu/~knuth/iaq.html
More information about the tex-live
mailing list