1

I would like to refer to an item in a lower-level list by just the lower-level label without it being prefixed by the higher-level labels. For example:

\documentclass{article}

\begin{document}

\begin{enumerate}
    \item First level
    \begin{enumerate}
        \item \label{itm:second} Second level
    \end{enumerate}
\end{enumerate}

Reference to the item in the second level appears as \ref{itm:second}.

\end{document}

MWE

Instead of the reference appearing as "1a", I want it to appear as just "a"; moreover, I only want the behavior for a single instance (or a few instances). I do not want to change the default behavior of \ref, or change the setting of the list itself (which would be accomplished by this answer), but just for a single instance I want to refer to the item as just "a". Is there some variant of \ref that shows only the lower-level label? Or else how should I do this?

1 Answer 1

1

You could define a variant of \label to write only the lower-level part in the .aux file, so that when calling \ref with a label defined with this variant, only the lower-level label is printed.

\documentclass{article}
\makeatletter
\newcommand*{\sublabel}[1]{%
    \let\old@currentlabel\@currentlabel%
    \renewcommand{\@currentlabel}{\theenumii}%
    \label{#1}%
    \let\@currentlabel\old@currentlabel%
}
\makeatother
\begin{document}

\begin{enumerate}
    \item First level
    \begin{enumerate}
        \item \label{itm:second} \sublabel{itm:secondonly} Second level
    \end{enumerate}
\end{enumerate}

Reference to the \verb|\label| of the item in the second level appears as \ref{itm:second}.

Reference to the \verb|\sublabel| of the item in the second level appears as \ref{itm:secondonly}.

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .