5

When having a list defined for one's own environment like (I need levels deeper than the standard 4):

\setlistdepth{12}
\newlist{MyEnumerate}{enumerate}{12}
\setlist[MyEnumerate,1]{label=\arabic*.}
...

this all works good and one can also overrule the label.

However when trying to set the start counter this does not work in the new list. i.e.

\begin{enumerate}[label=\alph*]
\setcounter{enumi}{3}
\item an item
...

works but the following doesn't:

\begin{MyEnumerate}[label=\alph*]
\setcounter{enumi}{3}
\item an item

So the question:

  • how can I set the counter for MyEnumerate and also for the higher levels ?

The complete MWE:

documentclass[twoside]{book}

\RequirePackage{enumitem}

\setlistdepth{12}
\newlist{MyEnumerate}{enumerate}{12}
\setlist[MyEnumerate,1]{label=\arabic*.}
\setlist[MyEnumerate,2]{label=(\alph*)}
\setlist[MyEnumerate,3]{label=\roman*.}
\setlist[MyEnumerate,4]{label=\Alph*.}
\setlist[MyEnumerate,5]{label=\arabic*.}
\setlist[MyEnumerate,6]{label=(\alph*)}
\setlist[MyEnumerate,7]{label=\roman*.}
\setlist[MyEnumerate,8]{label=\Alph*.}
\setlist[MyEnumerate,9]{label=\arabic*.}
\setlist[MyEnumerate,10]{label=(\alph*)}
\setlist[MyEnumerate,11]{label=\roman*.}
\begin{document}

A standard list:

================
\begin{enumerate}[label=\alph*]
\setcounter{enumi}{3}
\item an item
\begin{enumerate}[label=\alph*]
\setcounter{enumii}{13}
\item an item
\begin{enumerate}[label=\alph*]
\setcounter{enumiii}{23}
\item an item
\begin{enumerate}[label=\alph*]
\setcounter{enumiii}{23}
\item an item
\item an item
\item an item
\end{enumerate}
\item an item
\item an item
\end{enumerate}
\item an item
\item an item
\end{enumerate}
\item an item
\item an item
\end{enumerate}

================

A modified list:

================
\begin{MyEnumerate}[label=\alph*]
\setcounter{enumi}{3}
\item an item
\begin{MyEnumerate}[label=\alph*]
\setcounter{enumii}{13}
\item an item
\begin{MyEnumerate}[label=\alph*]
\setcounter{enumiii}{23}
\item an item
\item an item
\item an item
\end{MyEnumerate}
\item an item
\item an item
\end{MyEnumerate}
\item an item
\item an item
\end{MyEnumerate}

================

\end{document}

And the resulting image:

enter image description here

4
  • the names of the counters are e.g. \setcounter{MyEnumerateii}{6}, but why don't you simply use the start key? Commented Apr 28, 2021 at 15:02
  • What do you mean by the start key? can you give an example? Commented Apr 28, 2021 at 15:19
  • Alan already enlightent me. @UlrikeFischer thanks for your comment. Commented Apr 28, 2021 at 15:29
  • 1
    \begin{MyEnumerate}[label=\alph*,start=3] Commented Apr 28, 2021 at 15:29

1 Answer 1

6

The counters for new lists are named using the list name. From the documentation (p.17):

If ⟨type⟩ is enumerate, a set of counters with names ⟨name⟩i, ⟨name⟩ii, ⟨name⟩iii, ⟨name⟩iv, etc. (depending on ⟨max-depth⟩) is defined.

So in your case, the counters are MyEnumeratei, MyEnumerateii, etc.

But as Ulrike mentions in the comments, it's usually not necessary to reference the counters directly, so instead of \setcounter{MyEnumeratei}{6) you can simply use \begin{MyEnumerate}[start=6] instead. I've redone two of your example lists using this syntax. This syntax means that you don't need to know which level you are at to set the counter correctly.

\documentclass[twoside]{book}

\RequirePackage{enumitem}

\setlistdepth{12}
\newlist{MyEnumerate}{enumerate}{12}
\setlist[MyEnumerate,1]{label=\arabic*.}
\setlist[MyEnumerate,2]{label=(\alph*)}
\setlist[MyEnumerate,3]{label=\roman*.}
\setlist[MyEnumerate,4]{label=\Alph*.}
\setlist[MyEnumerate,5]{label=\arabic*.}
\setlist[MyEnumerate,6]{label=(\alph*)}
\setlist[MyEnumerate,7]{label=\roman*.}
\setlist[MyEnumerate,8]{label=\Alph*.}
\setlist[MyEnumerate,9]{label=\arabic*.}
\setlist[MyEnumerate,10]{label=(\alph*)}
\setlist[MyEnumerate,11]{label=\roman*.}
\begin{document}



================

A modified list:

================
\begin{MyEnumerate}[label=\alph*]
\setcounter{MyEnumeratei}{3}
\item an item
\begin{MyEnumerate}[label=\alph*,start=13]
\item an item
\begin{MyEnumerate}[label=\alph*,start=23]
\item an item
\item an item
\item an item
\end{MyEnumerate}
\item an item
\item an item
\end{MyEnumerate}
\item an item
\item an item
\end{MyEnumerate}

================

\end{document}
3
  • This does work in a fixed environment (also for e.g. level 7 with MyEnumeratevii, though in the environment I have I currently don't know the level I'm in. Is theer an automatic way possible? Commented Apr 28, 2021 at 15:21
  • 1
    @albert Yes, as mentioned in the comments, use the start= key. I'll update my example code. Commented Apr 28, 2021 at 15:22
  • Wow that easy, thanks. Commented Apr 28, 2021 at 15:28

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.