4

How can I achieve that the reference to the second item in the following enumeration is just (a) and not (1a)?

\documentclass{amsart}
\usepackage{enumerate}
\begin{document} 
\begin{enumerate}[(1)]
 \item\label{1} ABCD
 \begin{enumerate}[(a)]
   \item\label{a} xyz
  \end{enumerate}
\end{enumerate}
Now refer to \eqref{a}.
\end{document}

enter image description here

  • One might argue about the usefulness of using (a) when you refer to a subitem 1a -- unless it's unique and clear. I would use \ref and not \eqref here. – user31729 Dec 9 '15 at 16:10
3

Under amsart the reference prefix - denote by \p@-style macros - for each level of an enumerate is set to be hierarchical, thereby inheriting that of the previous level. You can remove this prefix in the preamble.

enter image description here

\documentclass{amsart}

\makeatletter
\renewcommand{\p@enumii}{}% Remove prefix for second-level enumerate item
\makeatother

\begin{document} 

\begin{enumerate}
 \item\label{1} ABCD
 \begin{enumerate}
   \item\label{a} xyz
  \end{enumerate}
\end{enumerate}
Now refer to (\ref{a}).

\end{document}

Note that there is no formatting of the labels required, as the default matches your anticipated output.

  • A nice solution to -- I should look into p@enumii ;-) (+1) – user31729 Dec 9 '15 at 17:10
2

Here's a quick and dirty method: \usepackage[shortlabels]{enumitem} instead of enumerate and say label={(\alph*)}] or \begin{enumerate}[(a)]. This uses the correct labelling.

\documentclass{amsart}
%\usepackage{enumerate}
\usepackage[shortlabels]{enumitem}
\begin{document} 
\begin{enumerate}[(1),leftmargin=*]
 \item\label{1} ABCD
 \begin{enumerate}[label={(\alph*)}]
   \item\label{a} xyz
  \end{enumerate}
\end{enumerate}
Now refer to \ref{a}.
\end{document}

enter image description here

  • Why is it dirty? – lpdbw Dec 9 '15 at 16:14
  • @lpdbw: It drops enumerate and uses another (easier to use package?), i.e. enumitem – user31729 Dec 9 '15 at 16:15
  • 1
    I see, you would in general say enumitem is "better"? – lpdbw Dec 9 '15 at 16:16
  • 1
    @lpdbw: It's more flexible, more up-to-date, in my point of view. But it can't be used fully with beamer, unfortunately. – user31729 Dec 9 '15 at 16:18
  • @ChristianHupfer careful choice of words in your answer to the comment:-) – David Carlisle Dec 9 '15 at 16: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.