3

I am currently formatting a TOC. I am getting rid of the number of the chapters only in the TOC, as can be seen in the MWE below.

\documentclass[a4paper]{scrbook}

% PACKAGES LOADING

\usepackage[titles]{tocloft} % To customise TOC.

% TOC SETTINGS

\renewcommand\addchaptertocentry[2]{\addtocentrydefault{chapter}{}{#2}} \renewcommand{\thesection}{\arabic{section}}

\renewcommand\tableofcontents{\listoftoc*{toc}}

%%%%%%%%%%%%%%% DOCUMENT %%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\tableofcontents

\chapter{Fancy title 1}

\section{Section title 1}

\section{Section title 2}

\end{document}

The MWE produces the following output: enter image description here

I want to the numbers of the sections to be aligned with the chapter; that is, on the red line of the next picture: enter image description here

Can anybody help me please achieve that?

Thank you all for your time!

EoDmnFOr3q
  • 2,299

1 Answers1

4

Don't mix the use of Koma-script classes and tocloft, since the class already provides features to deal with ToC-related adjustments.

Specifically, you can change the default style associated with sections and remove the indent:

\DeclareTOCStyleEntry[indent=0pt]{default}{section}

enter image description here

Werner
  • 603,163
  • Thank you for your answer. I am currently loading tocloft because I use \renewcommand{\cftchapaftersnum}{.} and similar commands to get a . before each number in the TOC. How can I achieve that without tocloft? – EoDmnFOr3q Jan 31 '22 at 18:20
  • 1
    you should be able to control this with the numbers=endperiod options (see https://tex.stackexchange.com/a/24448/12332) – ArTourter Jan 31 '22 at 18:29