It seems that there are different ways of accessing counters. I have been using \theMyCount as in this post about Using counters or macros, but noticed that the arrayjobx package uses \the\value{MyCount}.

This post about LaTeX programming comparison operators uses just \value{MyCount} but that does not seem to compile for me.

Are there any differences between these different methods of accessing counters?




MyCount = \theMyCount

MyCount = \the\value{MyCount}

%MyCount = \value{MyCount}% Does not compile for me.

\the\value{MyCounter} is just a slightly faster way to say \arabic{MyCounter}, as the former expands successively to

\the\csname c@MyCounter\endcsname

and the latter to

\expandafter\@arabic\csname c@MyCounter\endcsname

TeX rules say that \the is essentially equivalent to \number. I don't think that the difference in execution time can be significant in a normal document. It's usually better to stick to "official" macros, when they exist, in order to be sure that the result will be stable over time.

Usage of \theMyCount may be improper when we are not sure what kind of representation is associated to the counter MyCount.

On the other hand, \theMyCount should not be used in contexts when we are interested in the "abstract" value stored in the counter, so putting in a macro


is correct, while


is dangerous, because the user might have changed the representation of MyCounter when the macro is used.


You should use \theMyCounter if you want to output the value in Arabic numerals, Roman numerals, symbols or other format. You can restyle \theMyCounter by

\renewcommand\theMyCounter{\roman{MyCounter}} % lowercase Roman numerals

You should use \value{MyCounter} if it is used in an expression. For example

\ifnum\value{MyCounter}>5 ... \else ...\fi
\ifthenelse{\value{MyCounter}<4}{...}{...} % ifthen package

You can use \the\value{MyCounter} the same as \arabic{MyCounter}. But it is a mixed syntax. You'd better always use \arabic{MyCounter} in LaTeX; and if you want to pry, it is the same as \the\c@MyCounter.

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.