There are two and a half solutions (only the second one is valid if you need to use \include
):
- Use
\input
instead of \include
(if you don't need the functionality of \include
).
- Put
\appendices
into appendixA.tex
.
Manually configure the TOC file from
\contentsline {chapter}{\numberline {1}First things}{1}
\contentsline {chapter}{\numberline {A}The initial stuff}{3}
\contentsline {section}{\numberline {A.1}A section within the initial appendix}{3}
\contentsline {chapter}{Appendices}{3}
\contentsline {chapter}{\numberline {B}Another addendum}{5}
to
\contentsline {chapter}{\numberline {1}First things}{1}
\contentsline {chapter}{Appendices}{3}
\contentsline {chapter}{\numberline {A}The initial stuff}{3}
\contentsline {section}{\numberline {A.1}A section within the initial appendix}{3}
\contentsline {chapter}{\numberline {B}Another addendum}{5}
The package manual states:
There is an unfortunate interaction between the LaTeX kernel commands \include
and \addcontentsline
. […]
Things work as expected if the \addcontentsline
command is placed
within the \included
file, or if the imported file is \input
ed instead of \includ
ed.
On another note: appencides
is an environment not a macro, so you better use \appendices … \endappendices
or \begin{appendices} … \end{appendices}
.
The following code will remove the phrase "Appendix. " in front of "Bibliography" in the table of contents when using the LaTeX amsbook
class or the LyX document class book (AMS)
.
\usepackage{xstring}
\renewcommand{\tocappendix}[3]{%
\indentlabel{\IfStrEq{#3}{Bibliography}{}{#1}\@ifnotempty{#2}{ #2.\quad}}#3}
For LyX, this code can be inserted into the LaTeX Preamble ("Document > Settings...").
Background:
For typesetting the table of contents, the ".toc" file is used (it can be found in the "tmpdir" / "tmpbuf" directory of LyX). It contains lines like
\contentsline {chapter}{\tocappendix {Appendix}{A}{My First Appendix}}{3}
\contentsline {chapter}{\tocappendix {Appendix}{}{Bibliography}}{3}{appendix*.1}
Furthermore, the class file amsbook.cls
defines
\newcommand{\tocappendix}[3]{%
\indentlabel{#1\@ifnotempty{#2}{ #2}.\quad}#3}
By redefining the command \tocappendix
we can omit the printing of the first argument (e.g., "Appendix") if the third argument is "Bibliography". For string comparison, the xstring
package is used. Furthermore, the bracket }
in front of .\quad
was moved behind \quad
.
Best Answer
I know this is a few months old, but i just ran into the same problem, and this is the leading thread on the problem as far as i can see.
The problem occurs when using
\include
after the\addappheadtotoc
command, and is actually described in the manual for the appendix package in section 2.1 known problems.A workaround is to have
\addappheadtotoc
in the beginning of the first included appendix. (or you can do as I, and include a seperate file containing only that command.)