# How to adjust line spacing in wrapped chapter lines with KOMA-script?

I'm using scrbook. Some chapter titles are long and wrap, some of those even twice. When it goes on the third line, the spacing is different than that between the first and second lines. Looks terribly annoying (sorry for the lousy screenshot):

I've no idea why this happens, and I can't fix it.

There's substantial "literature" here on TeX.SE on formatting titles. The closest it gets to is the very nice discussion in Control line spacing of section headings, but it uses titlesec, so not an option. I tried to redefine \chapterformat, doesn't help:

\renewcommand*{\chapterformat}{\normalfont\large\bfseries}{%
\thechapter}{1em}{\setstretch{0.1}}


I tried to apply the two solutions in Changing the linespacing of headings independently from the rest of the text. The one with the \setstretch in the mandatory argument just scales what there is. The other doesn't have any effect. The best thing that worked is looseness=-1, but it breakes "syntactic" in two.

EDIT: All apologies, here's a MWE:

\documentclass[a4paper,10pt,headings=optiontohead,version=last,openany]{scrbook}
\usepackage{kantlipsum}\date{}
\usepackage{suffix}
\renewcommand{\sectionmark}[1]{}%prevent rewriting \markright
\renewcommand{\subsectionmark}[1]{}%prevent rewriting \markright
\newcommand{\chapterauthor}[1]{\authortoc{#1}\printchapterauthor{#1}\markright{#1}}% setting \markright to author

\makeatletter
\newcommand{\printchapterauthor}[1]{%
{\parindent0pt\vspace*{-10pt}%
\par\nobreak\vspace*{30pt}}
}
\newcommand{\authortoc}[1]{%
\protect\contentsline{chapter}%
{\hskip1.3em\mdseries\scshape\protect\scriptsize#1}{}{}}
}
\makeatother
%% chapter formatting
%% based on https://tex.stackexchange.com/a/173857/12934
\makeatletter
\renewcommand{\@chapapp}{}% remove the word chapter'
\renewcommand*{\chapterformat}{%

\vspace*{10\p@}%
{\parindent \z@ \raggedleft \reset@font
\Huge \sffamily \@chapapp{}  \thechapter\vspace*{-15\p@}
\par\nobreak
\interlinepenalty\@M\hrulefill\newline\vspace*{-5\p@}
\LARGE \sffamily #1\par\nobreak
\vspace*{-8\p@}%
\hrulefill
\par\nobreak
\vskip 30\p@
}}

\vspace*{4\p@}%
{\parindent \z@ \raggedleft \reset@font
\sffamily
\interlinepenalty\@M\hrulefill\newline\vspace*{-5\p@}
\Huge \bfseries #1\par\nobreak
\vspace*{-8\p@}%
\hrulefill
\par\nobreak
\vskip 30\p@
}}

\begin{document}
\chapter{The walzing wombat went to the lazy lizard to get to the
dixie dancing ducks to have a meal of beloved bananas}
\kant[2]
\end{document}


I think now that the custom formatting is triggering it somehow...

• Using titlesec with KOMA is never a good idea :-( – Johannes_B May 23 '15 at 13:52
• No! That's why I'm not using it :-) – Ivan Kapitonov May 23 '15 at 14:06
• Certainly the preamble (and a small document body) matters. Do you really believe one can analyze the behaviour without some code? Without knowing how you implemented the lines? – Ulrike Fischer May 23 '15 at 14:24
• @UlrikeFischer: Mea culpa. – Ivan Kapitonov May 23 '15 at 14:52
• Replace the \newline\vspace*{-5\p@} by \\[-5pt]. \vspace inside a paragraph is inserted after the current line (and so the \vspace{-5pt} makes the space between your first two lines smaller). Btw: With your redefinitions you are completly overwriting the KOMA commands. – Ulrike Fischer May 23 '15 at 15:03

For a lack of the actual code, i cannot really tell why this spacing is introduced, but here a solution using KOMA-only methods.

\documentclass[english]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{blindtext}

\KOMAoption{chapterprefix}{true}
\renewcommand*\raggedchapter{\raggedleft}
\renewcommand*{\chapterformat}{\thechapter\autodot\IfUsePrefixLine{}{\enskip}}
\RedeclareSectionCommand[beforeskip=0pt]{chapter}
\par\nobreak\vskip -.1cm {\rule{.4\textwidth}{.5pt}}\par%
}
\begingroup
\raggedchapter
\rule{0.9\textwidth}{.5pt}\par%
\vspace*{\baselineskip}%
\endgroup
}

\usepackage{geometry}% Just for this test
\geometry{ margin=7cm }
\begin{document}
\blinddocument
\chapter{The walzing wombat went to the lazy lizard to get to the
dixie dancing ducks to have a meal of beloved bananas}
\blindtext
\end{document}


With a bit of tweaking, we get this:

\documentclass[english]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{blindtext}
\usepackage{libertine}

\KOMAoption{chapterprefix}{true}
\renewcommand*\raggedchapter{\raggedleft}
\setkomafont{chapter}{\normalfont\large\sffamily}
\renewcommand*{\chapterformat}{\thechapter\autodot\IfUsePrefixLine{}{\enskip}}
\RedeclareSectionCommand[beforeskip=0pt]{chapter}
\par\nobreak\vspace{\baselineskip}{\rule[.7\baselineskip]{.4\textwidth}{.4pt}}\par%
}
\begingroup%
\raggedchapter%
\rule{\textwidth}{.5pt}\par%
\vspace*{\baselineskip}%
\endgroup%
}

\usepackage{geometry}
\geometry{ margin=6.9cm }
\begin{document}
\blinddocument
\chapter{The walzing wombat went to the lazy lizard to get to the
dixie dancing ducks to get some of their beloved bananabread}
\blindtext
\end{document}

• Elke, siehst du das raggedleft im endvskip-Teil? Die raggedchapter Gruppe wird schon vorher geschlossen. Ist jetzt die Frage, sollte das mit in der ragged-Gruppe enthalten sein? Früher zumindest wurde in der Doku die Möglichkeit der Nutzung von Nicht-Space erwähnt. – Johannes_B May 23 '15 at 14:13
• Alas, that doesn't help. I'll post my code in a minute. – Ivan Kapitonov May 23 '15 at 14:38
• Why \raggedleft to align a simple rule? Why not \hfill`? – Ulrike Fischer May 23 '15 at 14:43
• @esdd I was reusing code from the other answer ;-) – Johannes_B May 23 '15 at 14:46