![第一页和后续页面使用不同的页眉](https://linux22.com/image/405122/%E7%AC%AC%E4%B8%80%E9%A1%B5%E5%92%8C%E5%90%8E%E7%BB%AD%E9%A1%B5%E9%9D%A2%E4%BD%BF%E7%94%A8%E4%B8%8D%E5%90%8C%E7%9A%84%E9%A1%B5%E7%9C%89.png)
梅威瑟:
\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}