如何去除Fancyhdr header 引入的多余边距

如何去除Fancyhdr header 引入的多余边距

我正在尝试自定义我的简历模板,并希望在文档的每一页上都显示联系信息。我尝试使用 fancyhdr 来实现这一点,但它在第二页上引入了一些不必要的额外空间/边距,现在我已经在这里卡了一段时间。任何知道可能是什么原因并提出修复建议的人都将不胜感激!

%THE PROBLEM!!!!!!!!!!PS:在我的代码中我引入了 fancyhdr 标头的地方写了注释。

问题

简历.cls

\ProvidesClass{resume}[2010/07/10 v0.9 Resume class]

\LoadClass[11pt,letterpaper]{article} % Font size and paper type

\usepackage[parfill]{parskip} % Remove paragraph indentation
\usepackage{array} % Required for boldface (\bf and \bfseries) tabular columns
\usepackage{ifthen} % Required for ifthenelse statements

% My custom packages
\usepackage{xcolor}
\usepackage{fancyhdr}

% My custom definitons
\definecolor{MyBlue}{HTML}{013587}

\pagestyle{empty} % Suppress page numbers

%----------------------------------------------------------------------------------------
%   HEADINGS COMMANDS: Commands for printing name and address
%----------------------------------------------------------------------------------------


\pagestyle{plain}% Set page style to plain.
\def \name#1{\def\@name{#1}} % Defines the \name command to set name
\def \@name {} % Sets \@name to empty by default

\def \addressSep {\space\textbar\space}
% \def \addressSep {$\diamond$} % Set default address separator to a diamond


% One, two or three address lines can be specified 
\let \@addressone \relax
\let \@addresstwo \relax
\let \@addressthree \relax

% \address command can be used to set the first, second, and third address (last 2 optional)
\def \address #1{
  \@ifundefined{@addresstwo}{
    \def \@addresstwo {#1}
  }{
  \@ifundefined{@addressthree}{
  \def \@addressthree {#1}
  }{
     \def \@addressone {#1}
  }}
}

% \printaddress is used to style an address line (given as input)
\def \printaddress #1{
  \begingroup
    \def \\ {\addressSep\ }
    \centerline{#1}
  \endgroup
  \par
  \addressskip
}


% \printname is used to print the name as a page header
\def \printname {
  \begingroup
    \hfil{\MakeUppercase{\namesize\bf \@name}}\hfil
    \nameskip\break
  \endgroup
}

%----------------------------------------------------------------------------------------
%   PRINT THE HEADING LINES
%----------------------------------------------------------------------------------------


% THE PROBLEM!!!!!!!!!!
\renewcommand\headrulewidth{0pt} % remove the header rule

\let\ori@document=\document
\renewcommand{\document}{
  \ori@document  % Begin document
  
    \newgeometry{left=0.75in,top=1.6in,right=0.75in,bottom=0.6in}
    \pagestyle{fancy} % the default page style for the document
    
    \fancyhead[C]{
        \printname % Print the name specified with \name
          \@ifundefined{@addressone}{}{ % Print the first address if specified
            \printaddress{\@addressone}}
          \@ifundefined{@addresstwo}{}{ % Print the second address if specified
            \printaddress{\@addresstwo}}
             \@ifundefined{@addressthree}{}{ % Print the third address if specified
            \printaddress{\@addressthree}}
    }
    

}



%----------------------------------------------------------------------------------------
%   SECTION FORMATTING
%----------------------------------------------------------------------------------------

% Defines the rSection environment for the large sections within the CV
\newenvironment{rSection}[1]{ % 1 input argument - section name
  \sectionskip
  \textcolor{MyBlue}{\MakeUppercase{\bf #1}} % Section title
  \sectionlineskip
  \hrule % Horizontal line
  \begin{list}{}{ % List for each individual item in the section
    \setlength{\leftmargin}{1.5em} % Margin within the section
  }
  \item[]
}{
  \end{list}
}

%----------------------------------------------------------------------------------------
%   WORK EXPERIENCE FORMATTING
%----------------------------------------------------------------------------------------

\newenvironment{rSubsection}[4]{ % 4 input arguments - company name, year(s) employed, job title and location
 {\bf #1} \hfill {#2} % Bold company name and date on the right
 \ifthenelse{\equal{#3}{}}{}{ % If the third argument is not specified, don't print the job title and location line
  \\
  {\em #3} \hfill {\em #4} % Italic job title and location
  }\smallskip
  \begin{list}{$\cdot$}{\leftmargin=0em} % \cdot used for bullets, no indentation
   \itemsep -0.5em \vspace{-0.5em} % Compress items in list together for aesthetics
  }{
  \end{list}
  \vspace{0.5em} % Some space after the list of bullet points
}

% The below commands define the whitespace after certain things in the document - they can be \smallskip, \medskip or \bigskip
\def\namesize{\huge} % Size of the name at the top of the document
\def\addressskip{\smallskip} % The space between the two address (or phone/email) lines
\def\sectionlineskip{\medskip} % The space above the horizontal line for each section 
\def\nameskip{\bigskip} % The space after your name at the top
\def\sectionskip{\medskip} % The space after the heading section

简历.tex

\documentclass{resume} % Use the custom resume.cls style

\usepackage{lipsum}
\usepackage[left=0.75in,top=0.6in,right=0.75in,bottom=0.6in]{geometry} % Document margins
\usepackage{times}
\usepackage{fontawesome}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{array}
\usepackage{tikz}
\newcommand{\tab}[1]{\hspace{.2667\textwidth}\rlap{#1}}
\newcommand{\itab}[1]{\hspace{0em}\rlap{#1}}
\def\ci#1{\textcircled{\resizebox{0.55em}{!}{#1}}}

% header
\name{name}  
\address{  
    {{\faPhone} {\fontsize{10}{10} \selectfont (+00)00000000}} \\
    {{\faEnvelope} {\fontsize{10}{10} \selectfont \href{mailto:[email protected]}{[email protected]} }} \\
    {{\faLinkedin} {\fontsize{10}{10} \selectfont \href{https://www.linkedin.com}{name} }}
}

\begin{document}

\begin{rSection}{section 1}

\lipsum[2-4]
\end{rSection}


\begin{rSection}{section 2}
\lipsum[1-2]
\end{rSection}

\clearpage

\begin{rSection}{section 3}
\lipsum[2-4]
\end{rSection}

\begin{rSection}{section 4}
\lipsum[1-2]
\end{rSection}



\end{document}

答案1

感谢大家的评论,我解决了这个问题。问题在于,正如 Ulrike 所说,标题占用了太多空间,我不得不通过添加几何参数headheight并赋予其更大的值来弥补这一点。然而,Simon 注意到,出于某种原因,在 TeXworks 而不是 Overleaf 中渲染它似乎会自动解决这个问题。

相关内容