Cross-referencing enumerate item
Here is a different solution using the enumitem
package. With it we can configure how references to items look. In this MWE I change the reference format of second level enumerate
globally.
As an added bonus we do not have to mess with internals.
\documentclass[12pt]{article}
\usepackage{enumitem}
\setlist[enumerate,2]{
ref=(\alph*),
}
\begin{document}
\begin{enumerate}
\item Solve $x^2=1$.
\item Solve $x^2=4$.
\begin{enumerate}
\item \label{enum:1} Find all roots.
\item For each root in \ref{enum:1}, subtract 2 from it.
\end{enumerate}
\end{enumerate}
\end{document}
The key is to redefine the macro \p@enumii
, which holds the prefix used in this situation:
\documentclass[12pt]{article}
\begin{document}
\begin{enumerate}
\item Solve $x^2=1$.
\item Solve $x^2=4$.
\begin{enumerate}
\makeatletter
\renewcommand*\p@enumii{}
\makeatother
\item \label{enum:1} Find all roots.
\item For each root in (\ref{enum:1}), subtract 2 from it.
\end{enumerate}
\item To show that the redefinition is local:
\begin{enumerate}
\item \label{enum:2} Find all roots.
\item For each root in (\ref{enum:2}), subtract 2 from it.
\end{enumerate}
\end{enumerate}
\end{document}