[Tex/LaTex] appendix missing in toc

apa6appendicestable of contents

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?

Best Answer

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}