\usepackage{fancyhdr}
我想使用和制作页眉\pagestyle{fancy}
。但是当章节和部分名称很长时,它们会重叠。是否有选项可以强制页眉中的换行符,以使它们不重叠?这里有一个最简单的例子:
\documentclass{report}
% specifying header
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{document}
\chapter{A very long chapter title that should be on the top right}
\section{A very long section title that should be on the top left}
\newpage
Here, the header looks messy.
\end{document}
我看到有人讨论了这个问题这里但我希望这对我没有真正的帮助。
答案1
\parbox
下面是使用es 和\RaggedRight
/ \RaggedLeft
from设置标题的示例ragged2e
:
\documentclass{report}
\usepackage{fancyhdr,ragged2e}
\fancyhead{}
\lhead{\parbox[t]{0.4\textwidth}{\RaggedRight\rightmark\strut}}
\rhead{\parbox[t]{0.4\textwidth}{\RaggedLeft\leftmark\strut}}
\setlength{\headheight}{5\baselineskip}
\pagestyle{fancy}
\begin{document}
\chapter{A very long chapter title that should be on the top right}
\section{A very long section title that should be on the top left}
\newpage
Some text to demonstrate the header. looks bet.
\end{document}