19

I want to have a list like

(1) foo
   (1.1) foo
   (1.2) foo
(2) foo

I am using the package enumitem and

\begin{enumerate}[label=(\arabic*)]
   \item foo
\end{enumerate}

I know that i can append the parent label with label*=, but that leads to (1).1.

Has anybody an idea?

lockstep
  • 250,273
Jana
  • 2,254
  • 6
  • 21
  • 32

2 Answers2

16

This is how it can be done using enumitem:

enter image description here

\documentclass{article}
\usepackage{enumitem}% http://ctan.org/pkg/enumitem
\begin{document}
\begin{enumerate}[label=(\arabic*)]
  \item foo
  \begin{enumerate}[label=(\arabic{enumi}.\arabic*)]
    \item foo
    \item foo
  \end{enumerate}
  \item foo
\end{enumerate}
\end{document}​

You need to define the nested labels without the labelling format of the parent. The counters for the levels of enumerate are enumi, enumii, enumiii, while \arabic* refers to the current level counter.

Werner
  • 603,163
15

You can get this automatically, that is, forgetting to add [...] to each environment, with

\documentclass{article}
\usepackage{enumitem}

\newlist{jana}{enumerate}{3}
\setlist[jana,1]{label=(\arabic*)}
\setlist[jana,2]{label=(\arabic{janai}.\arabic*)}
\setlist[jana,3]{label=(\arabic{janai}.\arabic{janaii}.\arabic*)}

\begin{document}
\begin{jana}
\item A
\item A
  \begin{jana}
  \item B
  \item B
    \begin{jana}
    \item C
    \item C
    \end{jana}
  \end{jana}
\end{jana}
\end{document}

Choose a more sensible environment name, of course, changing also the occurrence of the string; for instance, if you choose myenum, you will say \arabic{myenumi}, \arabic{myenumii} and so on.

This provides up to three levels, add more levels with the same pattern if needed.

enter image description here

One can also change the format of the labels: for instance

\newlist{labelist}{enumerate}{5}
\setlist[labelist,1]{label=(\Alph*)}
\setlist[labelist,2]{label=(\Alph{labelisti}.\arabic*)}
\setlist[labelist,3]{label=(\Alph{labelisti}.\arabic{labelistii}.\arabic*)}
\setlist[labelist,4]{label=(\Alph{labelisti}.\arabic{labelistii}.\arabic{labelistiii}.\arabic*)}
\setlist[labelist,5]{label=(\Alph{labelisti}.\arabic{labelistii}.\arabic{labelistiii}.\arabic{labelistiv}.\arabic*)}

will define formats

(A)
  (A.1)
    (A.1.1)
      (A.1.1.1)
        (A.1.1.1.1)
egreg
  • 1,121,712