4

I define own list, for example mylist. For some reason I like to name it with series, for example as series=ML for resuming purposes: resume=ML. Adding this locally, for example as in the following MWE, this works as expected:

\documentclass{article}
\usepackage{enumitem}
\newlist{mylist}{enumerate}{2}
\setlist[mylist,1]{leftmargin=*,label=\arabic*.}
\setlist[mylist,2]{nosep, leftmargin=*, label=(\alph*)}

\begin{document}
    \begin{minipage}{\linewidth} % simulate new environment 
                                 % where I like incorporate mylist with
                                 % \mylist ... \endmylist
\begin{mylist}[series=ML, resume=ML]
   \item    example A
   \begin{mylist}
       \item    sub example A1
       \item    sub example A2
    \end{mylist}
\end{mylist}
    \end{minipage}

    \bigskip
    \begin{minipage}{\linewidth}
\begin{mylist}[series=ML, resume=ML]
   \item    example B
   \begin{mylist}
       \item    sub example B1
       \item    sub example B2
    \end{mylist}
\end{mylist}
    \end{minipage}
\end{document}

enter image description here

However, if I move series=ML, resume=ML from option of mylist to \setlist like:

\documentclass{article}
\usepackage{enumitem}
\newlist{mylist}{enumerate}{2}
\setlist[mylist,1]{leftmargin=*,label=\arabic*.,
                   series=ML, resume=ML  % <---
                   }
\setlist[mylist,2]{nosep, leftmargin=*, label=(\alph*)}

\begin{document}
    \begin{minipage}{\linewidth}
\begin{mylist}
   \item    example A
   \begin{mylist}
       \item    sub example A1
       \item    sub example A2
    \end{mylist}
\end{mylist}
    \end{minipage}

    \bigskip
    \begin{minipage}{\linewidth}
\begin{mylist}
   \item    example B
   \begin{mylist}
       \item    sub example B1
       \item    sub example B2
    \end{mylist}
\end{mylist}
    \end{minipage}
\end{document}

it trow the error:

! Package enumitem Error: Misplaced key 'series'.

Interestingly, if I after than forced compilation, I get desired result.

In enumitem documentation (I use version 3.9 from 2019/06/20) is nowhere described that series in \setlist is not allowed, but all examples of its use are as it is shown in the first MWE.

Do anyone know, how to convinced enumitem that will work in second MWE without error?

Edit: After correcting errors in my MWE (added missed \begin{minipage} and \end{minipage) accidental I discover that removing series from list definition in the second example gives desired result:

\usepackage{enumitem}
\newlist{mylist}{enumerate}{2}
\setlist[mylist,1]{resume=ML  % <---
                   leftmargin=*, label=\arabic*, after=\vspace*{-0.5\baselineskip}
                   }
\setlist[mylist,2]{nosep, leftmargin=*, label=(\alph*)}

Zarko
  • 296,517
  • 2
    To me this looks more like a feature request to the package author than a question for this site. –  Nov 26 '19 at 07:07
  • @Schrödinger'scat , you may be right. I wasn't sure if I was doing anything wrong. At the same time, I hoped that anyone here knew of a solution. I wanted to write to the author, but the "http://www.texnia.com/enumitem.html" page didn't seem active for a long time. – Zarko Nov 26 '19 at 07:32
  • Are you perhaps looking for an always resumed list? If so, then perhaps Define a List that is Always Resumed is a duplicate of this. – Peter Grill Nov 26 '19 at 08:07
  • @PeterGrill, thank you very much for the link. I will test this solution ASAP in my target application: defining new environments containing mylist activated by \mylist and terminated with \endmylist. On the first sight I don't see, that the question is duplicate, but I will see after my test. (hopefuly done today) – Zarko Nov 26 '19 at 10:30
  • 1
    If you type h at the error prompt, then it will tell you 'series' and 'resume*' must be used in the optional argument of lists, and there is a specific macro to test this condition in the code, so it's definitely not supported, for some (probably good) reason. I couldn't find out what it is, though, sorry. Perhaps ask for the author's view on this: https://github.com/jbezos/enumitem/issues – Phelype Oleinik Nov 26 '19 at 11:39
  • @PhelypeOleinik, you ae right! I didn't check this before, however in the package documentation are examples, where resume is used in \setlist, see 8.2 Restarting enumerates, page 19 : \setlist[enumerate]{resume}. I report my wish to package author on http://www.texnia.com/contact.html. Now I will look on github. – Zarko Nov 26 '19 at 12:47
  • @Zarko That's resume, which (I think) is allowed, different from resume*. And indeed, the documentation points you to texnia.com, so that's probably the right address. – Phelype Oleinik Nov 26 '19 at 12:53
  • @Zarko: Sorry, I wasn't clear. Define a List that is Always Resumed is not an exact duplicate of the question asked here, but I thought perhaps that was what you were trying to achive. – Peter Grill Nov 26 '19 at 17:19
  • @PeterGrill, it is intriguing. I will make test late evening (GMT), when all disturbance around me will go to sleep :-) – Zarko Nov 26 '19 at 17:27
  • @PeterGrill, I test proposed solutions on your questions. Unfortunately I didn't succeed to adopt any of them to my needs (use \mylist ... \endmylist in definition of the new environment). – Zarko Nov 27 '19 at 18:30
  • @Zarko: What is your the actual result that you want to be able to achive? With the resutls at the link I provided and the follow-up question, you define a list type that you want always resumed and then you don't need to specify it to be resumed when you use it. – Peter Grill Nov 27 '19 at 19:35

1 Answers1

3

Just adding \setlist[mylist]{resume} at the initial declaration works fine. Series is not necessary here.

Sample output

\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}
\newlist{mylist}{enumerate}{2}
\setlist[mylist]{resume}% <=================
\setlist[mylist,1]{leftmargin=*,label=\arabic*.}
\setlist[mylist,2]{nosep, leftmargin=*, label=(\alph*)}
\begin{document}
\lipsum[1][1-3]
    \begin{mylist}
        \item    example A
        \begin{mylist}
            \item    sub example A1
            \item    sub example A2
        \end{mylist}
    \end{mylist}
\lipsum[1-2][1-3]
    \begin{mylist}
        \item    example B
            \begin{mylist}
                \item    sub example B1
                \item    sub example B2
            \end{mylist} 
        \lipsum[1][1-3]
        \begin{mylist}
            \item    sub example B1
            \item    sub example B2
        \end{mylist}
    \end{mylist} 
\end{document}
Andrew Swann
  • 95,762
  • Thank you for your answer. As you can see in addendum to my question, I already discover this. Now I wonder, why I didn't close a question after this :-(, probably I decided then to wait if some new (better) solution will appear. Anyway, thank you very much again and +1 for the your answer! – Zarko May 10 '20 at 08:36