TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 15 down vote accepted

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}}{}}
share|improve this answer
    
Perfect. Thanks. – lpdbw Jul 28 '12 at 14:55
    
For reference I add the following link: tex.ac.uk/cgi-bin/texfaq2html?label=protect – lpdbw Jul 28 '12 at 15:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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