使用 fancyhdr 包时,标题部分会在 Latex 的每个页面上重复。由于我只想在第一页上显示标题,如何避免重复?

问题描述 投票:0回答:1

我使用了背面的“数据科学技术简历模板”模板来构建我自己的简历。 “_header.tex”文件包含“fancyhdr”包的使用,并使用 lheader 和 rheader 来显示我的姓名、电子邮件 ID、联系人等。但是,此标题部分在每个页面上重复。 1st Page 2nd Page

下面是_header.tex的代码:

\RequirePackage{fancyhdr}
    \fancypagestyle{plain}{%
    \fancyhf{}
    \lhead{
    
            \HUGE \skills \name \vspace{-.32em}
            \\ % feel free to adjust vspace to 0 
        {
                \color{highlight} \Large{\role}
            }
    } 
    \rhead{
        
            \city \\  % city 
            \phone \\ % PHONE    
            \href{mailto:\email}{\email} \\
            % \href{https://github.com/\github}{github.com/\github} \\% Github
            \href{https://www.linkedin.com/in/\LinkedIn}{linkedin.com/in/\LinkedIn}
    } 
\renewcommand{\headrulewidth}{1pt}% 2pt header rule
\renewcommand{\headrule}{\hbox to\headwidth{%
  \color{highlight}\leaders\hrule height \headrulewidth\hfill}}
}
\pagestyle{plain}

\setlength{\headheight}{90pt}
\setlength{\headsep}{5pt}

我希望标题避免在第二页重复。有人可以帮我解决这个问题吗,因为我是新手?

latex overleaf
1个回答
0
投票

我想我找到了一个可能对您有帮助的解决方案。

  • 首先,您需要将
    \RequirePackage{fancyhdr}
    _header.tex 移动到 TLCresume.sty
  • 其次,从
    _header.tex
    中删除 \fancypagestyle{plain} 并将
    \pagestyle{plain}
    更改为 \pagestyle{fancy}。
  • 第三,创建一个新文件(例如test.tex),其中包含第二页的内容,并更改resume.tex的代码。

这就是修改后的 resume.tex 文件的样子。

\begin{document}

% input header goes inside "document"
\input{_header}

\input{sections/objective}

\section{Skills}
\input{sections/skills}

\section{Technical Experience}
\input{sections/experience}

\section{Education}
\input{sections/education}

\section{Activities}
\input{sections/activities}

% this is where 2nd page starts
\newpage
\pagestyle{plain}
\setlength{\headheight}{50pt}
\setlength{\headsep}{0pt}

% content of the 2nd page
\section{Test}
\input{sections/test}

\end{document}
© www.soinside.com 2019 - 2024. All rights reserved.