Continuous list enumeration throughout the document with LaTeX

Karolina asked me today to create a macro for having a continuous list enumeration throughout the whole document, i.e.

This is the first list:

1. Item;
2. Another item;

And here goes the second list:

3. Third item;
4. And yet another item.

You can obtain an effect like that by using LaTeX counters and a custom definition of your own enumerate environment. First, we need to usepackage{enumerate}, and then define the following counter and an environment in the preamble:

newcounter{enumi_saved}
newenvironment{myenumerate}
{ begin{enumerate}setcounter{enumi}{value{enumi_saved}}}
{setcounter{enumi_saved}{value{enumi}}end{enumerate}}

After that, you can use myenumerate and you’ll have a continuous enumeration in the whole document.

Oh and some credits: I wouldn’t come up with a solution if I haven’t read this post, and this website. Huge thanks to the authors for their tips!

update: There’s a much simpler solution, thanks Jakub.

4 comments

  1. Jakub · June 28, 2010

    You can also use usepackage{enumitem} for that with begin{enumerate}[resume].

  2. Piotr Kaźmierczak · June 28, 2010

    :D

    you mean all my efforts to impress people by my tex-skills make no sense, because someone’s already made a package?;) damn…

  3. tikitu · June 28, 2010

    Your first stop for this kind of thing should always be the UK TeX FAQ (in fact, I find it’s worth browsing it without having a question in mind every six months or so). Jakub’s solution shows up in the question how to interrupt an enumerate list.

  4. Piotr Kaźmierczak · June 28, 2010

    thanks! bookmarked! (or actually… delicioused)

Comments are closed.