1

I would like to alter my table of contents.

  • The font of sections and subsections should be the same as the chapters (which is lmss).
  • Chapters should have dotted lines too
  • How do I remove the space between the toc-title and the header? It only appears on this page, it's fine elsewhere...

How would I do this? Is there some package to overwrite the defaults? Thanks for any help :)

source

\documentclass[a4paper, listof=totoc]{scrreprt}

%Packages
\usepackage[bmargin=1.5cm,tmargin=1.5cm, headheight=1cm, includehead, includefoot]{geometry} %Seitenränder definieren
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman, english]{babel}
\usepackage{glossaries}
\usepackage[colorlinks, urlcolor=blue, linkcolor=black, citecolor=black]{hyperref}
\usepackage[german, noabbrev, nameinlink]{cleveref} %Automatische Verweise mit \cref{} oder \cpageref{} auf \label{}. Bei englischer Arbeit muss "german" durch "english" ersetzt werden. 
\usepackage{float} %Unterdrückt das Fliessen eines Bildes wenn statt "h" "H" als float angegeben wird.
\usepackage{pdfpages}
\usepackage{amstext}
\usepackage{lineno}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{makeidx}
\usepackage{listings}
\usepackage[round, comma, sort&compress]{natbib} %Bibliografie
\usepackage[manualmark]{scrlayer-scrpage}
\usepackage{lipsum}
\usepackage{fontspec}
\usepackage{listings}
\usepackage{import}
\usepackage{hyperref}
%------------------------------------------------------------------------------------------------%
%Konfigurationen

%Code-style
\import{Code/}{Codestyle}

%Bibliografie-Stil
\bibliographystyle{ieeetr}

%Kapitel-Abstand zu Kopfzeile verkleinern
\renewcommand*{\chapterheadstartvskip}{\vspace*{-0.2cm}}

%Kopfzeile und Fusszeile
\ihead*{\raisebox{-0.1\height}[0pt][0pt]{\includegraphics{example-image}}}
\cfoot*{\pagemark}

%Listing-Namen überschreiben
\renewcommand\lstlistingname{Quellcode}
\renewcommand\lstlistlistingname{Quellcodes}

%Glossar
\makeglossaries

%Inhaltsverzeichnis
\setcounter{secnumdepth}{\subsubsectionnumdepth}
\setcounter{tocdepth}{\subsubsectiontocdepth}


%------------------------------------------------------------------------------------------------%
\begin{document}
\selectlanguage{ngerman} %Wenn Arbeit auf Englisch geschrieben wird auf "english" setzen

%Titelseite

\pagenumbering{arabic}\setcounter{page}{2} %Seitennummerierung ab hier

\addchap{Abstract}
\addchap{Ehrlichkeitserklärung}

%Inhaltsverzeichnis
\tableofcontents{}

%Kapitel
\addchap{Einleitung}
\section{Motivation}
\addchap{Umsetzung}
\section{REST-API}

\end{document}

my current toc layout

4
  • 1
    Which documentclass do you use? It is missing in the example.
    – esdd
    Commented Nov 18, 2021 at 9:33
  • sorry, my bad. updated it!
    – Remo
    Commented Nov 18, 2021 at 10:29
  • 1
    The tocloft package provides all sorts of capabilities for controlling the appearance of the ToC (and LoF and Lot) but does not necessarily work well with the Koma classes. Commented Nov 18, 2021 at 20:12
  • 1
    @PeterWilson KOMA-Script classes load and use package tocbasic for ToC, LoF, LoT etc.
    – esdd
    Commented Nov 20, 2021 at 19:41

1 Answer 1

2

You use \addchap, so I guess you load a KOMA-Script class.

If the font of section and subsection entries in TOC should be sansserif:

\DeclareTOCStyleEntries[
  entryformat=\sffamily,
  pagenumberformat=\sffamily
]{tocline}{section,subsection}

Chapter entries with dotted lines, use either class option toc=chapterentrywithdots or

\DeclareTOCStyleEntry[
  linefill=\TOCLineLeaderFill
]{tocline}{chapter}

Do not redefine \chapterheadstartvskip to adjust the space before chapter title. Use:

\RedeclareSectionCommand[
  beforeskip=-.2cm,
  afterindent=false
]{chapter}

Example:

\documentclass{scrreprt}
\usepackage[bmargin=1.5cm,tmargin=1.5cm, headheight=1cm, includehead, includefoot]{geometry} %Seitenränder definieren
\ifluatex
  \usepackage{fontspec}
\else
  \usepackage[T1]{fontenc}
\fi
\usepackage{lmodern}
\usepackage[english,ngerman]{babel}
\usepackage{pdfpages}% loads graphix
\usepackage[manualmark]{scrlayer-scrpage}
\usepackage{blindtext}% only for dummy text

% load as last packages and do not load twice: 
\usepackage[colorlinks, urlcolor=blue, linkcolor=black, citecolor=black]{hyperref}
\usepackage[german, noabbrev, nameinlink]{cleveref}

% adjust space before chapter title
\RedeclareSectionCommand[
  beforeskip=-.2cm,
  afterindent=false
]{chapter}

% header and footer
\ihead*{\raisebox{-0.1\height}[0pt][0pt]{\includegraphics[height=\baselineskip]{example-image}}}
\cfoot*{\pagemark}

% tableofcontents
\setcounter{secnumdepth}{\subsubsectionnumdepth}
\setcounter{tocdepth}{\subsubsectiontocdepth}
\DeclareTOCStyleEntry[
  linefill=\TOCLineLeaderFill
]{tocline}{chapter}
\DeclareTOCStyleEntries[
  entryformat=\sffamily,
  pagenumberformat=\sffamily
]{tocline}{section,subsection}

%------------------------------------------------------------------------------------------------%
\begin{document}
\includepdf[pages={8}]{example-image-a4-numbered}% dummy title page
\addchap{Abstract}
\addchap{Ehrlichkeitserklärung}

\tableofcontents

\chapter{Einleitung}
\section{Motivation}
\chapter{Umsetzung}
\section{Forschung}
\subsection{REST-API}

\blinddocument% dummy text
\end{document}

enter image description here


Additional remarks:

I have removed the unrelated stuff.

Do not load packages twice and load packages hyperref and cleveref last (in this order).

You must log in to answer this question.

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