1

When using the package appendix together with e.g. scrbook class \addappheadtotoc uses a chapter style Appendices entry in the toc and bookmarks.

How do I change this such that the Appendices entry is raised to part level in both, toc and bookmarks?

Here is a minimal working example:

\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[a4paper,11pt]{scrbook}

\usepackage[toc,title,page]{appendix}

\usepackage{bookmark,hyperref}

\begin{document}

\frontmatter% \tableofcontents%

\mainmatter% \part{p} \chapter{c} \section{s}

\part{p} \chapter{c} \section{s}

\appendices%

\chapter{c} \section{s}

\backmatter%

\end{document}

Bernard
  • 271,350
Stefan
  • 173

2 Answers2

2

With KOMA-Script class scrbook you do not need package appendix. You could use

\appendix
\addpart{\appendixname}

in the document.

Or you can define \appendixmore in the preamble:

\documentclass{scrbook}% paper=a4 and fontsize=11pt are default
\usepackage{bookmark,hyperref}

\newcommand*{\appendixmore}{\addpart{\appendixname}}% <- added

\begin{document} \frontmatter \tableofcontents

\mainmatter \part{p} \chapter{c} \section{s}

\part{p} \chapter{c} \section{s}

\appendix% <- changed

\chapter{c} \section{s} \end{document}

Or you can redefine \appendix:

\documentclass{scrbook}% paper=a4 and fontsize=11pt are default
\usepackage{bookmark,hyperref}

\newcommand{\originalappendix}{} \let\originalappendix\appendix \renewcommand{\appendix}{\originalappendix\addpart{\appendixname}}

\begin{document} \frontmatter \tableofcontents

\mainmatter \part{p} \chapter{c} \section{s}

\part{p} \chapter{c} \section{s}

\appendix% <- changed

\chapter{c} \section{s}

\end{document}

esdd
  • 85,675
  • This also works fine with \crefalias{section}{appendix} and so on. – Stefan Jan 08 '21 at 11:02
  • Since the originally accepted answer also works with \crefalias (as I messed something up in the first place) I reverted and accepted the other answer again. Simply because he was faster in the first place and I can only accept one answer. Thanks for providing a second possibility anyways. – Stefan Jan 09 '21 at 19:45
1

Try this revised version of your MWE.

% appintocprob.tex SE 577653
\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[a4paper,11pt]{scrbook}

\usepackage[toc,title,page]{appendix}

%\providecommand{\addappheadtotoc}{% no change \renewcommand{\addappheadtotoc}{% new simple version \phantomsection \addcontentsline{toc}{part}{\appendixtocname}% }

\usepackage{bookmark,hyperref}

\begin{document}

\frontmatter% \tableofcontents%

\mainmatter% \part{p} \chapter{c} \section{s}

\part{p} \chapter{c} \section{s}

\appendices%

\chapter{c} \section{s}

\backmatter%

\end{document}

Note the redefinition of \addappheadtotoc. It is a very simple redefinition whereby I have used part instead of chapter. The original definition of \addappheadttotoc is much more complex as it deals with a number of potential cases so this redefinition is really applicable only to your use.

Peter Wilson
  • 28,066
  • While this answer solves what I have asked for it doesn't reference the appendix correctly when using \cref, even though I considered the points made in this post. – Stefan Jan 08 '21 at 11:00
  • @Stefan Then please ask another question including an MWE that shows your use of \cref which does not appear in your above MWE. – Peter Wilson Jan 09 '21 at 18:17
  • @Stefan Someone reduced their acceptance of my answer. By any chance was it you? – Peter Wilson Jan 09 '21 at 19:24
  • It turns out that I messed up the first test I did. I now tried with a MWE and in the original document and it works fine also with your solution. Sorry for the confusion. – Stefan Jan 09 '21 at 19:42
  • Yes, I removed acceptance as I thought it does not work. I put it back again as it was originally. Sorry for the confusion on my end... – Stefan Jan 09 '21 at 19:43
  • @Stefan Thank you for explaining what has happened. All the best for 2021 – Peter Wilson Jan 10 '21 at 18:59