193

I'd like to be able to resume an enumerated list, continuing the old numbering, after some intervening text which should not be formatted like a list item. Is there a nice way to do this?

In particular, I don't want to start a second list with a hard-coded initial counter value, because that will break if I change the number of items in the first list.

210

This can easily be done using the enumitem package, for example:

\documentclass[12pt]{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}
  \item One
  \item Two
  \end{enumerate}
Some text
\begin{enumerate}[resume]
  \item Three
\end{enumerate}
\end{document} 

Output:

alt text

Alternatively, the package mdwlist provides the commands \suspend and \resume for temporarily ending a list and restarting it.

| improve this answer | |
  • 31
    Before this site existed, I had the impression there were a couple dozen tex packages I should know about that I don't. Now it seems like thousands. – Mark Meckes Aug 13 '10 at 17:17
  • 1
    @Mark, i feel the same way. every thread on this site introduces me to 2 or more new packages. – masfenix Aug 13 '10 at 17:34
  • 3
    I was about to ask another question, but then on a whim Googled the name that I would have given a package to solve my problem (theoremref), and came up with exactly what I wanted. – Mark Meckes Aug 13 '10 at 19:20
  • @MarkMeckes It never ends! :P – Alenanno Apr 24 '12 at 11:45
113

Just save the counter and then restore it. There's no reason to use packages for things like this.

\documentclass{article}

\newcounter{nameOfYourChoice}

\begin{document}

\begin{enumerate}
\item Foo
\setcounter{nameOfYourChoice}{\value{enumi}}
\end{enumerate}

Foo

\begin{enumerate}
\setcounter{enumi}{\value{nameOfYourChoice}}
\item Foo
\end{enumerate}

\end{document}
| improve this answer | |
  • 8
    I admire the simplicity. The advantage of one of the packages Stefan suggested is that it allows for more semantic markup. – Mark Meckes Aug 14 '10 at 13:22
  • 12
    I'm happy to see this solution. I'm always a bit hesitant to clutter my document with yet another package, because you can never really be sure what else it does under the hood, in addition to fixing a small problem you have. – Thomas Feb 8 '11 at 16:23
  • 3
    I think this is the better solution for a one off. But if you're going to be doing it a lot, then the enumitem solution is better (especially since you might want to use other features of enumitem if you have a lot of lists going on...) – Seamus May 30 '11 at 12:50
  • 7
    Thinking about it, this solution also has the advantage that you can have one list, then have another list, and then resume the first list. (Although I'm not totally sure that would be a good idea...) – Seamus May 30 '11 at 12:56
  • 4
    @Seamus: Apparently enumitem also allows one to do that, through what it calls series. – Mark Meckes Apr 20 '12 at 16:54
20

The question How to have the same counter in two enumerate lists? was closed as a duplicate of this one but introduced a slight difference: one of the pieces of the enumeration was inside a theorem environment. When using enumitem this needs special handling. The solution is contained in Mark Meckes comment on Carl's answer above, but in light of the new question I thought it instructive to give an example.

First, the non-working code:

\documentclass{article}
\usepackage{enumitem}
\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 have exited the theorem environment. We also have one more condition,

\begin{enumerate}[resume]
\item\label{condition3}\emph{the third condition}.
\end{enumerate}
\end{document}

When TeXed, the third condition has the incorrect number 1. Commenting out the \begin{theorem} and \end{theorem} lines gives it the correct number 3.

The correct way to correct this is to use the series key. This is explained in Section 3.5 of the enumitem manual. The feature was introduced in Version 3.0.

\documentclass{article}
\usepackage{enumitem}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem} We are in the theorem environment,
\begin{enumerate}[series=theoremconditions]
\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}[resume=theoremconditions]
\item\label{condition3}\emph{the third condition}.
\end{enumerate}
\end{document}

This produces the correct numbering. It can also handle having arbitrary stuff in between, including other lists.

Here's the same example with the labels modified (see How to have the same counter in two enumerate lists?), also showing the use of the resume* variant.

\documentclass{article}
\usepackage{enumitem}
\newtheorem{theorem}{Theorem}

\begin{document}
\begin{theorem} We are in the theorem environment,
  \begin{enumerate}[label=(\roman*),series=theoremconditions]
    \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*=theoremconditions]
  \item \label{condition3}\emph{the third condition}
\end{enumerate}

\begin{theorem}
  We have another theorem, based on \ref{condition3}.
\end{theorem}
\end{document}
| improve this answer | |
  • Interestingly, this fix does not seem to work if your document is an amsart document. However, if this is so then Carl Mummert's \newcounter method does the trick (even with the specific conditions in your answer)! – user1729 Jun 12 '12 at 16:23
11

Here is a way if you don't want to do it by hand each time. We define a counter and make our own enumerate environment that uses that counter and doesn't reset it when we exit:

\documentclass{article}

\newcounter{myenumi}
\setcounter{myenumi}{0}

\newenvironment{myenumerate}{
\begin{enumerate} 
\setcounter{enumi}{\value{myenumi}}
}{
\setcounter{myenumi}{\value{enumi}}
\end{enumerate}
}

\begin{document}

\begin{myenumerate}
\item first one
\item second one
\end{myenumerate}
Now we've ended the enumeration.

Let's start enumerating again
\begin{myenumerate}
\item third
\item fourth.
\end{myenumerate}
We've ended again.

But we aren't done yet
\begin{myenumerate}
\item fifth
\item sixth
\end{myenumerate}
Shall we go on further?
\end{document}

But - if you want to start over, then you'll need to do \setcounter{myenumi}{0} again.

You could define a new environment like startmyenumerate which does everything above except it also resets the counter. Then define continuemyenumerate to be what I did above, without the resetting the counter.

| improve this answer | |
  • This also works for compactenum, provided by the paralist package. :+1: – koppor Jun 4 '16 at 19:58
1

A simple alternative way to do this is with the outlines package. With the outlines package, you can have a list with 4 levels of enumeration as well as a 0th layer of regular text. The levels are referenced by \0, \1, \2, \3 and \4 from plain text to most indented.

\documentclass[12pt]{article}
\usepackage{outlines}
\begin{document}
\begin{outline}[enumerate]
\1 One
\1 Two
\0 Some text
\1 Three
\2 Sub-point to three
\1 Four
\end{outline}
\end{document} 

In order to count over the zero level, a little extra work is needed. We will define a new counter to keep track of the number of items in our ordered list, for any depth. The environment where this happens is called cenumerate-- as in, continuing to enumerate. To employ this environment at any level k in i, ii, iii or iv, just employ the command \renewcommand{outlinek}{cenumerate} before the start of your outline. Be warned, this will even continue to count across outlines! To reset the counter and return to default behavior, use the command \renewcommand{outlinek}{enumerate}. The code below demonstrates these ideas.

\documentclass[12pt]{article}
\newcounter{cenum}
\newcounter{cenumsaved}
\setcounter{cenumsaved}{0}
\newcommand{\labelcenum}{\arabic{cenum}.}
\newenvironment{cenumerate}%
{\begin{list}{\labelcenum}{\usecounter{cenum}}%
\setcounter{cenum}{\value{cenumsaved}}}%
{\setcounter{cenumsaved}{\value{cenum}}%
\end{list}}
\usepackage{outlines}
\begin{document}


\noindent \textit{This outline counts level one without stopping.}
\renewcommand{\outlinei}{cenumerate}
\begin{outline}
\1 One 
\1 Two  %\setcounter{outlinetemp}{\value{outlinei}}
\0 Some text
%\setcounter{\outlinei}{3}
\1 Three
\2 Sub-point to three
\1 Four
\end{outline}

\noindent \textit{This outline counts level two without stopping}
\renewcommand{\outlinei}{itemize}
\renewcommand{\outlineii}{cenumerate}
\setcounter{cenumsaved}{0}
\begin{outline}
\1 One 
\2 another point to one
\1 Two  %\setcounter{outlinetemp}{\value{outlinei}}
\2 another point to two
\0 Some text
%\setcounter{\outlinei}{3}
\1 Three
\2 Sub-point to three
\2 second sub-point to three
\1 Four
\end{outline}

\noindent \textit{Back to the default way}

\renewcommand{\outlinei}{enumerate}
\renewcommand{\outlineii}{enumerate}
\begin{outline}[enumerate]
\1 One
\1 Two 
\0 Some text
\1 Three 
\2 Sub-point to three
\1 Four
\end{outline}
\end{document}
| improve this answer | |
  • This doesn't answer the question of having a list be resumed. As soon as you use a 0th layer \0, the list enumeration is restarted. How can you, for example, use a 0th layer and have the enumeration of the higher layer \1 be resumed after that? – Werner Feb 14 at 23:20
  • Good point Werner. Thanks. I corrected the code with examples of how you could continue counting across level \1 or \2 despite an interruption from a higher level. – Notarobot2244 Feb 15 at 6:58
1

With linguex this is just write \ex. text EnterEnter anywhere in the document, without enclosing it in any list environment:

\documentclass{article}    
\usepackage{linguex}    
\usepackage{lipsum} % for dummy text    
\begin{document}
\ex.  \lipsum[1][1-1]\par % end item always with a blank line (or \par) 
\ex.  \lipsum[2][1-3]\par 
\ex.  \lipsum[3][1-1]\par 
\lipsum[4][1-4]\par 
\ex.  \lipsum[5][1-3]\par 
\ex.  \lipsum[6][1-1]\par 
\lipsum[7][1-4]\par 
\section*{Foo}
\lipsum[8][1-4]\par 
\ex.  \lipsum[8][1-1]\par 
\ex.  \lipsum[9][1-1]\par 
\lipsum[10][1-1]\par 
\ex.  \lipsum[11][1-1]\par 
\ex.  \lipsum[12][1-1]\par 
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.