I have this counter which I have defined using \newcounter{myCounter}.

Printing the value of myCounter can be easily done via \arabic{myCounter}. How can I print the value of (myCounter - 2)?


Either use the \label-\ref system if you're stepping myCounter via \refstepcounter system, or manually calculate it via \numexpr:

enter image description here



\verb|\themyCounter:     | \themyCounter

\verb|\arabic{myCounter}:| \arabic{myCounter}


\verb|\themyCounter:     | \themyCounter

\verb|\themyCounter:     | \themyCounter


\verb|\ref{myLabel}:     | \ref{myLabel}

\verb|Calculation:       | \number\numexpr\value{myCounter}-2\relax


\the<counter> is usually used to represent the value of <counter>, and is defined as \arabic{<counter>} by default. As reference, see The \the command.

More options exist (with LaTeX's fp and LaTeX3's l3fp) if you want to perform more intricate calculations.

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