![章节和节与页眉页码重叠](https://linux22.com/image/457513/%E7%AB%A0%E8%8A%82%E5%92%8C%E8%8A%82%E4%B8%8E%E9%A1%B5%E7%9C%89%E9%A1%B5%E7%A0%81%E9%87%8D%E5%8F%A0.png)
我正在使用基于回忆录类的模板。在某些极端情况下,章节和节标题不会换行,因此与页眉中的页码重叠。有没有办法防止这种情况发生?缩写章节或节标题不是一种选择,因为需要在目录和页眉中使用全名(如此处建议:fancyhdr 长节名称与页码重叠)。 谢谢!
我将其范围缩小到以下最小工作示例:
\documentclass[b5paper, twoside]{memoir}
\usepackage{lipsum}
% Chapter style
\makechapterstyle{chstyle}{%
\renewcommand\chapnamefont{%
\normalfont\Huge\sffamily
}
\renewcommand\chaptitlefont{%
\normalfont\HUGE\sffamily\bfseries
}
\renewcommand\printchaptertitle[1]{%
\chaptitlefont \begin{Spacing}{1}##1\end{Spacing}
}
\renewcommand\printchapternum{\chapnamefont\Huge\space\thechapter}
}
\chapterstyle{chstyle}
% Headers and footers
% Normal page style
\makepagestyle{hfpage}
\makeevenhead{hfpage}{\thepage}{}{\leftmark}
\makeoddhead{hfpage}{\rightmark}{}{\thepage}
\makeevenfoot{hfpage}{}{}{}
\makeoddfoot{hfpage}{}{}{}
\makeheadrule{hfpage}{\textwidth}{\normalrulethickness}
\makepsmarks{hfpage}{%
\nouppercaseheads
}
\pagestyle{hfpage}
\aliaspagestyle{chapter}{empty}
\begin{document}
\chapter{Hello 1 Hello 1 Hello 1 Hello 1 Hello 1 Hello 1 Hello 1 Helloooooo}
\lipsum[1-7]
\section{Section Section Section Section Section Section Section Section Sectionn}
\lipsum[8-9]
\end{document}
答案1
在标题中缩写标题应该一个选项。
该类memoir
为分段命令提供了第二个可选参数。
\chapter[<for toc>][<for heading>]{<title in the body>}
但我发现逻辑上有错误,因为标题的缩短版本比目录的缩短版本更为常见。
这是一种使用基于键值的语法来指定标题的修改版本的方法。
\documentclass[b5paper, twoside]{memoir}
\usepackage{lipsum}
% Chapter style
\makechapterstyle{chstyle}{%
\renewcommand\chapnamefont{%
\normalfont\Huge\sffamily
}%
\renewcommand\chaptitlefont{%
\normalfont\HUGE\sffamily\bfseries
}%
\renewcommand\printchaptertitle[1]{%
\chaptitlefont \begin{Spacing}{1}##1\end{Spacing}
}%
\renewcommand\printchapternum{\chapnamefont\Huge\space\thechapter}%
}
\chapterstyle{chstyle}
% Headers and footers
% Normal page style
\makepagestyle{hfpage}
\makeevenhead{hfpage}{\thepage}{}{\leftmark}
\makeoddhead{hfpage}{\rightmark}{}{\thepage}
\makeevenfoot{hfpage}{}{}{}
\makeoddfoot{hfpage}{}{}{}
\makeheadrule{hfpage}{\textwidth}{\normalrulethickness}
\makepsmarks{hfpage}{%
\nouppercaseheads
}
\pagestyle{hfpage}
\aliaspagestyle{chapter}{empty}
\ExplSyntaxOn
\NewDocumentCommand{\fixedchapter}{sO{}m}
{
\IfBooleanTF{#1}
{
\memoirchapter*{#2}
}
{
\thomas_fixtitles:Nnn \memoirchapter { #2 } { #3 }
}
}
\NewDocumentCommand{\fixedsection}{sO{}m}
{
\IfBooleanTF{#1}
{
\memoirsection*{#2}
}
{
\thomas_fixtitles:Nnn \memoirsection { #2 } { #3 }
}
}
\keys_define:nn { thomas/fixtitles }
{
head .tl_set:N = \l__thomas_fixtitles_head_tl,
toc .tl_set:N = \l__thomas_fixtitles_toc_tl,
}
\cs_new_protected:Nn \thomas_fixtitles:Nnn
{
\keys_set:nn { thomas/fixtitles }
{% initialize
head = { #3 },
toc = { #3 },
% evaluate the keys
#2
}
#1 [ \l__thomas_fixtitles_toc_tl ] [ \l__thomas_fixtitles_head_tl ] { #3 }
}
\ExplSyntaxOff
\AtBeginDocument{%
\NewCommandCopy{\memoirchapter}{\chapter}%
\RenewCommandCopy{\chapter}{\fixedchapter}%
\NewCommandCopy{\memoirsection}{\section}%
\RenewCommandCopy{\section}{\fixedsection}%
}
\begin{document}
\tableofcontents*
\chapter[
head={Hello 1 Hello 1 \dots}
]{Hello 1 Hello 1 Hello 1 Hello 1 Hello 1 Hello 1 Hello 1 Helloooooo}
\lipsum[1-7]
\section[
head={Section Section \dots},
toc={Something for the toc},
]{Section Section Section Section Section Section Section Section Sectionn}
\lipsum[8-9]
\end{document}
目录
偶数页标题
奇数页标题
答案2
memoir
分段命令提供了第二个可选参数,以便您可以为目录指定一个版本,为运行标题指定另一个版本。例如
\section[Very long title, goes to Table of contents][Abridged title]{Very long title}