1

I am working with the labeling environment and I would like to cross-reference to items by their labels. Here is a sample code:

\documentclass{article}
\usepackage{hyperref}
\usepackage{nameref}
\usepackage{scrextend}
\addtokomafont{labelinglabel}{\sffamily}
\begin{document}
\begin{labeling}{Cookies}
\item[Cookies] chocolate chip
\end{labeling}
\end{document}

And I want to later refer to the item Cookies by its name ``Cookies.'' But the traditional label-ref does not seem to work. Any guidance would be greatly appreciated.

2
\documentclass{article}
\usepackage{hyperref}
\usepackage{nameref}
\usepackage{scrextend}
\addtokomafont{labelinglabel}{\sffamily}
\makeatletter
\newcommand\labelitem[2]{%
  \item[#1]\def\@currentlabel{#1}\label{#2}}
\makeatother
\begin{document}
\begin{labeling}{Cookies}
\labelitem{Cookies}{cookie} chocolate chip
\end{labeling}

\ref{cookie}
\end{document}
|improve this answer|||||

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.