0

I want to add a prefix to subsections, that went well. After looking in this thread:

Add chapter/appendix prefix in table of contents of scrbook with correct appendix running head

it was almost ok. I adapted the code and the result is fine, but compiling gives me an error. This is my MWE:

\documentclass{exam}    
\renewcommand{\thesubsection}{Huistaak~\arabic{subsection}:}
\renewcommand{\contentsname}{Overzicht huistaken}
\usepackage{tocstyle}
\renewcommand*{\addsubsectiontocentry}[2]{%
\addtocentrydefault{subsection}{\subsectapp\nobreakspace #1}{#2}%
}

\begin{document}
\tableofcontents
\section{The weather is beautifull}
\subsection{I'm happy}
\subsection{You are happy}
\subsection{We are all happy}
\end{document}

The error I get is: \addsubsectiontocentry undefined

So I think I didn't do it correctly. (In fact I don't really understand the line:

\renewcommand*{\addsubsectiontocentry}[2]{%
\addtocentrydefault{subsection}{\subsectapp\nobreakspace #1}{#2}%
}

enter image description here

  • 1
    you are trying to redefine a command, which requires that the command has been created earlier, but the command hasn't. The command exists in a different documentclass than what you are using. In the original answer, you will see that they have used scrbook as the documentclass, where that command is being used. – Runar Sep 11 '16 at 12:01
  • 1
    If you are content with the output, you can just remove the lines regarding \renewcommand*{\addsubsectiontocentry}[2]{%…, and it will not throw you an error. Please revise your question if this is not the desired output. – Runar Sep 11 '16 at 12:04

0 Answers0