I’m trying to add code before and after centered chapter titles in scrbook. I tried to do this by redefining \chapterlinesformat.




But this doesn’t work.

enter image description here

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.


As you (and the KOMA-Script documentation) note, the argument #3 contains \@@par at its very end, which is what's bothering you. KOMA-Script does not provide a hook to insert text after the title.

The easiest hack is to just remove the \@@par and insert it after the inserted code.




  \newcommand*\@appendkomachaptertitle[2]{\@strip@trailing@@par #1#2\@@par}




MEW output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.