# Referencing an enumeration item with redefined \labelenumi

I've got the following problem. I redefined the \labelenumi command to get an alphabetic first-order enumeration. If I label an item in this enumeration and generate a reference to it, the number of the item and not the modified label.

A minimal example:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\renewcommand{\labelenumi}{\alph{enumi}.)}

\begin{document}
\begin{enumerate}
\item\label{part1} This is the first part.
\item We have seen in~\ref{part1}, that this does not work.
\end{enumerate}

\end{document}


gives:

   a.) This is the ﬁrst part.
b.) We have seen in 1, that this does not work.


What needs to be refined that \ref prints the character and not the number?

-

A bare-bones solution is to redefine \theenumi (and, if desired, \labelenumi on top of that).

\documentclass{article}

\renewcommand{\theenumi}{\alph{enumi}}
\renewcommand{\labelenumi}{\theenumi)}

\begin{document}

\begin{enumerate}
\item\label{part1} This is the first part.
\item We have seen in~\ref{part1} that this does not work.
\end{enumerate}

\end{document}


-

Whenever you're customizing a list, the enumitem is your best friend.

In the code below I've used the \setlist command to customize the enumerate environment. In particular, I've changed the label using

label*=\alph*)


which changes the label to a), b), etc. I've also changed the ref using

ref=\alph*


which means that when you reference it you'll get a, b, c without the parenthesis. If you don't specify a format for ref then it simply inherits the format specified by label.

You can, of course, customize this as you see fit.

\documentclass{article}
\usepackage{enumitem}
\setlist[enumerate]{label*=\alph*),ref=\alph*}

\begin{document}
\begin{enumerate}
\item\label{part1} This is the first part.
\item We have seen in~\ref{part1}, that this does not work.
\end{enumerate}

\end{document}

-
Unfortunately, your minimal example/solution did not work. –  Grisu Sep 10 '12 at 15:57
@Grisu sounds like an update is in order –  cmhughes Sep 10 '12 at 16:02

Just because you're using a fancy-pants package like cleveref doesn't mean you should forget all the old-skool techniques :-)

Since time immemorial, the way to format counters in LaTeX has been by redefining the \the<counter> command. Using cleveref doesn't change this. (Indeed, argument #2 in\crefformat et al. is the formatted counter produced by \the<counter>, not the raw counter value, for precisely this reason.)

Try the following MWE:

\documentclass{memoir}
\usepackage{cleveref}

\newtheorem{theorem}{Theorem}

\renewcommand{\theenumi}{\thetheorem(\alph{enumi})}
\renewcommand{\labelenumi}{\alph{enumi}}

\begin{document}
\begin{theorem}\label{thm}
My big theorem
\begin{enumerate}
\item\label[theorem]{thm!simple} Simple case
\item\label[theorem]{thm!complex} Complex case
\end{enumerate}
\end{theorem}

\cref{thm!simple}%  theorem 1(a)

\ref{thm!simple}%   1(a)

\end{document}


Note that I've used cleveref's optional argument to \label to tell it to format these labels as theorems, rather than as (automatically-inferred) enumi's. If you're using this a lot, it might be more convenient to define a new enumeration list variant (with its own counter), and tell cleveref how to format this new label type in the usual way. This would allow you to drop the optional argument and let cleveref infer the label type automatically.

But this MWE is anyway only to illustrate the basic idea. It reformats all enumi's to include the last theorem number before the enum item, which is no use if you want to use enumeration lists anywhere other than in theorems. There are various solutions to this for real documents, from simple but limited in scope, to elaborate but providing full flexibility. The best one that currently springs to mind is as described above: define a separate enumeration list variant for use within theorems. But someone else may have an even better idea.

-