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
\documentclass{article}
\begin{document}
\pageref{a}\pageref{b}
\tableofcontents
\addtocontents{toc}{a\label{a}}
\addtocontents{toc}{\newpage b\label{b}}
\end{document}
fails and produces the expected warning:
LaTeX Warning: There were undefined references.
\protectthe\labelcommands. – diabonas Apr 10 '12 at 18:33