В шаблоне класса kaobook мне удалось добавить подподраздел; но что мне нужно сделать, чтобы отобразить подподразделы в оглавлении на стороне kaobook?

В шаблоне класса kaobook мне удалось добавить подподраздел; но что мне нужно сделать, чтобы отобразить подподразделы в оглавлении на стороне kaobook?
%\setcounter{secnumdepth}{\kao@secnumdepth} % Set section numbering 
%depth
\setcounter{secnumdepth}{3}
\counterwithin*{sidenote}{chapter} % Uncomment to reset the sidenote counter at each chapter
%\counterwithout{sidenote}{chapter} % Uncomment to have one sidenote counter for the whole document

боковое оглавление

решение1

Класс kaobookне определяет записи для подподразделов при использовании поля ToC. Для этого требуется переопределить довольно длинную \magintocкоманду.

(1) \margintocвставит локальное оглавление на поля. Вы можете переместить его вверх или вниз с помощью необязательного параметра. Например, \margintoc[-0.6cm]чтобы выровнять с текстом

(2)Чтобы подавить подподразделы конкретного локального ToC, используйте

\etocsetnexttocdepth{2}
\setcounter{margintocdepth}{2}% 
\margintoc

с

% !TeX TS-program = pdflatex

\documentclass[
    secnumdepth=3, % <<<<<<<<<<<<<<<<<<<<<<<<< added for subsubsections
]{kaobook}

\usepackage{kantlipsum}% ONLY for dummy text

%%*********************************************************** added <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
\setcounter{margintocdepth}{3}% 3 for subsubsections; 2 for subsection
\etocstandarddisplaystyle % "toc display" as if etoc was not loaded
\etocstandardlines % "toc lines as if etoc was not loaded
%%%%% Command to print a table of contents in the margin
\RenewDocumentCommand{\margintoc}{O{\mtocshift}}{ % The first parameter is the vertical offset; by default it is \mtocshift
    \begingroup%
    \etocsetlevel{section}{6}
    \etocsetlevel{subsection}{6}
    \etocsetlevel{mtocsection}{1}
    \etocsetlevel{mtocsubsection}{2}
    \etocsetlevel{mtocsubsubsection}{3} % <<<<<<<<<<<<<<<<
    
    % Define default widths
    \def\margintocnumwidth{-.8mm}%
    \def\margintocpagenumwidth{8pt}%
    \setlength{\RaggedRightParfillskip}{0pt}
    
    % Dry run to get the needed widths
    \etocsetstyle{mtocsection}%
    {}%
    {\setbox0\hbox{{\usekomafont{section}\small\etocthenumber\kern.8mm}}%%
        \setbox1\hbox{{\usekomafont{section}\small\etocthepage}}}%
    {\ifdim\wd0>\margintocnumwidth \edef\margintocnumwidth{\the\wd0} \fi%%
        \ifdim\wd1>\margintocpagenumwidth \edef\margintocpagenumwidth{\the\wd1} \fi}%
    {}%
    \etocsetstyle{mtocsubsection}%
    {}%
    {\setbox0\hbox{{\usekomafont{section}\small\mdseries\etocthenumber\kern.8mm}}%
        \setbox1\hbox{{\usekomafont{section}\small\mdseries\etocthepage}}}%
    {\ifdim\wd0>\margintocnumwidth \edef\margintocnumwidth{\the\wd0} \fi%
        \ifdim\wd1>\margintocpagenumwidth \edef\margintocpagenumwidth{\the\wd1} \fi}%
    {}%
    \etocsetstyle{subsubsection}% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    {}%
    {\setbox0\hbox{{\usekomafont{section}\small\mdseries\etocthenumber\kern.8mm}}%
        \setbox1\hbox{{\usekomafont{section}\small\mdseries\etocthepage}}}%
    {\ifdim\wd0>\margintocnumwidth \edef\margintocnumwidth{\the\wd0} \fi%
        \ifdim\wd1>\margintocpagenumwidth \edef\margintocpagenumwidth{\the\wd1} \fi}%
    {}%
    \etocsettocstyle{}{%
        \global\let\margintocnumwidth\margintocnumwidth%
        \global\let\margintocpagenumwidth\margintocpagenumwidth%
    }%
    \localtableofcontents%
    
    % Set the style for section entries
    \etocsetstyle{mtocsection}%
    {\parindent 0pt \parskip 2.5pt \parfillskip 0pt \RaggedRight}%
    {\leftskip \margintocnumwidth \rightskip \margintocpagenumwidth}%
    {\makebox[0pt][r]{\makebox[\margintocnumwidth][l]{\etocnumber}}\etocname\nobreak\leaders\hbox{\hbox to 1.5ex {\hss.\hss}}\hfill\rlap{\makebox[\margintocpagenumwidth][r]{\etocpage}}\par}%
    {}%
    % Set the style for subsection entries
    \etocsetstyle{mtocsubsection}%
    {\parindent 0pt \parskip 0pt \parfillskip 0pt \RaggedRight}%
    {\leftskip \margintocnumwidth \rightskip \margintocpagenumwidth}%
    {\makebox[0pt][r]{\makebox[\margintocnumwidth][l]{\mdseries\etocnumber}}{\mdseries\etocname\nobreak\leaders\hbox{\hbox to 1.5ex {\hss.\hss}}\hfill\rlap{\makebox[\margintocpagenumwidth][r]{\mdseries\etocpage}}}\par}%
    {\parskip 2.5pt}%
    % Set the style for subsubsection entries <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    \etocsetstyle{mtocsubsubsection}%
    {\parindent 0pt \parskip 0pt \parfillskip 0pt \RaggedRight}%
    {\leftskip \margintocnumwidth \rightskip \margintocpagenumwidth}%
    {\makebox[0pt][r]{\makebox[\margintocnumwidth][l]{\mdseries\etocnumber}}{\mdseries\etocname\nobreak\leaders\hbox{\hbox to 1.5ex {\hss.\hss}}\hfill\rlap{\makebox[\margintocpagenumwidth][r]{\mdseries\etocpage}}}\par}%
    {\parskip 2.5pt}%
    % Set the global style of the toc
    \etocsettocstyle{\usekomafont{section}\small}{}%
    \etocsetnexttocdepth{\themargintocdepth}%
    % Print the table of contents in the margin
    \marginnote[#1]{\localtableofcontents}%
    \FloatBarrier%
    \endgroup%
}

\setcounter{tocdepth}{3}% 3 >> add subsubsections in main ToC <<<<<

\begin{document}
    
\tableofcontents% main ToC  
    
\mainmatter % 

\chapter{Introduction}

\etocsetnexttocdepth{3}% <<<<<<<<<<<<<<<<<<<<<<<<<<<<
\setcounter{margintocdepth}{3}% 
\margintoc[-0.6em]% <<<<<<<<<<<<<<<<<<<<<<<<<<<<

1. \kant[1]
\section{The main ideas}
\subsection{The sub--main idea}
3. \kant[3]
\subsubsection{The sub--sub--main idea}
4. \kant[4]
\section{What is does}
5. \kant[5]
\section{What does not}
\section{How to use}

\end{document}

Связанный контент