# Why is not there any \refcounter command in LaTeX?

We have the \stepcounter command in LaTeX where \stepcounter{counter} adds one to the counter and resets all subsidiary counters.

We also have the \refstepcounter command where \refstepcounter{counter} works like \stepcounter, except it also defines the current \ref value to be the result of \thecounter.

Now, sometimes, specially when building some home grown macro, we face a situation (believe me, I have been in that situation more than once in my life) where we need to \ref to a custom counter without actually incrementing the value.

If we check the definition of \refstepcounter, we see something like this:

\stepcounter {#1}\protected@edef \@currentlabel {\csname p@#1\endcsname \cs
name the#1\endcsname}


So, defining the command \refcounter would mean a simple deletion of the first incrementing part, namely, removing \stepcounter {#1}.

Why is not the \refcounter command part of base LaTeX?

Is the reason a plain and simple omission or there is a specific reason behind this?

• If hyperref is loaded the definition is different. – Ulrike Fischer Aug 30 '17 at 16:40
• it is so rarely needed, and you can always do \addtocounter{foo}{-1}\refstepcounter{foo} if you need it and don't want to look at the internals. – David Carlisle Aug 30 '17 at 16:46
• @DavidCarlisle but not together with hyperref, you would get a " destination with the same identifier (name{section.1})" warning. – Ulrike Fischer Aug 30 '17 at 16:51
• @DavidCarlisle not "probably", I tried ;-) – Ulrike Fischer Aug 30 '17 at 16:52
• @DavidCarlisle Yes, the problem are two \refstepcounters to the same value. – Ulrike Fischer Aug 30 '17 at 17:01