[texhax] TOC "Appendices" entry comes after 1st appendix entry when \include used

Barbara Beeton bnb at ams.org
Tue Sep 25 19:36:04 CEST 2012

On Mon, 24 Sep 2012, Murray Eisenberg wrote:

    I use the appendix package with its toc option for a book document. If the first of several appendices is inserted by using \include, then the "Appendices" heading in the TOC incorrectly appears after the entries for the first appendix.

the tex output routine is asynchronous, and
(at least for the basic \appendix command,
and some others), this command is held until
the next command is parsed, and in the case
of \include, processed.  hence whatever the
command that preceded the \include won't be
activated until the \include'd file has been
completed -- out of order!  (works exactly
in this way if you try to insert an
\addcontents line before an \include.)

the way i've handled situations like this
is to insert the \appendices (or \appendix)
command as the first line in the file to be
\include'd (but beware of the possibility
that the order of such files is changed).

i suppose that this could be managed in a
more "structural" manner by causing the
write of the appendix toc info into the .aux
file to be "immediate".  but i don't believe
that anyone has yet done so.

    This behavior does not occur if the body of the appendix is inserted directly in the main document.

    The behavior does not occur, either, if I use \input instead of \include. However, I really need to use \include.

either of these techniques causes the write
of the appendix toc info to be accomplished
before the appendix data proper is processed.


hope this is helpful.
						-- bb

More information about the texhax mailing list