[Tex/LaTex] How to split a latex document using parts and chapters

numberingsectioning

I'm trying to make a PDF document, using the book class, divided like this:

  • Part: 1
    • Chapter 1
    • Chapter 2
    • Etc.
  • Part: 2
    • Chapter 1
    • Chapter 2
    • Etc.

How do I do this without the break in page numbers?

Best Answer

There is nothing fancy about creating such a document in LaTeX. You can use either the report or book document class (or another, like memoir). The example below uses the book document class.

enter image description here

\documentclass{book}
% Comment the following to have chapters numbered without interruption (numbering through parts)
\makeatletter\@addtoreset{chapter}{part}\makeatother%
\begin{document}
\tableofcontents
\part{First part}
\chapter{First chapter}
\chapter{Second chapter}
%...
\chapter{Last chapter}
\part{Second part}
\chapter{First chapter}
\chapter{Second chapter}
%...
\chapter{Last chapter}
\part{Last part}
\chapter{First chapter}
\chapter{Second chapter}
%...
\chapter{Last chapter}
\end{document}

The \tableofcontents shows the document structure. In order to have this structure accurately represent the document contents, you need to compile your code at least twice. Similar counter-resetting functionality is provided by the cnhgcntr package via \counterwithin*{chapter}{part}, although LaTeX provides its own \@addtoreset{<slave>}{<master>}. Here is some information on counter resetting: Master and slave counters

If you want to have the numbering continue through the parts (rather than having it numbered on a per-part basis), you can comment the 3rd line of code.

Related Question