TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi I build a customer list environment with a counter, and I'd like to be able to reference the name the label associated with the counter. The code below produces an output similar to this:


  • REQ1 Requirement one
  • REQ2 Requirement two

Another Section

  • We want read "Requirement One" here : Requirements.
  • But instead we get the section name!


\usepackage[bookmarks, colorlinks=true, linkcolor=black, citecolor=black, urlcolor=black]{hyperref}


  { \begin{list}{\textbf{\thereqcount}}{\usecounter{reqcount}} }
  { \end{list} }

  \item \textbf{#1}
  \addcontentsline{toc}{subsection}{\thereqcount \quad #1}


\section{Requirements Section}
  \requirement{Requirement one} \label{req_one} \\
  \requirement{Requirement two} \label{req_two} \\

\section{Another Section}
We want read "Requirement One" here : \nameref{req_one}.
But instead we get the section name.

share|improve this question
I suspect that zref can do what you want. – Lev Bishop Oct 27 '10 at 5:49
A similar question was asked and answered here: stackoverflow.com/questions/2767389/… might be worth looking at. – Seamus Oct 28 '10 at 10:17

Set \@currentlabelname:

  \addcontentsline{toc}{subsection}{\thereqcount \quad #1}
share|improve this answer

It's not quite the same thing, but consider the following:

  { \begin{list}{\textbf{\thereqcount}}{} }
  %{ \begin{list}{\textbf{\thereqcount}}{\usecounter{reqcount}} }
  { \end{list} }
  \item \textbf{#1}
  \addcontentsline{toc}{subsection}{\thereqcount \quad #1}

The inclusion of \refstepcounter means that the value of the reqcount counter becomes the thing that \label now picks up (rather than the argument of \section, which will have been the last thing that invoked \refstepcounter).

After this, \ref{req_one} expands to "REQ1". Getting \nameref to do the same is presumably not far away (ie, exercise for reader territory!)

share|improve this answer
Responding to Ulrike's suggestion: \refstepcounter ultimately results in setting \@currentlabel (though with hyperref being part of the game, that's a biiig 'ultimately'). I suspect that \@currentlabelname is a hyperref addition, to support \nameref. – Norman Gray Oct 27 '10 at 9:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.