# Setting the enumi counter under custom enumeration with enumitem

I have a several items in an 'enumitem' enumerate environment with custom label styles, and I would like to repeat them at various points later on.

Something like this:

(a) Unicorns don't exist.

(b) Trees exist.

As I have said before:

(a) Unicorns don't exist.

What I tried to do was use \setcounter{enmui}{...} in a later enumerate environment with a reference to the label of the previous item. I had hoped that I could then \addtocounter{enmui}{-1} so that the next \item would have the same label as the one I referenced.

However, I ran into trouble because \ref{somelabel} (where somelabel is the label of an item in the enumerate environment) gives the stylised counter rather than the actual number.

So I tried using the 'refcount' package. But that doesn't seem to work either, and \getrefnumber{somelabel} gives the same result as \ref{somelabel}.

Here is a simplified version of my markup:

\documentclass{article}

\usepackage{enumitem}
\usepackage{refcount}

\begin{document}

\begin{enumerate}[label=(\alph*)]
\item Thing 1\label{first}
\item Thing 2
\setcounter{enumi}{\ref{first}}
\item Thing 3
\setcounter{enumi}{\getrefnumber{first}}
\item Thing 4
\end{enumerate}

\begin{enumerate}[resume*]
\setcounter{enumi}{\ref{first}}
\item Thing 5
\setcounter{enumi}{\getrefnumber{first}}
\item Thing 6
\end{enumerate}

Reference: \ref{first}. Number: \getrefnumber{first}.

\end{document}


I get ! Missing number, treated as zero. <to be read again> errors for each \setcounter (but only on the second run through).

The result looks like:

So despite latex's protestations, it does seem to be setting the counter right in the first enumerate (though in fact it should be (b), since I haven't decremented the counter by one; and it also prints out extra (a)'s).

However, in the second enumerate, it fails to even form a valid list (I get ! LaTeX Error: Something's wrong--perhaps a missing \item. errors too).

Note: I remove [label=(\alph*)] and [resume*], this all works perfectly.

I know this could be achieved by defining a counter for each item, or even hard-coding the values, but I'd rather do this with labels and references if possible.

• Welcome to TeX SE! You will save time if you look at enumitem's documentation as it has an option for this ;). I think it is ref=.
– cfr
Dec 1, 2014 at 0:08

I am not entirely sure I understand everything you are trying to do but maybe this will help:

\documentclass{article}

\usepackage{enumitem}

\begin{document}

\begin{enumerate}[label=(\alph*), ref=\alph*]
\item Thing 1\label{first}
\item Thing 2
\item Thing 3
\item Thing 4
\end{enumerate}

As I have said before:
\begin{itemize}
\item[(\ref{first})] Thing 1
\end{itemize}

Continuing our survey:

\begin{enumerate}[resume*]
\item Thing 5
\item Thing 6
\end{enumerate}

Reference: \ref{first}.

\end{document}


ref= sets the format for the label when used in references. By default, it is set to the value of the label, but you can override this as shown. You don't really want an enumeration when repeating items. You specifically want to repeat the earlier label, so I would use an itemize here with explicit labels constructed from the references.

• Wonderful, thank you! I must have missed that handy option in the documentation. Dec 1, 2014 at 7:05
• I'll edit the question a little to make it clearer what I was asking. Dec 1, 2014 at 7:06