[Tex/LaTex] Inconsistent margins using fancyhdr and geometry

fancyhdrgeometryheader-footermargins

For my homework assignments I usually use the fancyhdr package to create a header that contains the group (A, B, C etc), homework title, my name + student number and the date. Besides that I practically always use the geometry package to adjust the page margins.

The problem that appears is that the margins seem to change per page, or more specific: the margins of the first page differ from the others. As an illustration of the problem, consider the following MWE.

\documentclass[a4paper]{article}
\usepackage{fancyhdr,lipsum} % lipsum for filler text
\usepackage[margin=4.4cm]{geometry}
\begin{document}
\lhead{Group, homework corrector\\$\,$\\}
\rhead{Homework title\\Name (student number)\\\today}
\pagestyle{fancy}
\lipsum[1-5]    % filler text
\newpage
\lipsum[6-10]   % filler text
\newpage
\lipsum[11-15]  % filler text
\end{document}

Here [a4paper] seems necessary to not let geometry change the dimensions of the paper, lipsum is used for filling, and there are 3 pages written to show that the second and third have the same margins, which differ from those of the first page. The problem should not come from a conflict between fancyhdr and geometry, as it does also arise when the latter is commented out.

Now there are two things I try to achieve, with the corresponding questions:

  1. How do I ensure consistent margins troughout the document, as
    described above?
  2. How do I get the text on the second and following pages to start at
    the height the header starts at on the first page when using
    \thispagestyle{fancy} instead of \pagestyle{fancy}?

I have tried to solve the second point by redefining the length of \headheight, but it seems sloppy to me, as there's no way to be sure the header adds exactly that height on the first page. Here's what I have tried to solve this second problem:

\documentclass[a4paper]{article}
\usepackage{fancyhdr,lipsum} % lipsum for filler text
\usepackage[margin=4.4cm]{geometry}
\begin{document}
\lhead{Group, homework corrector\\$\,$\\}
\rhead{Homework title\\Name (student number)\\\today}
\thispagestyle{fancy}
\lipsum[1-5]    % filler text
\newpage
\setlength{\headheight}{-3\baselineskip}
\lipsum[6-10]   % filler text
\newpage
\lipsum[11-15]  % filler text
\end{document}

Best Answer

Add headheight=35pt to the geometry options (showframe is here only to show clearly the result).

\documentclass[a4paper]{article}
\usepackage{fancyhdr,lipsum} % lipsum for filler text
\usepackage[margin=4.4cm,headheight=35pt,showframe]{geometry}
\begin{document}
\lhead{Group, homework corrector\\$\,$\\}
\rhead{Homework title\\Name (student number)\\\today}
\pagestyle{fancy}
\lipsum[1-5]    % filler text
\newpage
\lipsum[6-10]   % filler text
\newpage
\lipsum[11-15]  % filler text
\end{document}

enter image description here

How do you get the 35pt? If I don't add the option, in the log file (and on the terminal) I get the warning

Package Fancyhdr Warning: \headheight is too small (12.0pt):
 Make it at least 34.54448pt.
 We now make it that large for the rest of the document.
 This may cause the page layout to be inconsistent, however.
Related Question