标题中有两行部分名称,文本和行之间的距离太小。我该如何更改?
\documentclass[12pt, % Schriftgröße
DIV=calc % Automatischer Satzspiegel
]{scrartcl}
\usepackage[T1]{fontenc} % Aktiviert EC-Schriftarten
\usepackage[utf8]{inputenc} % Dateikodierung
\usepackage[ngerman]{babel} % Deutsche Einstellung
\usepackage{lmodern} % Latin Modern
\usepackage{blindtext}
%% Geometrieeigenschaften
\usepackage[a4paper]{geometry}
\geometry{left=3.5cm, right=3.5cm, top=3cm, bottom=3cm}
%% Zeilenabstand auf 1,5
\usepackage{setspace}
\onehalfspacing
%% Kopf- und Fußzeile
\usepackage[headsepline,footsepline,automark]{scrlayer-scrpage}
\clearscrheadfoot % Voreinstellungen resetten
\ihead[]{\parbox[t]{.6\textwidth}{\headmark}} % Zeilenumbruch nach 60% der Länge
\ohead[]{Name} % Name oben rechts
\cfoot[]{-\pagemark-} % Seitenzahl unten mitte
\setkomafont{pageheadfoot}{\sffamily} % Serifenlose Kopf- und Fußzeile
\begin{document}
\section{Dies hier ist ein Blindtext zum Testen von Überschriften}
\blindtext
\end{document}
** 由 Manuel Kuehner (较小的 MWE) 编辑**
\documentclass[12pt]{scrartcl}
\usepackage{blindtext}
\usepackage[a4paper]{geometry}
\geometry{
top = 30mm,
showframe = true,
}
\usepackage[headsepline,automark]{scrlayer-scrpage}
\clearscrheadfoot
\ihead[]{\parbox[t]{.3\textwidth}{\headmark}}
\begin{document}
\section{Test Test Test Test Test Test Test Test }
\blindtext
\end{document}
答案1
如果您不能使用可选参数来\section
避免标题条目对于一行来说太长:
\documentclass[12pt]{scrartcl}
\usepackage{blindtext}% only for dummy text
\usepackage[a4paper]{geometry}
\geometry{
top = 30mm,
showframe = true,% to show the page layout
}
\usepackage[headsepline,automark]{scrlayer-scrpage}
\clearpairofpagestyles% depraceted command replaced
\ihead{%
\parbox
[b]% use b(ottom) instead t(op)
[\ht\strutbox]% to avoid the warning regarding head height
{.3\textwidth}{\raggedright\headmark}% \raggedright to avoid underfull hboxes
}
\begin{document}
\section{Test Test Test Test Test Test Test Test }
\blindtext
\end{document}
结果:
您也可以使用 option head lines=2
。然后您可以删除第二个可选参数\parbox
:
\documentclass[12pt,
head lines=2% added
]{scrartcl}
\usepackage{blindtext}% only for dummy text
\usepackage[a4paper,
]{geometry}
\geometry{
top = 30mm,
showframe = true,% to show the page layout
}
\usepackage[headsepline,automark]{scrlayer-scrpage}
\clearpairofpagestyles% depraceted command replaced
\ihead{%
\parbox
[b]% use b(ottom) instead t(op)
{.3\textwidth}{\raggedright\headmark}% \raggedright to avoid underfull hboxes
}
\begin{document}
\section{Test Test Test Test Test Test Test Test }
\blindtext
\end{document}
注意,还有一个选项headings=optiontohead
。然后您可以仅将节标题的简短版本用于页眉。
\documentclass[12pt,
headings=optiontohead% added
]{scrartcl}
\usepackage{blindtext}
\usepackage[a4paper]{geometry}
\geometry{
top = 30mm,
showframe = true,
}
\usepackage[headsepline,automark]{scrlayer-scrpage}
\clearpairofpagestyles% depraceted command replaced
\ihead{\headmark}% changed
\begin{document}
\tableofcontents
\clearpage
\section[Only Test]{Test Test Test Test Test Test Test Test }
\blindtext
\end{document}
使用其中一个选项headings=optiontohead
, headings=optiontoheadandtoc
, headlines= ,optiontotoc
您还可以在页眉和目录中使用不同的条目。
例子:
\documentclass[12pt,
headings=optiontoheadandtoc% added
]{scrartcl}
\usepackage{blindtext}
\usepackage[a4paper]{geometry}
\geometry{
top = 30mm,
showframe = true,
}
\usepackage[headsepline,automark]{scrlayer-scrpage}
\clearpairofpagestyles% depraceted command replaced
\ihead{\headmark}% changed
\begin{document}
\tableofcontents
\clearpage
\section[head={Version in page header},tocentry={Version in table of contents}]
{Test Test Test Test Test Test Test Test }
\Blindtext
\section[Only Test]{Test Test Test Test Test Test Test Test }
\Blindtext
\end{document}
答案2
- 如果使用
[b]
option 而不是[t]
option in\parbox
那么它看起来会更好。 - 此外,我使用了 use 推荐的解决方案@Bernard在评论中(该部分的简短版本)。
\documentclass{scrartcl}
% Based on https://komascript.de/node/249 (post from 2019-02-27)
\usepackage{blindtext}
% Uncomment to remove borders (borders are for debugging)
\usepackage{showframe}
\usepackage[automark,headsepline]{scrlayer-scrpage}
\clearpairofpagestyles
\ihead[]{\parbox[b]{.3\textwidth}{\headmark}}
\ohead{ohead}
\ifoot{ifoot}
\ofoot{\pagemark}
\begin{document}
% Without optional argument for \section
\section{Long Section Title Long Section Title Long Section Title Long Section Title Long Section Title }
\Blindtext
% With optional argument for \section
\section[Short section Title]{Long Section Title Long Section Title Long Section Title Long Section Title Long Section Title }
\Blindtext
\end{document}