[Tex/LaTex] Customization of TOC in KOMA

koma-scripttable of contents

I would like to customize the listing of the chapters given in the table of contents in a scrbook document. Given the following example:

\documentclass{scrbook}
\begin{document}
\tableofcontents
\chapter{Alpha}
\chapter{Beta}
\chapter{Gamma}
\end{document}

My TOC currently looks like this:

TOC

How can I customize the text printed in the TOC in the following two regards:

  • add a prefix/suffix to the number, e.g. write "Chapter 1" instead of "1"
  • increase letter spacing of the chapter title using microtype's textls

Best Answer

Here is another suggestion based on the example in this article by Markus Kohm at www.komascript.de

\documentclass{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{microtype}

\newcommand*{\SavedOriginaladdchaptertocentry}{}
\let\SavedOriginaladdchaptertocentry\addchaptertocentry
\renewcommand*{\addchaptertocentry}[2]{%
  \ifstr{#1}{}{% entry without number
    \SavedOriginaladdchaptertocentry{#1}{#2}%
  }{% entry with number
    \SavedOriginaladdchaptertocentry{}{%
      \string\expandafter\string\MakeUppercase\string\chaptername
      ~#1\string\quad\textls[500]{#2}}%
  }%
}%

\begin{document}
\tableofcontents
\addchap{Preface}
\chapter{Alpha}
\chapter{Beta}
\chapter{Gamma}
\addchap{Appendix}
\end{document}

enter image description here

I have increased the letter spacing to show the effect.

If the letter spacing should be increased for the whole chapterentry you can use

\newcommand*{\SavedOriginaladdchaptertocentry}{}
\let\SavedOriginaladdchaptertocentry\addchaptertocentry
\renewcommand*{\addchaptertocentry}[2]{%
  \ifstr{#1}{}{% entry without number
    \SavedOriginaladdchaptertocentry{#1}{#2}%
  }{% entry with number
    \SavedOriginaladdchaptertocentry{}{%
      \string\expandafter\string\MakeUppercase\string\chaptername
      ~#1\string\quad{}#2}%
  }%
}%
 \addtokomafont{chapterentry}{\textls[200]}

Note that \textls[200] have to be the last command for the chapterentry font element because it needs an argument

enter image description here