2

I use the enumitem package to manipulate the appearance of my list. Because I want to keep the default enumerate list, I defined a new list edulist and configured it.

The list should be used in an environment edulistvar, which gives the user the ability to change the itemsep with an optional argument.

I want this list to resume until several points in my document are reached (see \exercise in the example below). Resetting the counter of the list I want to do with \restartlist<list-name>} which seems to exist exact for this reason:

enumitem documentation

Currently, with

\setlist[enumerate]{resume}

you can get a continuous numbering through a document.A new command has been added for restarting the counter in the middle of the document:

\restartlist{<list-name>}

It is based solely in the list name, not the list type, which means enumerate* as defined with the package option inline is not the same as enumerate, because its name is different.

Unfortunately, I don't get it work in the following MWE.

Code

\documentclass{scrartcl}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{enumitem}
\usepackage{xparse}

\DeclareDocumentEnvironment {edulistvar} { O{0pt} } {
  \begin{edulist}[itemsep=#1]
}{
  \end{edulist}
}

\DeclareDocumentCommand \exercise {  } {%
  \bigskip
  \textsf{\bfseries\Large Exercise}
  \medskip
  \par
  \restartlist{edulist}
}


\newlist{edulist}{enumerate}{1}

\setlist[edulist]{%
  label=\alph*),    
  format=\sffamily,
  resume=edulist,
  partopsep=0ex,
  topsep=0.5\baselineskip,
  parsep=\parskip,
}

\begin{document}

\exercise

Bli Bla Blub

\begin{edulist}
  \item One
  \item Two
  \item Three
\end{edulist}

Bli Bla Blub

\begin{edulist}
  \item One
  \item Two
  \item Three
\end{edulist}

\exercise

Bli Bla Blub

\begin{edulistvar}[\baselineskip]
  \item One
  \item Two
  \item Three
\end{edulistvar}

\end{document}

Document

Wrong enumeration

Any idea how to reset the counter of the list? Manually resetting it (\setcounter{edulisti}{0}) doesn't work, as well.

  • 1
    Removing resume=edulist in your setlist-declaration should help. – Hackbard_C Aug 15 '14 at 15:20
  • 3
    changing resume=edulist into resume should work – clemens Aug 15 '14 at 15:23
  • @Hackbard_C: For sure. But as I wrote, I want the list to resume until I restart it at several points (e. g. new sections). So removing resume=edulist isn't a solution. ;o) – dawu Aug 15 '14 at 15:29
  • Sorry, my fault. You would have to use \begin{edulist}[resume], which is not as comfortable as @cgnieder's answer, so use his recommendation! It should do the job as desired. – Hackbard_C Aug 15 '14 at 15:32
  • @Hackbard_C: No problem! @cgnieder: This works. But: As written in the documentation, resume works only locally. So when I want to put my list inside an environment (e. g. center), it won't work without resume=edulist. (For some reason, I didn't get the series of enumitem to work ...) I edit my example, one moment, please. – dawu Aug 15 '14 at 15:35
2

I'm not sure I understand your question, either, but it seems straightforward to modify the MWE to do what you appear to want, if I've understood correctly, without the need for intervention by the end user:

\documentclass{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{enumitem}
\usepackage{xparse}

\DeclareDocumentEnvironment {edulistvar} { O{0pt} } {
  \begin{edulist}[itemsep=#1, resume=edulist]
}{
  \end{edulist}
}

\DeclareDocumentCommand \exercise {  } {%
  \bigskip
  \textsf{\bfseries\Large Exercise}
  \medskip
  \par
  \restartlist{edulist}
}


\newlist{edulist}{enumerate}{1}

\setlist[edulist]{%
  label=\alph*),
  format=\sffamily,
  partopsep=0ex,
  topsep=0.5\baselineskip,
  parsep=\parskip,
  resume}

\begin{document}

\exercise

Bli Bla Blub

\begin{edulist}
  \item One
  \item Two
  \item Three
\end{edulist}

Bli Bla Blub

\begin{edulist}
  \item One
  \item Two
  \item Three
\end{edulist}

\exercise

Bli Bla Blub

\begin{edulistvar}[\baselineskip]
  \item One
  \item Two
  \item Three
\end{edulistvar}

\begin{edulistvar}[\baselineskip]
  \item One
  \item Two
  \item Three
\end{edulistvar}

\end{document}

resume and restart

  • First, I thought it works. But if you add one more \begin{edulistvar} ... \end{edulistvar} at the end, the list will be reset, even without a new call of \exercise. It should continue. That's why you need resume=edulist (or to work with series, which I did't get to work inside \setlist). – dawu Aug 16 '14 at 16:54
  • @dawu Oops. You are right. I should have tested that. I've corrected the code and extended the MWE accordingly. – cfr Aug 17 '14 at 0:11
5

Not sure I understood what your problem consists in, exactly, but series work, even inside another environment:

\documentclass{scrartcl}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{enumitem}

\begin{document}

\begin{center}
    \begin{enumerate}[label=\alph*), series=edu]
    \item One
    \item Two
    \item Three
  \end{enumerate}
\end{center}

Bli Bla Blub.

\begin{center}
    \begin{enumerate}[resume*=edu]
    \item One
    \item Two
    \item Three
  \end{enumerate}
\end{center}

Blibli Blabla Blubblub.

\begin{center}
    \begin{enumerate}[resume*=edu, start = 1]
    \item One
    \item Two
    \item Three
  \end{enumerate}
\end{center}

\end{document} 

enter image description here

  • That's right. In this case, series works. But the user shouldn't need to take care of this. I am sorry that my question wasn't clear enought. I wanted to keep the situation as simple as possible. I hope that the problems now becomes clearer. – dawu Aug 15 '14 at 21:49

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.