# references with enumitem

I'm sorry if this question was asked elsewhere. I searched all over but couldn't find it.

I'm writing a document with lots of lists and lots of references. I'd like to refer to an entry of a list without explicitly writing out \label{} for each entry. I thought the enumitem package would solve this but maybe I'm mistaken.

Here's an example:

\begin{theorem} There are four equivalent things
\begin{enumerate}[label=(\roman{*}), ref=(\roman{*})]
\item Thing 1
\item Thing 2
\item Thing 3
\item Thing 4
\end{enumerate}


And then later in the text I refer to this as

Theorem~\ref[(ii)]{thm:4.1}


The text comes out as Theorem ??(ii)]thm:4.1

Is such a thing possible? Or is this asking too much?

• You have to define a label for later reference: \item\label{th2} Thing 2 and then you can say Theorem~\ref{thm:4.1}\ref{th2}. By the way, labeling theorems with their number is not a good idea; use descriptive names instead. – egreg Jul 15 '13 at 21:13
• @egreg Thanks! This label actually refers to a different number altogether, but I agree that it's better to use descriptive names. – mcat Jul 16 '13 at 1:32

The main problem here is that \ref doesn't support an optional argument. As such, the first token [ is considered to be the mandatory argument passed to \ref, which doesn't have an appropriate \label associated with it. Instead, you could use one of the following options, all of them supported by default via enumitem:

\documentclass{article}
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}\label{thm:labelA} There are four equivalent things
\begin{enumerate}[label=(\roman*), ref=(\roman*)]
\item \label{thm:labelA:thing1} Thing 1
\item \label{thm:labelA:thing2} Thing 2
\item \label{thm:labelA:thing3} Thing 3
\item \label{thm:labelA:thing4} Thing 4
\end{enumerate}
\end{theorem}

Theorem~\ref{thm:labelA}\ref{thm:labelA:thing2}.

\begin{theorem}\label{thm:labelB} There are four equivalent things
\begin{enumerate}[label=(\roman*), ref=\thetheorem(\roman*)]
\item \label{thm:labelB:thing1} Thing 1
\item \label{thm:labelB:thing2} Thing 2
\item \label{thm:labelB:thing3} Thing 3
\item \label{thm:labelB:thing4} Thing 4
\end{enumerate}
\end{theorem}

Theorem~\ref{thm:labelB:thing2}.

\end{document}


The first requires a manual separation between the theorem environment label and the enumerated item, while the second combines it in a single step by adding \thetheorem to the ref property of the list.

• I guess you can't automate the labels as I'd hoped. Thanks for the examples! – mcat Jul 16 '13 at 1:30
• @mcat: In what way do you wish to "automate the labels"? Do you want to avoid adding \thetheorem as part of ref=? Do you want to avoid adding \label{thm:labelB:thing2} to an item that you want to reference later via \ref? Automation of these \labels are sometimes easy to do, but not that convenient to use since it doesn't always make things go quicker as opposed to just labelling them as needed. Even so, you need to be very specific in the requirements. – Werner Jul 16 '13 at 2:20
• Yes, the latter. I have many of these to label, but I can just do it as needed as you say. – mcat Jul 16 '13 at 2:28