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 title says it all. Assume I use two \addtocontents in a document and I want to know whether or not their argument will be typeset in the same page of the ToC.

The simple idea of placing a \label and then using \pageref, as in





\addtocontents{toc}{\newpage b\label{b}}


fails and produces the expected warning:

LaTeX Warning: There were undefined references.
share|improve this question
It works (on the third LaTeX run) if you \protect the \label commands. – diabonas Apr 10 '12 at 18:33
up vote 6 down vote accepted

..... fragile command in a moving argument...

\addtocontents{toc}{\newpage b\protect\label{b}}
share|improve this answer
Now I feel really stupid! Thanks! – Gonzalo Medina Apr 10 '12 at 18:46

Your Answer


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.