3

I was wondering where this is possible in LaTeX?

Chapter 2

Part 1

Section 2.1.1

Section 2.1.2

Subsection 2.1.2.1

Subsection 2.1.2.2

Part 2

Section 2.2.1

Section 2.2.2

Subsection 2.2.2.1

Subsection 2.2.2.2

3
  • 1
    Why don't you just use the \sections normally? They will all get the correct numbering as you want. If not, why don't you simply use two \chapters? Or even a third option, you can used \part where a \chapter can be nested and then another \part for a different one. Commented Oct 26, 2013 at 2:10
  • @kan I need to labelled parts, sections and sub sections the way I have mentioned
    – Harry
    Commented Oct 26, 2013 at 3:12
  • You seem to want an extra sectioning level between chapter and section. I, personally, would just us \section for the parts and \subsection for the next level, etc. An alternative is to make two chapters with the same title, except "(part 1}" added to the first and "(part 2)" to the second. Adding an official level between chapter and section would be problematic in chapters that didn't have parts. Sections would be numbered like 2.0.1, 2.0.2, etc.
    – Dan
    Commented Oct 26, 2013 at 3:58

2 Answers 2

3

I’d simply swap parts and chapters here. So you use \part for your chapters and \chapter for your parts (of a chapter).

Swapping the headings “Part” and “Chapter” which are stored in \partname and \chaptername respectively can be done with

\begingroup
  \let\swap\partname
  \global\let\partname\chaptername
  \global\let\chaptername\swap
\endgroup

Then we simply need to set up the correct numbering scheme.

First, you want your chapters (LaTeX’ parts) to be arabic:

\renewcommand*{\thepart}{\arabic{part}}

We don’t need to change anything about the chapters (your parts).

Then we only need to setup \thesection so that they include the numbers from the parts and chapters (yours and LaTeX’).


We could also swap \chapter and \part but this won’t work successfully because \chapter (and maybe \part, too) is used in other macros (like \tableofcontents) to create a heading.

It is however possible to use \Chapter and \Part:

\let\Chapter\part
\let\Part\chapter

To avoid confusion I named the chapters and parts in German so we can properly observe the swap of \chaptername and \partname.

Code

\documentclass{book}
\begingroup
  \let\swap\partname
  \global\let\partname\chaptername
  \global\let\chaptername\swap
\endgroup
\renewcommand*{\thepart}{\arabic{part}}
\renewcommand*{\thesection}{\thepart.\thechapter.\arabic{section}}
\begin{document}
\tableofcontents
\stepcounter{part}% let's start with chapter 2 as in your example

\part{Kapitel 2}
\chapter{Teil 1}
\section{Section 2.1.1}
\section{Section 2.1.2}
\subsection{Subsection 2.1.2.1}
\subsection{Subsection 2.1.2.2}
\chapter{Teil 2}
\section{Section 2.2.1}
\section{Section 2.2.2}
\subsection{Subsection 2.2.2.1}
\subsection{Subsection 2.2.2.2}
\end{document}

Output

enter image description hereenter image description here

1
  • And such an answer cries for Section "Tricky Answers" in the TeX - LaTeX Weekly Newsletter. :-) Commented Oct 26, 2013 at 4:44
2

You could demote some sectional units and insert \part to replace \section:

enter image description here

\documentclass{book}

\let\part\section% Demote \part
\let\section\subsection% Demote \section
\let\subsection\subsubsection% Demote \subsection
\let\subsubsection\paragraph% Demote \subsubsection
\let\paragraph\subparagraph% Demote \paragraph
%\let\subparagraph\relax%

\begin{document}

\tableofcontents

\chapter{First chapter}
\part{First part}
\section{First section}
\section{Second section}
\subsection{First subsection}
\subsection{Second subsection}
\part{Second part}
\section{First section}
\section{Second section}
\subsection{First subsection}
\subsection{Second subsection}

\chapter{Second chapter}
\part{First part}
\section{First section}
\section{Second section}
\subsection{First subsection}
\subsection{Second subsection}
\part{Second part}
\section{First section}
\section{Second section}
\subsection{First subsection}
\subsection{Second subsection}

\end{document}

Formatting of the respective components in terms of their display/run-in setting can be achieved via other packages (like secsty or titlesec, for example).

You must log in to answer this question.

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