Certainly a stupid question. I have a newcounter defined normaly, that is
\newcounter{sharc}
How can I call a specific value of this counter with a command like label/ref ?
Exemple
blabla `\thesharc` blala
blabla `\thesharc` blabla
blabla `\thesharc` blabla <- I want to refer to this value
blabla `\thesharc` blabla
Best Answer
What do you mean by "refer to a value"?
Do you wish to obtain only the plain counter value in arabic numerals even if the counter in question is subordinated to whatsoever other counters and thus
\the<counter>
is defined to prepend whatsoever prefix and apply whatsoever formatting when printing the value?What about automatic creation of hyperlinks in case of using the hyperref-package?
Be that as it may.
For obtaining only the plain value in arabic numerals of the last counter that was incremented via
\refstepcounter
, Heiko Oberdiek's zref package might be of interest.(Within almost all the sectioning commands of documentclasses for LaTeX,
\refstepcounter
is used for stepping counters. That's because\refstepcounter
is the macro which makes values of counters available to the\label
..\ref
-mechanism.)For obtaining the expansion of
\the<counter>
without hyperlinks in situations where the hyperref bundle/package is in use, Heiko Oberdiek's refcount package might be of interest.(The example below requires to be compiled at least twice/requires at least two LaTeX-runs between which auxiliary files are not deleted.)