1

So I am trying to automate a counter using new counter and \refstepcounter. However I would like to print the number of the counter and the code below does not seem to word. Any idea why?

\newcounter{taskcounter}
\stepcounter{taskcounter}
\refstepcounter{taskcounter}
1
  • 3
    These only manipulate a counter macro. You'll need \thetaskcounter to print it. Note that stepcounter and refstepcounter both step up the value by one. The ref version just adds extra code such that \label can pick up the value.
    – daleif
    May 22 '18 at 19:26
2

In order to display the value of a counter <X> within your document, use \the<X>. For you specific example,

\thetaskcounter

This defaults to \arabic{<x>}, but can be changed.

\refstepcounter has nothing to do with the representation of the counter; it steps the counter (like \stepcounter) but also updates the components needed for referencing (via \label-\ref).

Related reference: The \the command

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.