如何使用 KOMA-script 调整换行章节行的行距?

如何使用 KOMA-script 调整换行章节行的行距?

我正在使用scrbook。有些章节标题很长而且会换行,有些甚至会换行两次。当它转到第三行时,间距与第一行和第二行之间的间距不同。看起来非常烦人(抱歉截图很糟糕):

ivanScrbook章节标题

我不知道为什么会发生这种情况,而且我也无法解决它。

TeX.SE 上有大量关于格式化标题的“文献”。最接近的是控制章节标题的行距,但它使用titlesec,所以不是一个选项。我试图重新定义\chapterformat,但没有帮助:

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

我尝试将这两种解决方案应用于独立于文本的其余部分更改标题的行距。强制参数中带有 的那个\setstretch只是缩放现有内容。另一个没有任何效果。效果最好的是looseness=-1,但它将“句法”一分为二。

编辑:非常抱歉,以下是 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}%
 \linespread{1.1}\large\scshape#1%
 \par\nobreak\vspace*{30pt}}
 \@afterheading%
}
\newcommand{\authortoc}[1]{%
 \addtocontents{toc}{\vskip-10pt}%
 \addtocontents{toc}{%
 \protect\contentsline{chapter}%
 {\hskip1.3em\mdseries\scshape\protect\scriptsize#1}{}{}}
 \addtocontents{toc}{\vskip5pt}%
}
\makeatother
%% chapter formatting 
%% based on https://tex.stackexchange.com/a/173857/12934
\makeatletter
\renewcommand{\@chapapp}{}% remove the word `chapter'
\renewcommand*{\chapterformat}{%
  \linespread{2.5}\chapappifchapterprefix{\ }\thechapter\autodot\enskip}

\def\@makechapterhead#1{%
\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@
}}

\def\@makeschapterhead#1{%
\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}

我现在认为自定义格式正在以某种方式触发它......

答案1

由于缺乏实际代码,我无法真正说出为什么引入这种间距,但这里有一个使用仅 KOMA 方法的解决方案。

ivanKOMA章节标题

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

\KOMAoption{chapterprefix}{true}
\renewcommand*\raggedchapter{\raggedleft}
\addtokomafont{chapter}{\large}
\renewcommand*{\chapterformat}{\thechapter\autodot\IfUsePrefixLine{}{\enskip}}
\RedeclareSectionCommand[beforeskip=0pt]{chapter}
\renewcommand{\chapterheadmidvskip}{%
    \par\nobreak\vskip -.1cm {\rule{.4\textwidth}{.5pt}}\par%
}
\renewcommand{\chapterheadendvskip}{%
    \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}

经过一些调整,我们得到了以下结果:

ivanKoma章节标题Mod

\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}
\renewcommand{\chapterheadmidvskip}{%
    \par\nobreak\vspace{\baselineskip}{\rule[.7\baselineskip]{.4\textwidth}{.4pt}}\par%
}
\renewcommand{\chapterheadendvskip}{%
\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}

相关内容