我正在尝试将页眉“边距”调大。它太靠近边缘了。我一直试图将其\setlength{\headheight}{10pt}
调大,但页码却向下移动太多了?
有什么想法吗?
\documentclass[a4paper,12pt]{report}
\usepackage[margin=2cm]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{\nouppercase{\leftmark}} % Set chapter in left header.
\rhead{\nouppercase{My University}} % Set my university name in right header.
\setlength{\headheight}{10pt} % ??????????????????
\begin{document}
\chapter{First Chapter} %
First chapter's content.
\clearpage
\section{Hello}
The header is to close to the edge..
\end{document}
答案1
你收到警告;
Package Fancyhdr Warning: \headheight is too small (10.0pt):
Make it at least 14.49998pt.
We now make it that large for the rest of the document.
This may cause the page layout to be inconsistent, however.
fancyhdr
告诉您标题至少应为 14.4999pt 高。因此请确保16pt
安全。并使用geometry
包执行此操作。
\usepackage[margin=2cm,top=2.5cm,headheight=16pt,headsep=0.1in,heightrounded]{geometry}
headsep=0.1in,heightrounded
还有其他设置只是为了达到完美效果。此外,您可以像上面一样增加顶部边距。
\documentclass[a4paper,12pt]{report}
\usepackage[margin=2cm,top=2.5cm,headheight=16pt,headsep=0.1in,heightrounded]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{\nouppercase{\leftmark}} % Set chapter in left header.
\rhead{\nouppercase{My University}} % Set my university name in right header.
%\setlength{\headheight}{16pt} %<---- Not this way
\begin{document}
\chapter{First Chapter} %
First chapter's content.
\clearpage
some text
\section{Hello}
The header is to close to the edge..
\end{document}