14

The following code produces an error. If the mathtools package is removed, it works. Why?


\documentclass{report}

\usepackage{mathtools}
\usepackage{etoolbox}

\newbool{shorttoc}

\makeatletter
\patchcmd{\@startshorttoc}{\bgroup}{\bgroup\booltrue{shorttoc}}{}{}
\makeatother

\begin{document}

\tableofcontents

\addtocontents{toc}{\protect\ifbool{shorttoc}{\setcounter{tocdepth}{0}}{}}

\chapter{Test Appendix}

\end{document}

This question is related to an earlier question of mine.

1 Answer 1

18

mathtools loads the calc package, which change the \setcounter command. You now have to protect it too:

\addtocontents{toc}{\protect\ifbool{shorttoc}{\protect\setcounter{tocdepth}{0}}{}}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.