I'm writing a book and I wanted to add sub-chapters like :
Chapter 1
Chapter 2
Chapter 3.1
Chapter 3.2
Chapter 3.3
Chapter 4
I've quite found an answer there but it's not working the way I wanted. Is someone having an idea ?
I'm writing a book and I wanted to add sub-chapters like :
Chapter 1
Chapter 2
Chapter 3.1
Chapter 3.2
Chapter 3.3
Chapter 4
I've quite found an answer there but it's not working the way I wanted. Is someone having an idea ?
A manual setup, not very convenient, by storing the chapter number and restoring it later on.
(In this example, the chapter number width in the ToC should be increased, e.g. with \addtolength{\cftchapnumwidth}{5pt} from tocloft package)
\documentclass{book}
\newcounter{subchapterusage}
\makeatletter
\let\latex@@thechapter\thechapter
\@addtoreset{chapter}{subchapterusage}% Reset the chapter counter if subchapterusage is stepped
\newcommand{\PrepareForSubchapterUsage}{%
\xdef\chapvalue{\the\numexpr\number\value{chapter}+1}
\stepcounter{subchapterusage}%
\renewcommand{\thechapter}{\chapvalue.\latex@@thechapter}
}
\newcommand{\RestoreToChapterUsage}{%
\setcounter{chapter}{\chapvalue}
\renewcommand{\thechapter}{\latex@@thechapter}
}
\makeatother
\usepackage{hyperref}
\begin{document}
\tableofcontents
\chapter{Foo}
\chapter{Foobar}
\PrepareForSubchapterUsage
\chapter{Intermediate Chapter with Strange Counting}
\section{Foo section}
\chapter{Another intermediate Chapter with Strange Counting}
\chapter{Yet another intermediate Chapter with Strange Counting}
\RestoreToChapterUsage
\chapter{Foo continued}
\end{document}
subchapters actually. Happy TeXing anyway!
–
Jun 11 '16 at 17:51
\section??? A\sectionis asubchapter and if the section counter is correctly set up, it's3.1,3.2,3.3etc. Or redefine thechaptercounter – Jun 11 '16 at 15:23