If you use the documentclass book or scrbook, new chapters look rather boring: it's just the headline plus the number, for exmaple:
So instead one might want to add horizontal lines before and after -- which makes it look a bit more pleasing I think:
How that's done is described here on Stackoverflow, the adapted code is re-produced here:
\documentclass{book}
\usepackage{titlesec}
\usepackage{graphicx}
% Surrounds all chapter titles by lines (see screenshot),
% which includes the titles in the TOC and list of figures and tables
\titleformat{\chapter}[display]
{\bfseries\huge}
{\filleft\Large\chaptertitlename~\thechapter}
{3ex}
{\titlerule\vspace{1.5ex}\filright}
[\vspace{1ex}\titlerule]
% The following code removes the lines (that are added above)
% from the TOC and list of figures and tables
\titleformat{name=\chapter, numberless}[block]
{\bfseries\huge}
{}
{0pt}
{\filright}
\begin{document}
% Puts TOC and list of figures on tables on a single pages
% makes sense for minimal working examples so that one
% doesn't have to scroll for ages just to check appearance
\tableofcontents
\begingroup
\let\clearpage\relax
\listoffigures
\let\clearpage\relax
\listoftables
\endgroup
\newcommand{\ShortLorem}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. }
\chapter{First Chapter Headline}
\ShortLorem
\begin{figure}[h]
\centering
\includegraphics[width=.35\textwidth]{example-image-a}
\caption{Dummy caption\label{fig:dummyFig}}
\end{figure}
\ShortLorem
\begin{table}[h]
\begin{center}
\begin{tabular}{cc}
A & B\
\hline
a & b
\end{tabular}
\caption{Dummy caption\label{tab:dummyTab}}
\end{center}
\end{table}
\ShortLorem
\chapter{Second Chapter Headline}
\ShortLorem
\section{First Section in 2nd Chapter}
\ShortLorem
\section{Second Section in 2nd Chapter}
\ShortLorem
\end{document}
Just for the sake of completeness: My question (see below) is a variant on the one I linked. The original question asks how to prevent these additional lines in the TOC and list of figures and tables. That's what the second code block in the beginning (The following code removes...) does. Its impact illustrated in the following graphic:
(If you find all of above useful, please like the Q and A in the orginal question! I just improved the code a bit (added comments, removed pointsless packages), and added screenshots.)
Now, my question:
How do I get this code to work when I change the documentclass from book to scrbook?
When I do that I receive the following error message:
! Missing number, treated as zero.
<to be read again>
}
l.74 \section{First Section in 2nd Chapter}
I do not know why ... Can this be 'repaired'? The sole reason why I use scrbook instead of book is since the former provides much more space, i.e., the borders are smaller. I wasn't aware of any other changes so far (like the ones that clearly cause the above code not to work anymore). Help would be greatly appreciated. :)



titlesectogether with a KOMA-Script class. If really want to do this see Conflict between titlesec package and scrbook class after most recent update of TeXLive2019. To change the layout of the chapter title redefine\chapterlinesformatand\chapterlineswithprefixformat. Example: KOMA-Script line above and below chapter title. – esdd Dec 06 '21 at 08:47scrbooktogether with classarticle, load KOMA-Script packagetypearea. – esdd Dec 06 '21 at 08:50