Tx · LaTeX & TikZ

Why Doesn’t \setcounter{enumi} Work with enumitem’s resume?

Published By the 9to5Science editorial team

At a glance

  1. 1. Check the list level

    Use enumi for the first enumerate level, enumii for the second, and so on.

  2. 2. Open the resumed list

    The resume option restores the counter saved from the previous list.

  3. 3. Set the counter afterward

    Place \setcounter after \begin{enumerate}[resume] and before the first \item.

  4. 4. Choose the right starting value

    Set the counter to one less than the number you want on the next item.

With enumitem, the resume option restores the numbering state from an earlier list. That restoration happens as the new list begins, so a counter value set before \begin{enumerate}[resume] may be replaced. Set the counter inside the resumed list, before its first \item, or use start for a new list that should begin at a particular number.

Why the counter gets overwritten

At the first level of an enumerate environment, LaTeX uses the counter enumi. When you write \begin{enumerate}[resume], enumitem retrieves the saved state and continues from it. A \setcounter{enumi}{...} placed before that environment sets the value too early: the resumed list can restore its saved value afterward.

The value passed to \setcounter is the number of the previous item. For example, set enumi to 4 when you want the next item to be numbered 5.

Worked example: override the resumed number

This complete example first makes a two-item list. The next list resumes, then explicitly changes the counter so its first item is numbered 5.

\documentclass{article}
\usepackage{enumitem}

\begin{document}

\begin{enumerate}
  \item First item
  \item Second item
\end{enumerate}

\begin{enumerate}[resume]
  \setcounter{enumi}{4}
  \item This item is numbered 5
  \item This item is numbered 6
\end{enumerate}

\end{document}

The order matters: \setcounter comes after the resumed environment begins and before its first \item. If you instead put \setcounter{enumi}{4} before \begin{enumerate}[resume], the resume option can restore the saved value of 2, making the next item number 3 rather than 5.

When to use start instead

If the list is not meant to resume a previous list, use start to specify its first item directly:

\begin{enumerate}[start=5]
  \item This item is numbered 5
  \item This item is numbered 6
\end{enumerate}

Use resume when you want to continue the numbering saved from a preceding list. Use start when you want a new list to begin at a known number. If you need both the resumed list’s settings and a different starting number, use resume and set the counter inside the environment, as in the worked example.

Check the counter for nested lists

The counter name changes with the nesting level:

List levelCounter
First enumerate levelenumi
Second levelenumii
Third levelenumiii
Fourth levelenumiv

For example, to change the next number in a nested second-level list, set enumii, not enumi. A counter for the wrong level will not control the label you are looking at.

Common mistakes

  • Setting the counter before a resumed list. The resume option may restore the saved value after your assignment. Set it after \begin{enumerate}[resume].
  • Setting the counter to the desired label itself. The counter records the previous item. For a next label of 5, set it to 4.
  • Using enumi in a nested list. Use the counter matching the list’s level, such as enumii for the second level.
  • Using resume when you want a fixed starting number. For a fresh list, start=5 is the direct choice.

These rules apply to the counter assignment and numbering. If you have customized labels or list settings, check that those settings also match the list you intend to continue.

References

  1. enumitem package documentation

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.