第一页和后续页面使用不同的页眉

第一页和后续页面使用不同的页眉

梅威瑟:

\documentclass{article}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2cm,bmargin=3cm,lmargin=2cm,rmargin=2cm}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage[english]{babel}
\usepackage{fancyhdr}
\usepackage{lastpage}
\fancypagestyle{firststyle}
{
  \fancyhf{}% Clear header/footer
  \renewcommand{\headrulewidth}{0pt}
  \fancyhead[L]{\begin{minipage}{.45\textwidth}Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1
      \\\\
      \makebox[\textwidth]{\hrulefill}
    \end{minipage}
  }
  \fancyhead[R]{\begin{minipage}{.45\textwidth}Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2
      \\\\
      \makebox[\textwidth]{\hrulefill}
    \end{minipage}
  }
  \fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
}
\fancypagestyle{plain}
{
  \fancyhf{}% Clear header/footer
  \renewcommand{\headrulewidth}{0pt}
  \fancyhead[L]{}
  \fancyhead[R]{}
  \fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
}
\pagestyle{plain}
\pagenumbering{arabic}
\usepackage{lipsum}
\begin{document}
\thispagestyle{firststyle}
\lipsum[1-18]
\end{document}

如何设置第一页上边距的垂直大小?

第二页顶部有一个空白的垂直空间:

在此处输入图片描述

它还将底部页脚分页移至页面边缘:

在此处输入图片描述

答案1

将页面尺寸设置为文档主体所需的尺寸,并调整与之不同的页面。使用“第一页”和“其他”页面布局时尤其容易。以下是建议的模型:

在此处输入图片描述

\documentclass{article}

\usepackage{geometry}
\geometry{
  tmargin=2cm,
  bmargin=3cm,
  hmargin=2cm
}

\usepackage{fancyhdr}
\usepackage{lastpage}

\fancypagestyle{firststyle}{
  \fancyhf{}% Clear header/footer
  \renewcommand{\headrulewidth}{0pt}% Remove header rule
  \fancyhead[L]{\raisebox{-\height}[0pt][0pt]{\begin{minipage}{.45\textwidth}
      Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1 
      Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1 \endgraf
      \medskip
      \rule{\linewidth}{.4pt}
    \end{minipage}}
  }
  \fancyhead[R]{\raisebox{-\height}[0pt][0pt]{\begin{minipage}{.45\textwidth}
      Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2 
      Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2 \endgraf
      \medskip
      \rule{\linewidth}{.4pt}
    \end{minipage}}
  }
  \fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
}
\fancypagestyle{plain}{
  \fancyhf{}% Clear header/footer
  \renewcommand{\headrulewidth}{0pt}% Remove header rule
  \fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
}
\pagestyle{plain}
\usepackage{lipsum}

\begin{document}

\thispagestyle{firststyle}

\vspace*{2\baselineskip}

\sloppy\lipsum[1-20]

\end{document}

大(第一页)页眉设置为插入一个0pt高度框(使用\raisebox{-\height}[0pt][0pt])和一个附加\vspace*在文档开始之前添加以适应更大的标题。

答案2

一个简单的补救措施是,不要在第一页使用花哨的标题,只需将标题文本放在页面开头即可。以下是您的 MWE 的粗略修订版本。

    % headerprob.tex  SE 517975 header space on first page

\documentclass{article}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2cm,bmargin=3cm,lmargin=2cm,rmargin=2cm}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage[english]{babel}
\usepackage{fancyhdr}
\usepackage{lastpage}

\usepackage{comment}

\begin{comment}

\fancypagestyle{firststyle}
{
  \fancyhf{}% Clear header/footer
  \renewcommand{\headrulewidth}{0pt}
  \fancyhead[L]{\begin{minipage}{.45\textwidth}Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1
      \\\\
      \makebox[\textwidth]{\hrulefill}
    \end{minipage}
  }
  \fancyhead[R]{\begin{minipage}{.45\textwidth}Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2
      \\\\
      \makebox[\textwidth]{\hrulefill}
    \end{minipage}
  }
  \fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
}

\end{comment}

\fancypagestyle{plain}
{
  \fancyhf{}% Clear header/footer
  \renewcommand{\headrulewidth}{0pt}
  \fancyhead[L]{}
  \fancyhead[R]{}
  \fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
}
\pagestyle{plain}
\pagenumbering{arabic}
\usepackage{lipsum}
\begin{document}
%\thispagestyle{firststyle}

\begin{minipage}{.45\textwidth}Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1 Accepted by CEO company 1
      \\\\
      \makebox[\textwidth]{\hrulefill}\\\\
    \end{minipage}
\hfill
\begin{minipage}{.45\textwidth}Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2 Accepted by CEO company 2
      \\\\
      \makebox[\textwidth]{\hrulefill}\\\\
    \end{minipage}


\lipsum[1-18]
\end{document}

相关内容