1

I would like to indent the chapter lines of the table of contents (it includes parts and chapters) but apparently I am not able to do it.

I understand that the Koma-script I am using (scrbook) should do it by default, but it doesn't. I have been reading the manual and several forum questions about it. Apparently a toc=graduated or toc=indent options can be used. I tried to put the option in the documentclass but it does not work.

Could anybody help me?

Here is my code:

 \documentclass[chapterprefix=true]{scrbook}

\setcounter{secnumdepth}{0}
\usepackage{xcolor, graphicx}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{textcomp}
\usepackage{indentfirst}
\usepackage{times}
\usepackage{mathptmx}
\usepackage{setspace}
\doublespacing


\definecolor{chaptergrey}{rgb}{0.7,0.7,0.7}

\let\raggedchapter\raggedleft
\addtokomafont{disposition}{\normalfont}
%\setkomafont{element}{commands}
\setkomafont{title}{\color{cyan}\LARGE}
\setkomafont{chapter}{\color{cyan}\LARGE}
\setkomafont{subtitle}{\color{black}}

\renewcommand*{\chapterformat}{%
    \scalebox{3}{\color{cyan}\thechapter}%
}


\begin{document}
\author{}

\subject{Linea Guida}
\title{\textbf{Il trattamento laparoscopico di laparocele e ernie ventrali}}
\subtitle{}
\titlehead{}


\date{Gennaio 2022}

\frontmatter
\maketitle
\tableofcontents
\chapter{Intro}



\mainmatter
\part{Sviluppo della linea guida}
\chapter{one}
\chapter{two}
\part{Quesiti}
\chapter{three}
\chapter{four}
\backmatter
% bibliography, glossary and index would go here.

\end{document}
2
  • make an example that we can actually compile to see the issue. So remove all these \include and add a few chapters manually. Dec 30, 2021 at 14:45
  • Ok, thank you. I edited the code in the original message eliminating all the "include"; I left the first part unchanged. I hope that it works as an example Dec 30, 2021 at 15:06

1 Answer 1

1

Each sectioning command has a so called depth, e.g. -1 for \part, 0 for \chapter, 1 for \section and so on. Indentation starts only with \section. Since you have only defined \chapter, none of your entries in indented.

Adding a few additional levels yield the expected result

TOC with indentation

\documentclass[chapterprefix=true]{scrbook}

\setcounter{secnumdepth}{0}
\usepackage{xcolor, graphicx}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{textcomp}
\usepackage{indentfirst}
\usepackage{times}
\usepackage{mathptmx}
\usepackage{setspace}
\doublespacing


\definecolor{chaptergrey}{rgb}{0.7,0.7,0.7}

\let\raggedchapter\raggedleft
\addtokomafont{disposition}{\normalfont}
%\setkomafont{element}{commands}
\setkomafont{title}{\color{cyan}\LARGE}
\setkomafont{chapter}{\color{cyan}\LARGE}
\setkomafont{subtitle}{\color{black}}

\renewcommand*{\chapterformat}{%
    \scalebox{3}{\color{cyan}\thechapter}%
}


\begin{document}
    \author{}
    
    \subject{Linea Guida}
    \title{\textbf{Il trattamento laparoscopico di laparocele e ernie ventrali}}
    \subtitle{}
    \titlehead{}
    
    
    \date{Gennaio 2022}
    
    \frontmatter
    \maketitle
    \tableofcontents
    \chapter{Intro}
    
    
    
    \mainmatter
    \part{Sviluppo della linea guida}
    \chapter{one (depth=0)}
    \section{First section (depth=1)}
    \subsection{A subsection (depth=2)}
    % The subsubsection does not appear in the toc, because the default is tocdepth=2 for scrbook
    \subsubsection{And a subsubsection (depth=3)}
    \section{Second section}
    \chapter{two}
    \part{Quesiti}
    \chapter{three}
    \chapter{four}
    \backmatter
    % bibliography, glossary and index would go here.
    
\end{document}

The \section and \subsection and unnumbered, because you specified \setcounter{secnumdepth}{0}, meaning only \part and \chapter are numbered.

Also, notice that the \subsubsection does not appear in the table of contents. This is controlled via the counter tocdepth which has a default value of 2 for the scrbook class.

Koma-Script has some handy commands, so you don't have to remember the different depths. Adding \setcounter{tocdepth}{\subsubsectiontocdepth} would include \subsubsection in the table of contents.

If you would like to have your chapters one, two and so on indented, you can add this to your preamble.

\RedeclareSectionCommand[
    tocindent=2em
]{chapter}

\RedeclareSectionCommand[
    tocindent=4em
]{section}

\RedeclareSectionCommand[
    tocindent=6em
]{subsection}

TOC with chapter indent

1
  • Great!I found out another solution: \setlength{\cftsecindent}{0pt}%remove indent for section \setlength{\cftchapindent}{30pt}% add indent for \subsection % \setlength{\cftsubsubsecindent}{0pt}% Remove indent for \subsubsection but your solution seems far more linear Dec 31, 2021 at 10:17

You must log in to answer this question.

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