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

Murray Eisenberg murrayeisenberg at gmail.com
Mon Sep 24 23:37:30 CEST 2012

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.

This happens no matter whether I use the \appendices command, as shown below, or else the appendices environment.
The same thing happens if I don't use the appendix package but instead just the \appendix command and use an\addcontentsline to insert the "Appendices" item in the TOC.

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.

Here's a minimal failing example. (The 2nd appendix is here just to highlight the effect in TOC. In the main file, I have a 2nd appendix right there, but it makes no difference if I put that in a separate file and use another \include for it.)

%%%%% main file %%%%
\documentclass{book}
\usepackage[toc]{appendix}

\begin{document}

\frontmatter
\tableofcontents

\mainmatter

\chapter{First things}
This comes first.

\appendices

\include{appendixA}

\end{document}

%%%% file appendixA follows… %%%%
\chapter{The initial stuff}

\section{A section within the initial appendix}
Yet more.
\endinput
%%% end file %%%

---
Murray Eisenberg                     murrayeisenberg at gmail.com
80 Fearing Street                      phone 413 549-1020 (H)
Amherst, MA 01002-1912

`