I’m trying to add code before and after centered chapter titles in scrbook
.
I tried to do this by redefining \chapterlinesformat
.
\documentclass[twoside=semi]{scrbook}
\renewcommand{\raggedchapter}{\centering}
\renewcommand{\chapterlinesformat}[3]{Before~#3~After}
\begin{document}
\chapter*{Test}
\end{document}
But this doesn’t work.
I guss this is because #3
is formatted and contains \@@par
at its end.
(I learned this from an answer to an earlier question.)
This problem is very similar (nearly identical) to another one. But the approaches given there won’t work for me:
- The first answer uses
titlesec
, which shouldn’t be used together with KOMA-Script. - The second answer requires additional code after the table of content. But in my use case, all the configuration must take place in the preamble (or, more specifically, in the class file).
My current idea is to implement the second approach by redefining \tableofcontents
to include the necessary additional code.
But this seems rather hacky to me.