2

I have the following code. How can we define series = A before the first \begin{enumerate}, so that all \begin{enumerate} would be uniform, that is, all equal to \begin{enumerate}[resume = A] ?

\documentclass[]{article}

\usepackage{enumitem}

\begin{document}

\begin{enumerate}[series=A]
\item this is an item.
\end{enumerate}

\vbox{
\begin{enumerate}[resume=A]
\item this is an item.
\end{enumerate}
}

\vbox{
\begin{enumerate}[resume=A]
\item this is an item.
\end{enumerate}
}

\end{document}

2 Answers 2

2

Just set enumerate to use resume.

\documentclass{article}
\usepackage{enumitem}

\setlist[enumerate]{resume}

\begin{document}

\begin{enumerate}
\item this is an item.
\end{enumerate}

\begin{enumerate}
\item this is an item.
\end{enumerate}

\begin{enumerate}
\item this is an item.
\end{enumerate}

\end{document}

I don't know what \vbox was for, so I removed it.

However, it would be better to use a different name.

\documentclass{article}
\usepackage{enumitem}

\newlist{globalenum}{enumerate}{1}
\setlist[globalenum]{label=\arabic*.,resume}

\begin{document}

\begin{globalenum}
\item this is an item.
\end{globalenum}

\begin{globalenum}
\item this is an item.
\end{globalenum}

\begin{globalenum}
\item this is an item.
\end{globalenum}

\end{document}

enter image description here

For the \vbox approach:

\documentclass{article}
\usepackage{enumitem}

\newcounter{outerenum}
\newenvironment{outerenum}
 {\par\addvspace{\topsep}\vbox\bgroup
  \begin{enumerate}[nosep]\setcounter{enumi}{\value{outerenum}}}
 {\end{enumerate}\egroup\addvspace{\topsep}\stepcounter{outerenum}}

\begin{document}

\begin{outerenum}
\item this is an item.
\begin{enumerate}
  \item Inner
  \item Inner
  \item Inner
\end{enumerate}
\end{outerenum}

\begin{outerenum}
\item this is an item.
\end{outerenum}

\begin{outerenum}
\item this is an item.
\end{outerenum}

\end{document}

enter image description here

9
  • Thanks a lot, @egreg! I need vbox to prevent page breaks, but, unfortunately, your solution appears to be incompatible with vbox, as the resulting numbering of the list is wrong when using vbox.
    – PaulS
    Jul 21, 2022 at 19:55
  • @PaulS Then you're using the wrong tools. Is there always a single item in the \vbox?
    – egreg
    Jul 21, 2022 at 20:04
  • Thanks, @egreg! Each \vbox has single outer item and multiple one-level nested items. Do you think there is a better solution than the \vbox one?
    – PaulS
    Jul 21, 2022 at 20:26
  • @PaulS Not for the \vbox, but for the whole thing. Yours is definitely an XY question. Please, open a new one, with more details. My guess is that you're preparing exercise sets, but that's not really relevant.
    – egreg
    Jul 21, 2022 at 20:29
  • 1
    @PaulS I added a possible approach for the \vbox. Maybe you can adapt it to you real problem.
    – egreg
    Jul 21, 2022 at 20:50
2

You can start the series before the enumerate:

\documentclass[]{article}

\usepackage{enumitem}

\begin{document}

\SetEnumitemKey{series=A}

\begin{enumerate}[resume=A]
\item this is an item.
\end{enumerate}

\vbox{
\begin{enumerate}[resume=A]
\item this is an item.
\end{enumerate}
}

\vbox{
\begin{enumerate}[resume=A]
\item this is an item.
\end{enumerate}
}

\end{document}
1
  • That is another great solution solution! Thanks a lot, @UlrikeFischer!
    – PaulS
    Jul 21, 2022 at 21:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .