[Tex/LaTex] Bibliography appears as an appendix in ToC in LyX

amsbookappendicesbibliographieslyxtable of contents

I want to place the Bibliography after the appendices. So in LyX I mark "Start Appendix Here", insert the appendices, and after that the Bibliography. Now, all appendices appear in the Table of Contents like "Appendix A. …", or "Appendix B. …". The problem is that the Bibliography also appears like "Appendix. Bibliography", which obviously isn't what I want. How do I fix this?

Instructions to reproduce issue:

  1. Create new Lyx document with Document Class: book (AMS).
  2. Add a TOC (Insert -> List / TOC -> Table of Contents).
  3. With the cursor placed after the Table of Contents, start the appendix (Document -> Start Appendix Here)
  4. Below the Appendix red line, insert a Bibliography (Insert -> List / TOC -> BibTeX Bibliography).
  5. Compile.
  6. Tell me what happens.

Best Answer

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.