TransWikia.com

Spacing in toc with KOMA-script or tocloft and visible header

TeX - LaTeX Asked by Jannis on March 10, 2021

right now I am using the tocloft-package for spacing in my toc. This results into the problem of not having a header on the page. Do you know a way to replace tocloft with KOMA-script commands or do you know a way to create the same header while using tocloft? Furthermore I need the command to turn the page numbers in toc to normalfont.

enter image description here

Minimal example:

documentclass[a4paper]{scrartcl}

%HEADER
usepackage[headsepline=0.75pt]{scrlayer-scrpage}
renewcommand*{headfont}{normalfontsffamily}
clearpairofpagestyles
automark[section]{section}         
ihead{headmark} 
ohead{pagemark}                

%Spacing TOCLOFT
usepackage{tocloft} 
cftsetindents{sec}{0cm}{0.9cm}
cftsetindents{subsec}{0.3cm}{1.25cm}
cftsetindents{subsubsec}{0.6cm}{1.355cm}
renewcommand{cftsecfont}{normalfont}


begin{document}
tableofcontents
newpage
section{Ein erster Abschnitt}
subsection{Unterabschnitt}
subsubsection{Unter-Unterabschnitt}
end{document}

2 Answers

It is not recommended to use package tocloft with a KOMA-Script class. You could change indent and numwidth in ToC using RedeclareSectionCommand or DeclareTOCStyleEntry.

Example:

documentclass[a4paper]{scrartcl}

usepackage[headsepline=0.75pt]{scrlayer-scrpage}
setkomafont{pagehead}{normalfontsffamily}% <- changed
clearpairofpagestyles
automark[section]{section}
ihead{headmark} 
ohead{pagemark}

RedeclareSectionCommand[
  tocindent=0cm,
  tocnumwidth=0.9cm
]{section}
RedeclareSectionCommand[
  tocindent=0.3cm,
  tocnumwidth=1.25cm
]{subsection}
RedeclareSectionCommand[
  tocindent=0.6cm,
  tocnumwidth=1.355cm
]{subsubsection}
setkomafont{sectionentry}{normalfont}

begin{document}
tableofcontents
clearpage
section{Ein erster Abschnitt}
subsection{Unterabschnitt}
subsubsection{Unter-Unterabschnitt}
end{document}

or

documentclass[a4paper]{scrartcl}

usepackage[headsepline=0.75pt]{scrlayer-scrpage}
setkomafont{pagehead}{normalfontsffamily}% <- changed
clearpairofpagestyles
automark[section]{section}
ihead{headmark} 
ohead{pagemark}

DeclareTOCStyleEntry[
  indent=0cm,
  numwidth=0.9cm
]{tocline}{section}
DeclareTOCStyleEntry[
  indent=0.3cm,
  numwidth=1.25cm
]{tocline}{subsection}
DeclareTOCStyleEntry[
  indent=0.6cm,
  numwidth=1.355cm
]{tocline}{subsubsection}
setkomafont{sectionentry}{normalfont}

begin{document}
tableofcontents
clearpage
section{Ein erster Abschnitt}
subsection{Unterabschnitt}
subsubsection{Unter-Unterabschnitt}
end{document}

Correct answer by esdd on March 10, 2021

Option for tocloft:

usepackage[titles]{tocloft} 
renewcommand{cftsecpagefont}{normalfont}

Still would like to use KOMA instead.

Answered by Jannis on March 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP