1

MWE:

\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}

How can I set the vertical size of the top margin on the first page?

And on the second page there is empty vertical space at the top:

enter image description here

It also shifts bottom footer pagination to the edge of the page:

enter image description here

user4035
  • 5,035
  • 6
  • 40
  • 57

2 Answers2

1

As a simple remedy, don't use your fancy header on the first page just put the header text at the start of the page. Below is a crudely revised version of your 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}
Peter Wilson
  • 28,066
1

Set your page dimensions to what will be used for the bulk of your document, and adjust the pages that differ from that. It's especially easy when working with a "first" and "other" page layout. Below is a mockup-of the suggestion:

enter image description here

\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}

The large (first page) header is set insert a 0pt-height box (using \raisebox{-\height}[0pt][0pt]) and an additional \vspace* is added before the document start to accommodate for the larger header.

Werner
  • 603,163