4

I have an article document. In this document I have sections and subsections. In a subsection there are nested 'description' lists. I want that items of this description have numbers which use the number of the subsection and nested case the number of the parent description.

4.1. Subsection
  4.1.1. Item 1 of Description 1
    4.1.1.1. Item 1 of Description 2
    4.1.1.2. Item 2 of Description 2
  4.1.2. Item 2 of Description 1

How I can achieve that?

lockstep
  • 250,273
user14416
  • 838

2 Answers2

4

I have no idea why you would do this using a description environment and not an enumerate (as in the other answer), but who am I to question? :)

In the code below, I've borrowed some ideas from Enumerated description list and have introduced a couple of new counters descriptcounti and descriptcountii; if you plan to have deeper lists, just keep going (descriptcountiii, etc)

screenshot

\documentclass{article}

\usepackage{enumitem}

% first level
\newcounter{descriptcounti}
\setlist[description]{%
  before={\setcounter{descriptcounti}{0}},%
  ,font=\bfseries\refstepcounter{descriptcounti}\thesubsection.\thedescriptcounti~}

% second level
\newcounter{descriptcountii}
\setlist[description,2]{%
  before={\setcounter{descriptcountii}{0}},%
  ,font=\bfseries\refstepcounter{descriptcountii}\thesubsection.\thedescriptcounti.\thedescriptcountii~}
\begin{document}


\setcounter{section}{4} % just for demonstration
\subsection{Sub section}
\begin{description}
    \item item one
    \item item two
    \item item three
    \begin{description}
        \item item one
        \item item two
        \item item three
    \end{description}
\end{description}

\end{document}

Following the comments, you can easily apply this to a custom description, say mydesc, by using \newlist

\documentclass{article}

\usepackage{enumitem}

\newlist{mydesc}{description}{5}

% first level
\newcounter{descriptcounti}
\setlist[mydesc]{%
  before={\setcounter{descriptcounti}{0}},%
  ,font=\bfseries\refstepcounter{descriptcounti}\thesubsection.\thedescriptcounti~}

% second level
\newcounter{descriptcountii}
\setlist[mydesc,2]{%
  before={\setcounter{descriptcountii}{0}},%
  ,font=\bfseries\refstepcounter{descriptcountii}\thesubsection.\thedescriptcounti.\thedescriptcountii~}
\begin{document}


\setcounter{section}{4} % just for demonstration
\subsection{Sub section}
\begin{mydesc}
    \item item one
    \item item two
    \item item three
    \begin{mydesc}
        \item item one
        \item item two
        \item item three
    \end{mydesc}
\end{mydesc}

\end{document}
cmhughes
  • 100,947
1

How does this work for you?

\documentclass{article}
\begin{document}
\renewcommand{\labelenumi}{\bfseries\arabic{enumi}} 
\renewcommand{\labelenumii}{\bfseries\arabic{enumi}.%
                            \arabic{enumii}} 
\renewcommand{\labelenumiii}{\bfseries\arabic{enumi}.%
                             \arabic{enumii}.\arabic{enumiii}} 
\renewcommand{\labelenumiv}{\bfseries\arabic{enumi}.%
                            \arabic{enumii}.\arabic{enumiii}.%
                            \arabic{enumiv}}

  \begin{enumerate}
  \item Starting at the first level
        \begin{enumerate}
          \item Now we're at the second level
          \item This is the second item on the second level
                \begin{enumerate}
                  \item Now we're three levels deep.
                  \item Let's go deeper with an itemized list.  
                        Let's list fruits.
                        \begin{enumerate}
                          \item Bananas
                          \item Oranges
                          \item Apples
                        \end{enumerate}
                \end{enumerate}
          \item We're back to the second level.
        \end{enumerate}
  \item Back to the first level
  \end{enumerate}

\end{document}

enter image description here

A.Ellett
  • 50,533