[Tex/LaTex] Add Appendix with correct page to ToC

appendicespage-breakingpage-numberingtable of contents

I am failing to add a heading for the appendix to the ToC with the correct page number:

\documentclass{scrbook}
\begin{document}
\tableofcontents
\chapter{test}
\appendix
\addcontentsline{toc}{part}{\appendixname}
\chapter{First Appendix}
\end{document}

enter image description here

I also tried to use the \addappheadtotoc command from the appendix package, but that changes nothing (expect that it writes 'Appendices' instead).

I assume that the appendix package provides the solution, but I could not figure out how to use it.

Best Answer

\appendix only changes the chapter numbering to Alph; it doesn't add a page break. Solution: Add \cleardoublepage before \appendix. (This is appropriate for a document using the openright class option; for openany, use \clearpage.)

EDIT: Personally, I wouldn't add a "pseudo chapter" to the ToC that doesn't correspond to an existing chapter (there is no chapter called "Appendix" in your example). Consider to add an unnumbered "Appendix" part to the main text and the ToC instead.

\documentclass{scrbook}
\begin{document}
\tableofcontents
\chapter{test}
\cleardoublepage
\appendix
\addcontentsline{toc}{part}{\appendixname}
\chapter{First Appendix}
\end{document}

enter image description here