我正在尝试使用 \RedeclareSectionCommand 修改节标题前后的间距(也适用于目录)。修改“afterskip”的值确实会改变节标题和文本之间的距离。但是,更改“beforeskip”的值没有任何作用。我不想为此使用 \vspace*{}。有很多关于此的帖子,但我尝试过的所有方法都没有用。
过去我使用 titlesec 包和以下命令来修改间距:
\usepackage{titlesec}
\titlespacing{\section}{0pt}{*5}{*3}
\titlespacing{\subsection}{0pt}{*5}{*3}
在没有 titlesec 包的情况下,我尝试使用 KOMA-Script 中给出的命令:
\documentclass[12pt,a4paper,captions=nooneline,twoside]{scrartcl}
\usepackage[onehalfspacing]{setspace}
\usepackage[paper=a4paper,left=30mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{csquotes}
\usepackage[headsepline=0.4pt]{scrlayer-scrpage}
\pagestyle{scrheadings}
\clearpairofpagestyles
\RedeclareSectionCommand[
%runin=false,
afterindent=false,
beforeskip=\baselineskip,
afterskip=0.5\baselineskip]{section}
\begin{document}
\tableofcontents
\newpage
\section{Test}
Text beginns here....
\end{document}
答案1
它确实有效:
\documentclass[12pt,captions=nooneline,twoside]{scrartcl}
\usepackage[onehalfspacing]{setspace}
\usepackage[paper=a4paper,left=30mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}% needed with older TeX distributions
\usepackage{lmodern}
\usepackage{csquotes}
\usepackage[headsepline=0.4pt]{scrlayer-scrpage}
\clearpairofpagestyles
\RedeclareSectionCommand[
%runin=false,
afterindent=false,
beforeskip=5\baselineskip,% enlarged for demonstration
afterskip=0.5\baselineskip]{section}
\begin{document}
\tableofcontents
%\newpage
\section{Test}
Text beginns here.
\end{document}
结果是
请注意,beforeskip
如果章节标题位于页面顶部,则会被删除。
因此也许您想使用scrreprt
并\chapter
得到所需的结果:
\documentclass[12pt,captions=nooneline,twoside]{scrreprt}
\usepackage[onehalfspacing]{setspace}
\usepackage[paper=a4paper,left=30mm,right=20mm,top=25mm,bottom=25mm]{geometry}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}% needed with older TeX distributions
\usepackage{lmodern}
\usepackage{csquotes}
\usepackage[headsepline=0.4pt,plainheadsepline]{scrlayer-scrpage}
\clearpairofpagestyles
\RedeclareSectionCommand[
%runin=false,
afterindent=false,
beforeskip=5\baselineskip,% enlarged for demonstration
afterskip=0.5\baselineskip]{chapter}
\begin{document}
\tableofcontents
%\newpage
\chapter{Test}
Text beginns here.
\end{document}