使用 parskip=half* 选项时控制 \chapterformat 中的垂直间距

使用 parskip=half* 选项时控制 \chapterformat 中的垂直间距

尝试自定义章节标题时,我无法控制规则和章节名称之间的垂直间距。我想使用段落间距而不是缩进,所以我使用 Koma 选项parskip=一半*

但之前描述的间距比parskip=false感觉很奇怪。

我该如何定义 \chapterformat 来避免这个问题?

以下是 MWE:

\documentclass[fontsize=12pt,french]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{luatextra}
\usepackage{polyglossia}
\usepackage{blindtext}

\defaultfontfeatures{Ligatures=TeX} % To support LaTeX quoting style
\setmainfont{Cambria}
\setsansfont{Calibri}

\KOMAoption{chapterprefix}{true}
\KOMAoptions{%
    parskip=half*
}%
\renewcommand*\raggedchapter{\centering}
\RedeclareSectionCommand[beforeskip=0pt,afterskip=8\baselineskip,innerskip=0pt]{chapter}
%\setkomafont{chapterprefix}{\normalsize\mdseries}

\renewcommand*{\chapterformat}{%
  \chapappifchapterprefix{\nobreakspace}\thechapter\autodot%
  \IfUsePrefixLine{%
    {\parskip=0pt\par}\nobreak\vspace{-\parskip}\vspace{-.6\baselineskip}%
    \rule{0.9\textwidth}{.5pt}%
  }{\enskip}%
}

\newcommand\SectionFontStyle{\sffamily}

\setkomafont{sectioning}{\SectionFontStyle}
\addtokomafont{chapter}{\bfseries\scshape}    % Chapter in samm capitals font

\begin{document}
\tableofcontents
\chapter{Chapter One}
\textbf{\KOMAScriptVersion}
\par
\Blindtext
\addchap{Chapter without number}
\Blindtext
\end{document}

答案1

您可以设置innersep=-\parskip

\documentclass[fontsize=12pt,french]{scrreprt}
%\usepackage[utf8]{inputenc}
\usepackage{luatextra}
\usepackage{polyglossia}
\setdefaultlanguage{french}
\usepackage{blindtext}

\defaultfontfeatures{Ligatures=TeX} % To support LaTeX quoting style
\setmainfont{Cambria}
\setsansfont{Calibri}

\KOMAoption{chapterprefix}{true}
\KOMAoptions{%
    parskip=half*
}%
\renewcommand*\raggedchapter{\centering}
\RedeclareSectionCommand[
  beforeskip=0pt,afterskip=8\baselineskip,
  innerskip=-\parskip% <- changed
]{chapter}

\renewcommand*{\chapterformat}{%
  \chapappifchapterprefix{\nobreakspace}\thechapter\autodot%
  \IfUsePrefixLine{%
    \par\nobreak\vspace{-\parskip}\vspace{-.6\baselineskip}%
    \rule{0.9\textwidth}{.5pt}%
  }{\enskip}%
}

\newcommand\SectionFontStyle{\sffamily}
%
\setkomafont{sectioning}{\SectionFontStyle}
\addtokomafont{chapter}{\bfseries\scshape}    % Chapter in samm capitals font

\begin{document}
\tableofcontents
\chapter{Chapter One}
\textbf{\KOMAScriptVersion}
\par
\Blindtext
\addchap{Chapter without number}
\Blindtext
\end{document}

在此处输入图片描述


另一种可能性innerskip=0pt

\renewcommand*{\chapterformat}{%
  \chapappifchapterprefix{\nobreakspace}\thechapter\autodot%
  \IfUsePrefixLine{%
    \par\nobreak\vspace{-\parskip}\vspace{-.6\baselineskip}%
    \rule{0.9\textwidth}{.5pt}%
    \vspace{-\parskip}% <- added
  }{\enskip}%
}

相关内容