En la plantilla de clase kaobook, logré agregar una subsección; pero ¿qué tengo que hacer para mostrar subsecciones en el TOC del lado de kaobook?

En la plantilla de clase kaobook, logré agregar una subsección; pero ¿qué tengo que hacer para mostrar subsecciones en el TOC del lado de 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

TOC lateral

Respuesta1

La kaobookclase no define las entradas para las subsubsecciones cuando se utiliza el margen ToC. Para hacerlo es necesario redefinir el \magintoccomando, bastante largo.

(1) \margintocinsertará la ToC local en el margen. Puede moverlo hacia arriba o hacia abajo usando el parámetro opcional. Por ejemplo \margintoc[-0.6cm]para alinear con el texto.

(2)Para suprimir las subsubsecciones de un uso de ToC local particular

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

C

% !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}

información relacionada