33

I would like to create a five level deep list using the enumitem package. I found this suggestion on stackoverflow and implemented it as follows

\documentclass[twoside,a4paper,12pt]{report}
\usepackage{enumitem}
\setlistdepth{9}

\begin{document}
\begin{enumerate}
\item 1st level
    \begin{enumerate}
    \item 2nd level
        \begin{enumerate}
        \item 3rd level
            \begin{enumerate}
            \item 4th level
                \begin{enumerate}
                \item 5th level
                \end{enumerate}
            \end{enumerate}
        \end{enumerate}
    \end{enumerate}
\end{enumerate}
\end{document}

But still get the error too deeply nested. Using itemize environments is unfortunately not an option.

In the link provided it is mentioned that the \setlistdepth{} only works from a certain version on, how do I find out which version I am using?

1
  • To see which version of a package you are using it is best to look in the .log file and search for the particular package. Jan 17, 2012 at 20:48

4 Answers 4

35

LaTeX has a limit of depth of lists to save counters. However, you can clone the existing enumerate environment and increase the depth with the enumitem pacakge:

\newlist{myEnumerate}{enumerate}{6}

You then need to use \setlist to set up the counters for each depth, and use \setlistdepth{} to increase the default depth limit of 6.

enter image description here

Note:

  • Without the use of \setlistdepth{9} a depth larger than 6 will result in:

    LaTeX Error: Too deeply nested.

  • Have tested this to a depth of 15 and seems to work fine, but if you have a high list depth, you really need to reconsider the formatting of the information that you are trying to convey.

Code:

\documentclass{article}
\usepackage{enumitem}
\setlistdepth{9}

\newlist{myEnumerate}{enumerate}{9}
\setlist[myEnumerate,1]{label=(\arabic*)}
\setlist[myEnumerate,2]{label=(\Roman*)}
\setlist[myEnumerate,3]{label=(\Alph*)}
\setlist[myEnumerate,4]{label=(\roman*)}
\setlist[myEnumerate,5]{label=(\alph*)}
\setlist[myEnumerate,6]{label=(\arabic*)}
\setlist[myEnumerate,7]{label=(\Roman*)}
\setlist[myEnumerate,8]{label=(\Alph*)}
\setlist[myEnumerate,9]{label=(\roman*)}

\begin{document}
\begin{myEnumerate}
\item 1st level
    \begin{myEnumerate}
    \item 2nd level
        \begin{myEnumerate}
        \item 3rd level
            \begin{myEnumerate}
            \item 4th level
                \begin{myEnumerate}
                \item 5th level
                    \begin{myEnumerate}
                    \item 6th level
                        \begin{myEnumerate}
                        \item 7th level
                            \begin{myEnumerate}
                            \item 8th level
                                \begin{myEnumerate}
                                \item 9th level
                                \end{myEnumerate}
                            \end{myEnumerate}
                        \end{myEnumerate}
                    \end{myEnumerate}
                \end{myEnumerate}
            \end{myEnumerate}
        \end{myEnumerate}
    \end{myEnumerate}
\end{myEnumerate}
\end{document}
9
  • that is sweet! However, I still do not fully understand it. Changing the list definition and initialization to \newlist{myEnumerate}{enumerate}{9} \setlist[myEnumerate,1,2,3,4,5,6,7,8,9]{label=(\arabic*)} will take me to the 7th(!!) level before throwing the error. Why is that?
    – D.Roepo
    Jan 17, 2012 at 21:01
  • Have updated solution to a higher limit. Jan 17, 2012 at 21:56
  • What do you mean it still doesn't? I have shown the above to work to a depth of 9 and tested it to a depth of 15? How much deeper do you want it to go? Jan 18, 2012 at 16:18
  • no, no. It does work, I forgot to \setlistdepth{} b/c I didn't see it have any effect. And I just want to go to depth five, where it indeed is not needed
    – D.Roepo
    Jan 18, 2012 at 16:27
  • This is a wonderful solution. However, references to labels do not include the complete nested location. Is this implementable?
    – beethree
    Aug 5, 2013 at 3:20
23

I realize this answer doesn't satisfy the requirement of not using itemize, but I am adding it for completeness.

Since the 5-level depth constraint also applies to itemize environments, here is an example (using the same method proposed in Peter's answer) that increases the depth for the default itemize environment:

\usepackage{enumitem}
\setlistdepth{20}
\renewlist{itemize}{itemize}{20}

% initially, use dots for all levels
\setlist[itemize]{label=$\cdot$}

% customize the first 3 levels
\setlist[itemize,1]{label=\textbullet}
\setlist[itemize,2]{label=--}
\setlist[itemize,3]{label=*}
0

There is a simple, but unconventional way if you "just" need that little extra fifth level. Does not work when you need six or more levels and needs some manual hacking.

You can use

\item []

to truncate the enumeration symbol and add it to you text manually.

\begin{enumerate}
    \item first level.
    \begin{enumerate}
        \item second level.
        \item Lorem ipsum dolor sit amet.
        \begin{enumerate}
            \item third level.
            \item Lorem ipsum dolor sit amet.
            \begin{enumerate}
                \item fourth level.
                \item Lorem ipsum dolor sit amet.
                %fake \begin{enumerate}
                    \item [] 1. fake fifth level.
                    \item [] 2. Lorem ipsum dolor sit amet.
                    \item [] 3. Lorem ipsum dolor sit amet.
                %fake \end{enumerate}
                \item Lorem ipsum dolor sit amet.
            \end{enumerate}
            \item Lorem ipsum dolor sit amet.
        \end{enumerate}
        \item Lorem ipsum dolor sit amet.
    \end{enumerate}
\end{enumerate}

enter image description here

1
  • Though it may work, I suggest sticking to the prepared and provided standard way, as outlined in other answers, here.
    – MS-SPO
    Sep 11, 2021 at 9:01
0

The hack that I've been using to get that fifth level of nesting is to use itemize inside of enumerate. It's the simplest, out-of-the-box way if you don't absolutely need numbering on the innermost layer.

You must log in to answer this question.

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