Simple use case, I have a counter for requirements, R1, R2, etc like the one below:


However, when I refer to a counter instance (i.e. \requirement{req:a} by \ref{req:a}) then the \ref{} will only contain the counter value, rather than the custom label in the format of R.value

How can I format the counter reference label?

  • Welcome to TeX.SE. Does your code provide a \label instruction for req:a? – Mico Jun 25 '20 at 12:24

It is sufficient to redefine macro \the<counter>. Then the \label/\ref system will pick it up automatically:



Here's a small snippet that can do this:

  R\ref*{#1} \refstepcounter{reqcount}\label{#1}

Example usage:

Here is req: \reqitem{reqi:a}

Here is req: \reqitem{reqi:b}

Here is reference: \descref{reqi:a}, \descref{reqi:a}, \descref{reqi:b}


enter image description here

  • What are you trying to demonstrate with the duplicate \descref{reqi:a} directives? – Mico Jun 25 '20 at 12:28

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.