Consider this code:


When I compile I get the following error:

! Missing number, treated as zero.
<to be read again> 
l.8 \addtocounter{counterB}{counterA}

How to add the value in counterA to counterB?

  • 4
    – moewe
    Apr 5 '19 at 15:37
  • 3
    In case that this is related to your page counter problem: due to the asynchronic page building of tex, the page counter is often not reliable in the text body. Apr 5 '19 at 15:39
  • 1
    In case Ulrike's hunch is right, you may be interested in texfaq.org/FAQ-wrongpn
    – moewe
    Apr 5 '19 at 15:41

You can access the value of a counter for arithmetic or other situations where LaTeX expects a number with \value{<countername>}, so


should be what you are looking for.

You would use \the<countername> to print (a representation of) the value.




in the example.

In rare situations or when you define \the<countername> you may have to use


to force a particular printed representation.

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.