花式标头的问题

花式标头的问题

使用花式页眉 (\pagestyle{fancy}) 时,我遇到了问题。当我添加它时,文本在上部重叠,如下图所示: 在此处输入图片描述

我尝试使用 geometry 包,但是没有用。我觉得问题应该出在这部分代码上:

\fancypagestyle{plain}{
  \renewcommand{\headrulewidth}{0.0pt}
  \fancyfoot{}
  \fancyfoot[RO, LE]{\thepage}
  \fancyhead{}
}

\pagestyle{fancy}

我还在此处包含了整个代码,以防出现任何其他问题:

\documentclass[pdftex,11pt,openright,headsepline]{book}

\usepackage{paralist}       % List environment
\usepackage{color}      % For colored text
\usepackage{times}
\usepackage{amsfonts}       % Additional math fonts
\usepackage{amsmath}        % Math symbols
\usepackage{latexsym}
\usepackage{graphicx}       % For including images
% \usepackage{listings}     % If listings are needed
% \usepackage{mydefs}       % Some of our own definitions
% \usepackage{wrapfig}      % To wrap images
% \usepackage{algorithmic}  % Nice algorithm environment
% \usepackage{algorithm}
\usepackage{fancyhdr}       % Produce the nice header
\usepackage{fullpage} % Use the full page




\usepackage{textcomp}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage[hidelinks]{hyperref}
\usepackage{mathtools}



% Change the appearance of the header. Here \MakeUppercase is hard-coded, so renewing this command allows to elegantly change the header appearance.
\renewcommand{\MakeUppercase}{\scshape}

% Set the headings' appearance in the ``fancy'' pagestyle
\fancyhead{}
\fancyhead[RO, LE]{\leftmark}
\fancyfoot{}
\fancyfoot[RO, LE]{\thepage}

% The first pages shall be empty, even no page numbering 


\begin{document}
\pagestyle{empty} % even no page number

\fancypagestyle{plain}{
  \renewcommand{\headrulewidth}{0.0pt}
  \fancyfoot{}
  \fancyhead{}
}

% Title page, modify accordingly 
\input{title.tex}
\cleardoublepage

\input{abstract.tex}

%% Input here any acknowledgements
%\input{ack.tex}
%\cleardoublepage
%\newpage

% % Chapter-pages etc. use the ``plain'' pagestyle - since we don't want to have a heading at all at chapter-pages, redefine plain accordingly. Don't forget the page number. 
\fancypagestyle{plain}{
  \renewcommand{\headrulewidth}{0.0pt}
  \fancyfoot{}
  \fancyfoot[RO, LE]{\thepage}
  \fancyhead{}
}

\pagestyle{fancy}
\pagenumbering{Roman}

% Insert table of contents
\tableofcontents

% Insert list of figures
\listoffigures
\cleardoublepage

% Insert list of tables
\listoftables
\cleardoublepage

\newpage

\pagenumbering{arabic}

%% ----------------------------------------------------------------------------
% Actual text comes here - defer it to other files and use \input{bla.tex}, ..
%% ----------------------------------------------------------------------------
\input{intro.tex}
\input{relatedwork.tex}
\input{materialsandmethods.tex}
\input{experimentsandresults.tex}
\input{discussion.tex}
\input{conclusion.tex}


%% ----------------------------------------------------------------------------
% If Appendix is needed
%% ----------------------------------------------------------------------------
\appendix
\input{appendix.tex}

%% ----------------------------------------------------------------------------
% Bibliography is stored in references.bib file, and can often be found
% online on webpages like dblp.uni-trier.de
%
% To include it in your thesis, run
%  pdflatex main
%  bibtex main
%  pdflatex main
%  pdflatex main
%
% This ensures all references are done correctly.
%% ----------------------------------------------------------------------------

\bibliographystyle{plain}
\bibliography{/home/alvaroeg/SemesterProject/Report/Bibliography/SlidingBoundaries}

\end{document}

提前致谢

答案1

我看不出加载该fullpage包的任何理由。该包的用途与排版论文完全不同。

由于它将\headheight\headsep都设置为零,显然您不希望这样。使用任何headings选项都不能令人满意。

谨防\renewcommand{\MakeUppercase}{\scshape}是一个严重的错误:尽快将其从您的代码中删除。我在下面的代码中添加了获取小写字母标题的好方法。

headsepline该类别没有选项bookopenright是默认的,并且pdftex永远不应指定。

您可以使用geometry并获得与相同的效果fullpage,但使用正确的标题。

\documentclass[11pt]{book}
\usepackage[margin=1in,headheight=13.6pt]{geometry}

\usepackage{lipsum} % for filler text

\usepackage{fancyhdr}


% Set the headings' appearance in the ``fancy'' pagestyle
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO, LE]{\scshape\nouppercase{\leftmark}}
\fancyfoot[RO, LE]{\thepage}

% The first pages shall be empty, even no page numbering
\fancypagestyle{plain}{%
  \renewcommand{\headrulewidth}{0.0pt}%
  \fancyhf{}%
}

\begin{document}

\chapter{Title}
\section{Title}

\lipsum[1-20]

\end{document}

在此处输入图片描述

答案2

当您处理文档时,您应该会看到如下警告:

Package Fancyhdr Warning: \headheight is too small (0.0pt): 
Make it at least 13.59999pt.

由于\headheight设置为0pt,由于fullpage包的原因,标题和文本发生冲突。\headheight按建议增加:这可以通过fullpage使用headings选项加载来完成:

\usepackage[headings]{fullpage}

但是,由于您的设置,您的头部高度仍然太小:

Package Fancyhdr Warning: \headheight is too small (12.0pt): 
Make it at least 13.59999pt.

因此你还需要添加类似

\setlength\headheight{13.6pt}

或者加载geometry包而不是fullpage并使用该包自定义页面布局。

相关内容