KOMA 脚本的标题和字体

KOMA 脚本的标题和字体

我正在使用 scrbook 作为自制的双面打印文档类的基础来设置我的学士论文的布局。我想要一个标题,其中包含外侧的当前部分编号和名称(偶数页左侧,奇数页右侧),标题中心的当前章节编号和名称以及内侧的章节编号和名称。我在 KOMA-Script 文档中找到了这个示例:

\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\automark[chapter]{chapter}
\automark*[section]{}

它将章节放在偶数页的外侧,将部分放在奇数页的外侧。遗憾的是,我无法修改它以满足我的需求,因为我不太了解 KOMA-Script 的工作方式。如果某个部分开始了,但其中仍然没有章节,则该章节的位置将保持空白(章节和部分相同)。有人能帮忙吗?

此外,我想将 KOMA-Script 更改的所有字体(例如 toc、section、chapter...)改回默认的计算机现代字体,因为我不喜欢 KOMA-Script 在这里使用的字体。有没有比像这样手动更改所有字体更好的方法:

\addtokomafont{section}{\fontfamily{cmr}\selectfont}

答案1

对于页眉中的部分条目,我将修改我的示例scrpage2:标题的三个“标记”\automark。请注意,重新定义后不能有取消星号的命令,\partmark因为这会重置此定义。

要在章节标题中获得衬线字体,您可以更改字体元素disposition

\setkomafont{disposition}{\normalcolor\bfseries}

或者你可以使用未记录的选项

headings=standardclasses

如果字体元素也descriptionlabel应该使用衬线字体,你可以设置未记录的选项,egregdoesnotlikesansseriftitles这是这个问题并且需要 KOMA 3.20 或更新版本。更新:此未记录的选项已弃用。对于 KOMA-Script 版本 3.39 或更新版本,现在有记录类选项sfdefaults=false

\documentclass[
  sfdefaults=false,% needs version 3.39 or newer
  %headings=standardclasses
]{scrbook}
%\providecommand*\Ifstr{\ifstr}% needed up to and including KOMA-Script version 3.27, see https://komascript.de/faq_deprecatedif
%\providecommand*\Ifnumbered{\ifnumbered}% needed up to and including KOMA-Script version 3.27, see https://komascript.de/faq_deprecatedif
\usepackage{scrlayer-scrpage}% activates page style scrheadings automatically
\automark[section]{chapter}
\newmarks\currentpart

\renewcommand\partmark[1]{% after all unstarred \automark commands!
  \marks\currentpart{\Ifnumbered{part}{\partname~\thepart\autodot\enskip}{}#1}%
  \markboth{}{}%
  }
\newcommand\partinheadfoot{\firstmarks\currentpart}

\clearpairofpagestyles
\ohead{\partinheadfoot}
\chead{\leftmark}
\ihead{\Ifstr{\leftmark}{\rightmark}{}{\rightmark}}
\ofoot*{\pagemark}

\renewcommand\partpagestyle{empty}
\usepackage{lipsum}% for dummy text
\begin{document}
\tableofcontents
\part{First Test}
\chapter{A Chapter}
\section{A Section}
\lipsum

\part{Second Test}
\chapter{Only a Chapter}
\lipsum

\part{Third Test}
\section{Only a Section}
\lipsum

\part{Fourth Test}
\lipsum
\begin{description}
\item[Testlabel] Text
\end{description}
\end{document}

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

如果您的部分、章节或节标题对于标题来说太长,您可以使用选项headings=optiontoheadheadings=optiontoheadandtoc在标题中使用短标题,在目录中使用长(或其他)版本。请参阅 KOMA-Script 文档部分“3.16. 文档结构”中对等的解释\part[short version ]{heading

相关内容