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:
- How do I ensure consistent margins troughout the document, as described above?
- 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}
headheight=35pt
to the options forgeometry
headheight
both up and down. For example: both atheadheight=10pt
and atheadheight=35pt
there seems to be about one\baselineskip
difference between the top of the header and the top of the text on the second page.headheight=35pt
as said to your first example, I get identical positioning on both pages.