# How to have the same counter in two enumerate lists? [duplicate]

Possible Duplicate:
Resuming a list

I want to have an enumerate list which is broken in the middle by some text. What I have at the moment is something along the lines of this,

\renewcommand{\labelenumi}{(\roman{enumi})}
\newtheorem{theorem}{Theorem}

\begin{theorem} We are in the theorem environment,
\begin{enumerate}
\item\label{condition1}the first condition,
\item\label{condition2}the second condition,
\end{enumerate}
\end{theorem}

We have exited the theorem environment. We also have one more condition,

\begin{enumerate}
\item[\emph{(iii)}]\label{condition3}\emph{the third condition}.
\end{enumerate}


However, I do not like the fact I have to manually number the final condition, and it also leaves me with problems when referencing. I was therefore wondering if it is possible to connect the counters in the two lists?

Otherwise (and clearly this is less than ideal), is there a way of getting \ref{condition2} to be (iii) (that is, what it is in the square brackets). There must be some way of doing this, but I cannot find it! Currently, it spits out...2 (so clearly my issues go deeper than just this question! However, a solution to one of these question would pretty much sort everything out...).

EDIT

The solutions given in the Resuming a list question do not seem to work in my example. Two solutions were proffered:

The second solution, which gets LaTeX to save the counter manually, I cannot get to work in my document, although it does work when I make a sample document. This is similar to the answer given below, which does work in my document, so I will not dwell on this.

The first solution has a subtle problem, which makes it unsuitable for my use. This solution uses the enumitem package. The solution works if the document contains only one Theorem, or if both lists are not straddling a theorem in any way. However, the following does not work (and this most closely resembles what I am doing),

\documentclass{article}
\usepackage{enumitem}
\renewcommand{\labelenumi}{(\roman{enumi})}
\newtheorem{theorem}{Theorem}

\begin{document}
\begin{theorem} We are in the theorem environment,
\begin{enumerate}
\item \label{condition1}the first condition,
\item \label{condition2}the second condition,
\end{enumerate}
\end{theorem}

We havve exited the theorem environment. We also have one more condition,
\begin{enumerate}[resume]
\item \label{condition3}\emph{the third condition}
\end{enumerate}

\begin{theorem}
We have another theorem.
\end{theorem}
\end{document}


Here, the counter is reset when we exit the theorem environment so we get,

(i) the third condition.


while we actually want

(iii) the third condition.


and the same thing happens to the reference (the code I've got above will give \ref{condition3} as 1)

-

## marked as duplicate by Loop Space, N.N., Torbjørn T., cmhughes, David CarlisleApr 24 '12 at 11:18

–  celtschk Apr 24 '12 at 10:55
Please take a look at the linked question (same question in both comments!) to see if it answers your question. If so, we'll close this as a duplicate to better direct people looking for similar solutions. –  Loop Space Apr 24 '12 at 10:56
@AndrewStacey It looks like it does - I'm just typing it in to double check... –  user1729 Apr 24 '12 at 10:59
The enumitem package doesn't seem to like more than one counter going on. If I am not in the theorem environment then I have no problems, but because one list is in the theorem environment and the other is outside the counter is (seemingly) reset (however, if you have a document with only one theorem there is no problems). –  user1729 Apr 24 '12 at 11:19
@user1729 Actually, in taking a look at the other answer I saw a comment that is relevant to your situation. I've expanded on that comment in another answer at that question which might help. That error message can mean a misspelled name in \setlist (see p16 in the enumitem manual). –  Loop Space Apr 24 '12 at 11:43

You can save and restore the count like so:

\documentclass{article}

\makeatletter
\def\saveenum{\xdef\@savedenum{\the\c@enumi\relax}}
\def\resetenum{\global\c@enumi\@savedenum}
\makeatother

\newenvironment{theorem}{}{}

\begin{document}
\begin{theorem} We are in the theorem environment,
\begin{enumerate}
\item\label{condition1}the first condition,
\item\label{condition2}the second condition,
\end{enumerate}
\end{theorem}

We have exited the theorem environment. We also have one more condition,

\saveenum
\begin{enumerate}\resetenum
\item\label{condition3}\emph{the third condition}.
\end{enumerate}

\end{document}

-
This works wonderfully. Thanks! –  user1729 Apr 24 '12 at 11:26