调整标题页面样式的字体大小

调整标题页面样式的字体大小

如同问题是,我想确保章节标题适合文档的标题边界。我正在使用KOMA 报告作为文档类。

为了实现这一点,我按如下方式减小了字体大小 \renewcommand*\headfont{\normalfont\footnotesize} ,但这不是我想要的解决方案,因为我想在整个文档中保持相同的字体大小。例如,是否可以仅在标题中换行?非常感谢任何帮助!

这是我的 MWE:

\documentclass[%
    paper=a4,
    twoside=true,
    bibliography=totoc,
    listof=notnumbered,
    numbers=noenddot,
    parskip=half,
    headsepline,
    footsepline,
    headings=normalsize,
    fontsize=12pt,
    chapterprefix=true,
]{scrreprt}
\KOMAoptions{listof=entryprefix}
\usepackage[ngerman, english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{hyperref}

\renewcommand*\headfont{\normalfont\footnotesize} % My solution

\begin{document}
\pagestyle{headings}
\tableofcontents

\chapter{One}
\section{Length of this section's title fits well}
\lipsum[1-8]
%\newpage
\section{Here the long section's title exceeds the boundaries of the A4 page in the header. I want to ensure the section titles fit within the header boundaries of my document.}
\lipsum[1-8]

\end{document}

答案1

使用headings=optiontohead和可选参数\section。我不明白为什么使用scrrreprt而不是scrbook

另外,使用\setkomafont{pagehead}(全局)更改大小;我发现将标题的尺寸设置为比文本小是一个好主意。

\documentclass[%
    paper=a4,
    twoside=true,
    bibliography=totoc,
    listof=notnumbered,
    numbers=noenddot,
    parskip=half,
    headsepline,
    footsepline,
    fontsize=12pt,
    chapterprefix=true,
    headings=optiontohead,
]{scrbook}
\KOMAoptions{listof=entryprefix}
\usepackage[ngerman, english]{babel}
%\usepackage[utf8]{inputenc} % no longer needed
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{hyperref}

\setkomafont{pagehead}{\normalsize\footnotesize}

\begin{document}

\tableofcontents

\chapter{One}
\section{Length of this section's title fits well}
\lipsum[1-8]

\section[Here the long section's title exceeds the boundaries of the A4 page in the header.]
  {Here the long section's title exceeds the boundaries of the A4 page in the header.
   I want to ensure the section titles fit within the header boundaries of my document.}

\lipsum[1-8]

\end{document}

在此处输入图片描述

目录中的标题将会很长。

在此处输入图片描述

答案2

我也建议使用@egreg的答案。但是,如果您确实需要多行页眉,则可以使用包scrlayer-scrpage并添加类选项headlines=2(以支持 2 行页眉):

\documentclass[%
    paper=a4,            % default and therefore not needed
    twoside=true,
    bibliography=totoc,
    listof=notnumbered,
    numbers=noenddot,
    parskip=half,
    headsepline,
    footsepline,
%    headings=normalsize,% Option headings does not provide an argument
%                        % normalsize. So it is unclear, what you wanted here!
    fontsize=12pt,
    chapterprefix=true,
    headlines=2,
]{scrreprt}
\KOMAoptions{listof=entryprefix}% Why not addded to the options of \documentclass?
\usepackage[ngerman, english]{babel}
\usepackage[utf8]{inputenc} % default since LaTeX 2018-04-01
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{graphicx}

\usepackage[automark]{scrlayer-scrpage}

\usepackage{hyperref}

\begin{document}
\pagestyle{headings}
\tableofcontents

\chapter{One}
\section{Length of this section's title fits well}
\lipsum[1-8]
%\newpage
\section{Here the long section's title exceeds the boundaries of the A4 page in the header. I want to ensure the section titles fit within the header boundaries of my document.}
\lipsum[1-8]

\end{document}

在此处输入图片描述

相关内容