# Customize TOC using KOMA-Script

I want to customize my ToC and read that the package tocloft is not the good package to use in combination with the KOMA-Script. With the package tocstyle I also get warnings about version conflicts.

Since I think my adjustment are not to complicated maybe it is also possible to do them without such a package, however I have no clue how to do that.

• I want to have the same format for my ToC as the chapter,section and subsection styles. So the number in the left margin and the names in the body at the right side aligned. (See MWE and image)

Does someone have any idea?

\documentclass{scrreprt}

\usepackage[
includemp,
showframe,
reversemp,
paperwidth=20.1cm,
paperheight=25.80cm,
top=2.30cm,
bottom=3.4cm,
inner=2.7cm,
outer=2.7cm,
marginparwidth=1.6cm, % Fixed for now
marginparsep=0.4cm
]{geometry}

\usepackage{lipsum}
% \usepackage{tocloft}

\makeatletter          % to set the marginpar on the left side in showframe
\let\Gm@vrules@mpi\Gm@vrules@mpii
\makeatother

\renewcommand*{\chapterformat}{\makebox[0pt][r]{\chapappifchapterprefix{\
}\thechapter\autodot\hskip\marginparsep}}%
\renewcommand*{\sectionformat}{\makebox[0pt][r]
{\thesection\autodot\hskip\marginparsep}}
\renewcommand*{\subsectionformat}{\makebox[0pt][r]
{\thesubsection\autodot\hskip\marginparsep}}
\renewcommand*{\subsubsectionformat}{\makebox[0pt][r]
{\thesubsubsection\autodot\hskip\marginparsep}}

% remove the vertical skip before the chapter heading
\RedeclareSectionCommand[beforeskip=-1sp plus -1sp minus 1sp]{chapter}

\usepackage[footwidth=textwithmarginpar]{scrlayer-scrpage}

\begin{document}

\clearpairofpagestyles
\automark{chapter}
\ifoot{%
\makebox[0pt][r]{\pagemark\autodot\hskip\marginparsep}%
\ifodd \value{page}%
Quantifying goodness of morphodynamic field predictions
\else
\fi
}
\renewcommand\chaptermarkformat{}

\tableofcontents

\chapter{chapter}
\lipsum[2]
\section{section}
\lipsum[2]
\subsection{subsection}
\lipsum[2]

\end{document}


\documentclass{scrreprt}

\usepackage[
includemp,
showframe,
reversemp,
paperwidth=20.1cm,
paperheight=25.80cm,
top=2.30cm,
bottom=3.4cm,
inner=2.7cm,
outer=2.7cm,
marginparwidth=1.6cm, % Fixed for now
marginparsep=0.4cm
]{geometry}

\usepackage{lipsum}
% \usepackage{tocloft}

\makeatletter          % to set the marginpar on the left side in showframe
\let\Gm@vrules@mpi\Gm@vrules@mpii
\makeatother

\renewcommand*{\chapterformat}{\intoleftmargin{\chapappifchapterprefix{\
}\thechapter\autodot}}%
\renewcommand*{\sectionformat}{\intoleftmargin{\thesection\autodot}}
\renewcommand*{\subsectionformat}{\intoleftmargin{\thesubsection\autodot}}
\renewcommand*{\subsubsectionformat}{\intoleftmargin{\thesubsubsection\autodot}}

% remove the vertical skip before the chapter heading
\RedeclareSectionCommand[beforeskip=-1sp plus -1sp minus 1sp]{chapter}
\RedeclareSectionCommands[tocnumwidth=0pt,tocindent=0pt,tocentrynumberformat=\intoleftmargin]{chapter,section,subsection,subsubsection}
\newcommand*{\intoleftmargin}[1]{\makebox[0pt][r]{#1\hskip\marginparsep}}

\usepackage[footwidth=textwithmarginpar]{scrlayer-scrpage}

\begin{document}

\clearpairofpagestyles
\automark{chapter}
\ifoot{%
\makebox[0pt][r]{\pagemark\autodot\hskip\marginparsep}%
\ifodd \value{page}%
Quantifying goodness of morphodynamic field predictions
\else
\fi
}
\renewcommand\chaptermarkformat{}

\tableofcontents

\chapter{chapter}
\lipsum[2]
\section{section}
\lipsum[2]
\subsection{subsection}
\lipsum[2]

\end{document}


For more information about \RedeclareSectionCommand and options like tocnumwidth, tocindent and tocentrynumberformat (which are the options numwidth, indent and entrynumberformat of style tocline of command \DeclareTOCStyleEntry) see the English KOMA-Script manual or the German KOMA-Script manual or even the German KOMA-Script book.

• Excuse me for the bad formatting in the question. Many thanks! – SLeenders Aug 14 '17 at 14:35