Frequently Asked Question List for TeX

# Using labels as counter values

Labels are tempting sources of “numbers” — their most common use, after all, is simply to typeset a number. However, their seeming simplicity is deceptive; the packages babel and hyperref, at least, fiddle with the definition of \ref and \pageref in ways that make

\setcounter{foo}{\ref{bar}}

(etc.) not work; thus the technique may not be relied upon.

The solution is to use the refcount package (incidentally, by the author of hyperref). The package provides four commands, all similar to:

\usepackage{refcount}
...
\label{bar}
...
\setcounterref{foo}{bar}