I want to add a subchapter
sectioning level, between chapter
and section
.
I use the \titleclass
command from titlesec
package.
According to titlesec
documentation, \titleclass{\subchapter}{straight}[\chapter]
should set the level of subchapter
to 1, and increase by 1 the levels below (section
of level 2, subsection
of level 3, etc).
However, the following example :
\documentclass{book}
\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage{titletoc}
\titleclass{\subchapter}{straight}[\chapter]
\newcounter{subchapter}
\titleformat{\subchapter}[block]{}{}{0pt}{}
\titlespacing{\subchapter}{1pc}{*4}{*2.3}
\titlecontents{subchapter}[1.5em]{}{}{\hspace*{-2.3em}}{\titlerule*[0.75pc]{.}\contentspage} %bad formatting, but only here to produce a content line in ToC
\begin{document}
\setcounter{tocdepth}{1}
\tableofcontents
\chapter{Chapter one}
\subchapter{Subchapter one}
\section{Section one}
\subsection{A subsection}
\section{Section two}
\end{document}
produces a ToC showing both subchapter
and section
, meaning that the level of section
is still equal to 1.
I also tried to add
\makeatletter
\def\toclevel@section{2}
\makeatother
as suggested in How to add an extra level of sections with headings below \subsubsection,
but it does nothing.
What am I missing?
Note that for now, I do not care about the formatting of the ToC and can manage this by myself later, I am only interested in the levels of the different sectioning titles.
Best Answer
The basic command
\titlecontents
is defined in thetitlesec
package as (see p.14):I your case the option
{〈numbered-entry-format〉}
is "empty" , that is, it seems to be undefined. Therefore, after compiling my output does not show any subchapter number:\contentslabel
or\thecontentslabel
print the subchapter number:\contentslabel{2.3em}
:\thecontentslabel\enspace
:Without defining the option
{〈numbered-entry-format〉}
but combining it with the macro\dottedcontents
, it also prints the subchapter number:Nevertheless, in all the cases there is a problem with the level; but the manual says (p. 10):
"If the chapter level is 0, then the subchapter one is 1; the levels below are increased by one (section is 2, subsection is 3, and so on)."
This issue is addressed in
GitHub
as \titleclass doesn't increase levels below and it stills open by Javier Bezos, the author of\titlsec
.The code: