如果部分从新页面开始,则将 headers 放大

如果部分从新页面开始,则将 headers 放大

我正在使用带有几何包的 KOMA 脚本 scrartcl 类,并希望我的部分(总是从新页面开始)在标题行之间有一些额外的垂直间距,但我不想更改小节、小小节、段落、浮点数等的标题行。

我读了这个帖子但不幸的是,我没有足够的声誉来发表评论。

我相信将此命令应用于部分(而不是仅应用于 sub 和 subsub 部分)会起作用:

\usepackage{xpatch}
\xpretocmd\sectionlinesformat{\vspace*{0pt}}{}{\PatchFailed}

这是我的 MWE:

%%% Preamble
\documentclass[12pt,
twoside=false,
letterpaper,
hidelinks,
parskip=half,
onehalfspacing,
bibliography=numbered,
numbers=noenddot]{scrartcl}

\usepackage[headsepline]{scrlayer-scrpage}  % enable header line

\usepackage[
top=3cm,
headheight=2.5cm, % 17pt as per the warning by fancyhdr 17pt = about 0.6cm
headsep=1em,
%includehead,  % do not includefoot so that you can strictly define the top of the footer
heightrounded, % to avoid spurious underfull messages
footskip=5mm,
bottom=1cm,
bindingoffset=0.0mm,
left=2.2cm,
right=2.2cm,
%showframe=true,
]{geometry} 

\usepackage{xpatch}
\xpretocmd\sectionlinesformat{\vspace*{0pt}}{}{\PatchFailed}  % adds padding to subsections also :(

\addtokomafont{section}{\clearpage}
\RedeclareSectionCommand[beforeskip=1.0em,afterskip=0.01em]{section}
\RedeclareSectionCommand[beforeskip=1.0em, afterskip=0.01em]{subsection}
\RedeclareSectionCommand[beforeskip=1.0em, afterskip=0.01em]{subsubsection}


\usepackage{blindtext}

%%%   Document  %%%
\begin{document}

\blindtext

\blinddocument

\blindtext

\blindtext

\blinddocument

\end{document}

答案1

免责声明:我建议使用类scrreprt\chapter


请勿滥用\addtkomafont。参数中仅允许使用字体命令。

将补丁更改\sectionlinesformat为:

\usepackage{xpatch}
\xpretocmd\sectionlinesformat
  {\ifstr{#1}{section}{\clearpage\vspace*{0pt}}{}}
  {}{\PatchFailed}

例子:

\documentclass[12pt,
twoside=false,
letterpaper,
%hidelinks,
parskip=half,
%onehalfspacing,
bibliography=numbered,
numbers=noenddot]{scrartcl}
\usepackage{blindtext}% only for dummy text

\usepackage[headsepline]{scrlayer-scrpage}  % enable header line

\usepackage[
top=3cm,
headheight=2.5cm, % 17pt as per the warning by fancyhdr 17pt = about 0.6cm
headsep=1em,
%includehead,  % do not includefoot so that you can strictly define the top of the footer
heightrounded, % to avoid spurious underfull messages
footskip=5mm,
bottom=1cm,
%bindingoffset=0.0mm,
left=2.2cm,
right=2.2cm,
%showframe=true,
]{geometry} 

\usepackage{xpatch}
\xpretocmd\sectionlinesformat
  {\ifstr{#1}{section}{\clearpage\vspace*{0pt}}{}}
  {}{\PatchFailed}

\RedeclareSectionCommands
  [beforeskip=1.0em,afterskip=0.01em]
  {section,subsection,subsubsection}

\begin{document}
\blindtext
\blinddocument
\blindtext
\blindtext
\blinddocument
\end{document}

结果:

在此处输入图片描述

相关内容