![如果部分从新页面开始,则将 headers 放大](https://linux22.com/image/400474/%E5%A6%82%E6%9E%9C%E9%83%A8%E5%88%86%E4%BB%8E%E6%96%B0%E9%A1%B5%E9%9D%A2%E5%BC%80%E5%A7%8B%EF%BC%8C%E5%88%99%E5%B0%86%20headers%20%E6%94%BE%E5%A4%A7.png)
我正在使用带有几何包的 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}
结果: