Context: I want to store values in the aux file to use them earlier in the file on the next run, rather than creating my own solution I want to use labels (as suggest by this answer).

Problem: Whenever a label is defined it creates something like this


I want to be able to extract those values. \ref does not work as its output is not just the value but some complex latex string.

  • 1
    \getrefnumber{customLabel} from package refcount -- it is expandable, \ref isn't.
    – user31729
    Mar 8, 2016 at 14:48
  • That worked for my current problem, is there any reason why you will not post this as an answer? Mar 8, 2016 at 14:55
  • I was writing an answer ;-)
    – user31729
    Mar 8, 2016 at 14:58
  • I've added an answer, with another way of writing the label -- this is not shown by you, so I assumed some approach
    – user31729
    Mar 8, 2016 at 15:10

1 Answer 1


With refcount and \getrefnumber it is possible to extract label values in an expandable way.

\getrefnumber{foo} will provide whatever is stored as label value, this might be a number but it is not restricted to numbers. (It can be 'anything')

The label value must be stored as second argument of \newlabel.








\ifnum\getrefnumber{otherLabel} < 25 

\ifnum\getrefnumber{customLabel} < 25 


enter image description here

  • I used \def\@currentlabel{#2}\label{#1} to save the label but the net result is the same. Mar 8, 2016 at 17:09

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.