The problem is that lstdoc.sty
redefines some of the \l@...
family of commands in charge of typesetting the entries for the sectional units in the ToC. For example, \l@section
is defined in lstdoc.sty
as
\newcommand*\l@section[2]{%
\addpenalty\@secpenalty
\addvspace{.25em \@plus\p@}%
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode
\advance\leftskip\@tempdima
\hskip -\leftskip
#1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\endgroup}
whereas the definition for \l@section
in scrbook.cls
is
\newcommand*\l@section{\bprot@dottedtocline{1}{1.5em}{2.3em}}
In order to recover the original definitions you can redefine the \l@...
commands in the preamble of your document to be the ones used for scrbook.cls
. So for example:
\documentclass[a4paper,titlepage]{scrbook}
\usepackage{lstdoc}
\makeatletter
\renewcommand*\l@section{\bprot@dottedtocline{1}{1.5em}{2.3em}}
\makeatother
\begin{document}
\tableofcontents
\section{test1}
test test
\end{document}
produces

which is (up to the colored hyperlink) the original formatting. Similar redefinitions will have to be made for some of the other \l@...
commands corresponding to the other sectional units that will go to the ToC and which \l@... commamds are redefined by lstdoc.sty.
The following example code shows these redefinitions necessary to obtain the original formatting for ToC entries from \chapter
down to \subparagraph
:
\documentclass[a4paper,titlepage]{scrbook}
\usepackage{lstdoc}
% all sectional units will be numbered and will go to the ToC
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\makeatletter
\renewcommand*\l@section{\bprot@dottedtocline{1}{1.5em}{2.3em}}
\renewcommand*\l@subsection{\bprot@dottedtocline{2}{3.8em}{3.2em}}
\renewcommand*\l@subsubsection{\bprot@dottedtocline{3}{7.0em}{4.1em}}
\makeatother
\begin{document}
\tableofcontents
\chapter{Test Chapter}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\paragraph{Test Paragraph}
\subparagraph{Test Subparagraph}
\end{document}
