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}
Werner
  • 603,163
  • 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

1 Answers1

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

Werner
  • 603,163