0

I have a document with apa6 class in which sections are the uppermost heading level. In Lyx I set "Start Appendix here" which sets \appendix in the sorce. Afterwards I define a section. In the rendered document (pdflatex) it reads Appendix A followed by the section name but there is no toc entry.

So my questions are: Am I missing something? In other posts I read that the toc entries should appear automatically.

I don't know, if it is possibly suppressed by the document class. Does anybody know, if this might be the case?

1 Answer 1

0

In class apa6 command \appendix redefines \section completly and this redefined \section does not provide an entry in ToC.

You could patch \appendix to patch the redefined \section:

\usepackage{xpatch}
\makeatletter
\xapptocmd\appendix
  {\xapptocmd\section
    {\addcontentsline{toc}{section}{\appendixname\ifoneappendix\else~\theappendix\fi\ #1}}
    {}{\InnerPatchFailed}%
  }
{}{\PatchFailed}

enter image description here

Code:

\documentclass{apa6}
\usepackage{blindtext}% only for dummy text in this example

\usepackage{xpatch}
\makeatletter
\xapptocmd\appendix
  {\xapptocmd\section
    {\addcontentsline{toc}{section}{\appendixname\ifoneappendix\else~\theappendix\fi\ #1}}
    {}{\InnerPatchFailed}%
  }
{}{\PatchFailed}

\begin{document}
\tableofcontents
\blinddocument

\appendix
\section{Section in Appendix}
\subsection{Subsection in Appendix}
\Blindtext
\blinddocument
\end{document}
1
  • Thank you. I would never have found that solution on my own.
    – user121855
    Aug 8, 2017 at 21:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .