![使用 parskip=half* 选项时控制 \chapterformat 中的垂直间距](https://linux22.com/image/361956/%E4%BD%BF%E7%94%A8%20parskip%3Dhalf*%20%E9%80%89%E9%A1%B9%E6%97%B6%E6%8E%A7%E5%88%B6%20%5Cchapterformat%20%E4%B8%AD%E7%9A%84%E5%9E%82%E7%9B%B4%E9%97%B4%E8%B7%9D.png)
尝试自定义章节标题时,我无法控制规则和章节名称之间的垂直间距。我想使用段落间距而不是缩进,所以我使用 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}%
}