7

How does one include chapter number in the enumerate list number? For example if I have list in chapter 3, I would like to have the following list (independent of section in which it occurs). The numbering should continue across different enumerate lists in the same chapter.

Example:

Chapter 3
Section 1
Lorem ipsum dolor sit amet, consectetur adipiscing elit:
3.1 Pellentesque
3.2 a aliquam
3.3 Elis

Section 2
Lorem ipsum dolor sit amet, consectetur adipiscing elit:
3.4 Pellentesque
3.5 a aliquam
3.6 Elis

Chapter 4
Section 1
Lorem ipsum dolor sit amet, consectetur adipiscing elit:
4.1 Pellentesque
4.2 a aliquam

2
  • what if you have two enumerate lists in chapter 3? Should both of them start with 3.1 ?
    – ebosi
    Jan 16, 2017 at 10:44
  • of yes, of course there should be continuation in list numbers across different enumerate lists in the same chapter.
    – Lanc
    Jan 16, 2017 at 10:45

1 Answer 1

4

Using the enumitem and etoolbox package, the important parts are:

 % include the chapter number
 \setlist[enumerate]{label=\thechapter.\arabic{*},resume}

 % restart the enumerate list every chapter
 \preto\chapter{%
   \restartlist{enumerate}%
}

Here's a complete MWE:

% arara: pdflatex
 \documentclass{report}

\usepackage{enumitem}
\usepackage{etoolbox}

 % include the chapter number
 \setlist[enumerate]{label=\thechapter.\arabic{*},resume}

 % restart the enumerate list every chapter
 \preto\chapter{%
   \restartlist{enumerate}%
}

 \begin{document}

    \chapter{one}
    \begin{enumerate}
        \item \label{testref} first
        \item second and cross reference: \ref{testref}
    \end{enumerate}
    more
    \begin{enumerate}
        \item third
        \item fourth
    \end{enumerate}

    \chapter{two}
    \begin{enumerate}
        \item \label{secondref} first
        \item second and cross reference: \ref{secondref}
    \end{enumerate}
    more
    \begin{enumerate}
        \item third
        \item fourth
    \end{enumerate}
    \end{document}
0

You must log in to answer this question.

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