[Tex/LaTex] Using index on parent enumeration

#enumerate

I want to use index of parent enumeration in child enumeration.
For example,

\begin{enumerate}
\item the 
\item quick 
\begin {enumerate}
\item brown
\item fox 
\end {enumerate}
\item jumps 
\begin {enumerate}
\item over
\item the
\begin {enumerate}
\item lazy
\end {enumerate}
\end {enumerate}
\item dog
\end{enumerate}

will print:

(1) the

(2) quick

(2.1) brown

(2.2) fox

(3) jumps

(3.1) over

(3.2) the

(3.2.1) lazy

(4) dog

Actually I found a formatting to use (num) stuff:

[label=(\arabic*)]

However, I have no idea to use parent's index.

Best Answer

With enumitem:

\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=(\arabic*)]
\item the
\item quick
\begin {enumerate}[label=(\arabic{enumi}.\arabic*)]
\item brown
\item fox
\end {enumerate}
\item jumps
\begin {enumerate}[label=(\arabic{enumi}.\arabic*)]
\item over
\item the
\begin {enumerate}[label=(\arabic{enumi}.\arabic{enumii}.\arabic*)]
\item lazy
\end {enumerate}
\end {enumerate}
\item dog
\end{enumerate}

\end{document}

enter image description here

There is also label* which will append the parent's label, but as you want parenthesis here, it may not be suitable.

If you want labels to be flush to the left margin, add this in the preamble:

\setlist[enumerate,1,2,3]{wide}

enter image description here

Related Question