Suppose I have a counter, say, count. I can do something like this
\setcounter{count}{0}
\refstepcounter{count}\thecounter{count}\label{cool}
\ref{cool}
This will give me "1" in the end. Now, I would like to be able to use nameref in the following way (which doesn't quite work, and which is the reason why I ask this question)
\setcounter{count}{0}
\refstepcounter{count}\thecounter{count}
\@currentlabelname{awesome:\thecount}}\phantomsection\label{cool}
\stepcounter{count}
\nameref{cool}
I would like the result to be awesome:1, but it will be 2 in this case, because when I do nameref, \thecount gives value 2. The problem is that \thecount doesn't save the value at the point it's called. How do I fix this?
As a side note, something like \tag (for equation) might work. For example, if I have \tag{awesome:\thecount}\label{cool} and have \eqref{cool} later on, I actually get the correct result.
\protected@edef, never knew about that! Mysterious things withinhyperrefthat needed protection were throwing errors on all changes of\@currentlabelnamefor me. – scorchgeek Aug 21 '22 at 02:12