# titletoc-like toc-layout for subsections with KOMA-Script only

Since the use of titletoc in connection with KOMA-Script is not recommended, I am looking for a solution that allows the following toc-layout for subsections exclusively with KOMA-Script. I tried it first using \DeclareTOCStyleEntry and tocraggedpagenumber, but I couldn't find a way to prevent the line break after an entry – if it can work with \DeclareTOCStyleEntry at all. The following minimal example shows my current attempt using titletoc:

\documentclass{scrbook}

\usepackage{lmodern}

\usepackage{titletoc}
\titlecontents*{subsection}
[3.8em]
{\small\itshape}
{\thecontentslabel\ }
{}
{\ \thecontentspage}
[\ $\cdot$\ ]
[]

\begin{document}

\tableofcontents

\chapter{Testchapter}
\section{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}

\end{document}

• This is an interesting question (+1), but unfortunaly there is no style for this type of entry. Defining such a new style using \DeclareTOCEntryStyle (note the changed order of "Entry" and "Style") is really complex. Additionally the existing styles (eg tocline) must be modified too. So there is no suggestion to replace the titletoc solution by KOMA-Script code. – esdd Jul 6 at 17:44
• @esdd Thank you for your comment. Due to the complexity I will probably have to stay with the titletoc solution. Although the combination with KOMA-Script is not recommended, I haven't noticed any unintended problems so far – a complete KOMA-Script solution would just have been nice. I only replaced the version of titletoc currently available in TeX Live 2019 with the development version from GitHub, because there were hyperlink problems with package hyperref before (see here). – bho Jul 7 at 20:25
• Good news: Markus informed me that the next tocbasic version will provide a new style toctext - see Geplante Änderungen in zukünftigen KOMA-Script-Versionen (German). – esdd Jul 8 at 14:23
• @esdd That's really good news! I have adjusted my question... – bho Jul 9 at 8:28
• My suggestion: ask Markus directly. You will find his e-mail in the copyright info at the beginning of his classes and packages. – esdd Jul 9 at 12:21

From version KOMA-Script 3.27.3167 it is now possible to realize the above mentioned toc-layout with the new tocstyle toctext (see comment from @esdd). Here is a new working MWE (with thanks to Markus Kohm):

\documentclass{scrbook}
\usepackage{lmodern}
\DeclareTOCStyleEntry[%
raggedright=false,% don't activate ragged right
entryformat=\textit,% The format expects the text as argument, so we prefer
% \textit over \itshape
pagenumberformat={},% don't use default \normalfont for the page numbers
onstartfirstentry=\small,% Use \small for the whole paragraph
onstartentry={\ $\cdot$\ },% distance and centered dot between entries
onendentry={},% do not use the default \quad after entries,
afterpar=\normalsize,% after final par switch back to \normalsize (note:
% will be executed for each entry!)
]{toctext}{subsection}
\begin{document}
\tableofcontents
\chapter{Testchapter}
\section{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\subsection{Testsection}
\end{document}

• Prerelease 3.27.3175 is available from the KOMA-Script website. – esdd Jul 24 at 6:12
• @esdd Thank you for this hint! – bho Jul 24 at 10:33