What I would like to achieve is a (fairly high) header in the first page and alternate headers with different heights for even and odd in the subsequent pages.
I tried Werner's solution from this page, but I have the problem that, like I said, the subsequent headers are of different heights in even and odd pages. Here is my document, although it's not really minimal
\documentclass[11pt,a4paper,twoside]{article}
\usepackage[ngerman]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{xcolor}
\usepackage{xltabular,multirow}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage[bottom]{footmisc}
\usepackage{blindtext}
\usepackage[left=2.00cm, right=3.00cm, top=2cm, bottom=2.0cm, headsep=1.50cm]{geometry} % Tried with other bottom margins. The footer disappears at the bottom of the page.
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor={red!60!black},
citecolor={blue!50!black},
urlcolor={blue!80!black},
}
\fancyhf{}
\sisetup{output-decimal-marker={,},group-minimum-digits=4}
% Header for first page
\fancypagestyle{ersteabph}{
\fancyhf{}% Clear header/footer
\renewcommand{\headrulewidth}{0pt}% Remove header rule
\setlength{\headheight}{160pt}
\fancyhead[C]{\begin{xltabular}{\textwidth}{p{9cm} p{8mm} X}
\raisebox{-\height}[0pt][0pt]{\textbf{{\Large Mybeautifulschool}}} & & \raisebox{-\height}[0pt][0pt]{\textbf{\Large Arbeitsblatt Physik}}\newline \raisebox{-\height}[0pt][0pt]{\textbf{\Large Elektrisches Feld}}\
Name: & & GPH1\
Datum: & & Seite \thepage/\pageref{LastPage}
\end{xltabular}\rule{\linewidth}{.4pt}
}
}
% Header for subsequent pages
\fancypagestyle{abph}{
\fancyhf{}
\setlength{\headheight}{120pt}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[CO]{\begin{xltabular}{\linewidth}{p{9cm} p{8mm} X}
\raisebox{-\height}[0pt][0pt]{\textbf{{\Large Mybeautifulschool}}} & & \raisebox{-\height}[0pt][0pt]{\textbf{\Large Arbeitsblatt Physik}}\newline \raisebox{-\height}[0pt][0pt]{\textbf{\Large Elektrisches Feld}}\
& & Seite \thepage/\pageref{LastPage}
\end{xltabular}}
\fancyhead[RE]{\raisebox{-\height}[0pt][0pt]{\thepage/\pageref{LastPage}}}
}
\pagestyle{abph}
\setlength{\parindent}{0pt}
\renewcommand{\arraystretch}{2.50}
\author{Myself}
\begin{document}
%\vspace*{3cm}
\section*{Versuch: die Energie des Kondensators.}
\thispagestyle{ersteabph}
\begin{minipage}[b]{0.5\textwidth}
\includegraphics[width=0.98\linewidth]{example-image-a}
\end{minipage}\hspace{0.1cm}%
\begin{minipage}[b]{0.5\textwidth}
\includegraphics[width=0.98\linewidth]{example-image-b}
\end{minipage}
\section*{Versuchsbeschreibung}
In diesem Versuch wollen wir die Abhängigkeit der in einem Kondensator gespeicherten Energie von der Spannung und von der Kapazität untersuchen. Dafür laden wir einen Kondensator zu einer gewissen Spannung und lassen ihn auf einem elektrischen Motor entladen. Am Motor hängt ein Gewicht mit gegebener Masse $m$. Der Motor kommt zum Laufen und hebt das Gewicht zu einer gewissen Höhe $h$. Die potentielle Energie $E_{\mathrm{pot}}$, die das Gewicht beim Anheben gewinnt, ist zur gespeicherten Energie im Kondensator proportional.\\
Der Versuch besteht aus zwei Teilen: zuerst wird ein Kondensator auf verschiedene Spannungen geladen. Die angegebene Spannung und die durch das Gewicht erreichte Höhe werden in eine Tabelle eingetragen. Dann werden Kondensatoren unterschiedlicher Kapazitäten auf die gleiche Spannung geladen und wir notieren wieder in eine Tabelle die Kapazität und die erreichte Höhe.\\
Beim Versuch ist auf folgendes zu achten:
\begin{itemize}
\item Der Motor hat leider keine Bremse, sodass das Gewicht wieder nach unten kommt, wenn es nicht angehalten wird. Warte, bis das Gewicht die maximale Höhe erreicht und halte es dann an dieser Stelle, sodass die Höhenmessung durchgeführt werden kann.
\item Beim ersten Teil wählen wir einen Kondensator mit Kapazität \SI{10}{\milli\farad} und die Ladespannungen \qtylist{4;6;8;10}{V}. Überschreitet bitte nicht die Spannung \SI{10}{V}, da sonst das Gewicht zu hoch kommt und am Ösen klemmt (außerdem würde das Ergebnis dadurch gefälscht).
\item Beim zweiten Teil wählen wir Kondensatoren mit Kapazität \qtylist{4.7;5;6.7;10}{\milli\farad} und die Spannung von \SI{9}{V}. Auch diese Werte wurden so gewählt, dass die Messdaten eine gute Auswertung ermöglichen.
\end{itemize}
\Blindtext[3][3]
\section*{Durchführung}
\end{document}
I also tried without adding the \setlength{\headheight} (suggested by the warnings), but leaving the \vspace*{} at the beginning of the document per Werner's answer in the linked question. That solution, however, has the problem that the header of the odd pages is too high and ends up in the text. I can't keep adding \vspace*{}s because I don't know in advance where a page ends (or at least it's not elegant).
Another thing I tried is a solution with \usepackage[pagestyles]{titlesec}, but that didn't work either (I can paste my not-so-minimal example of that if you want me to).
So basically:
- if I add the
\setlength{\headheight}, I have the problem that the top margins don't all look the same and the bottom margin is not right. - if I use the
\vspace*{}s, then the bottom margin is right, but I have to insert it manually and change it every time I add or remove something in the text (unless there is an automated way to do it that I don't know).
I'm ready to do away with the xltabulars in the headers, if there is another easy way to line up the lines of the header properly.
I am out of ideas to try and open to suggestions.
EDIT:
By the way, my question sounds exactly like this one, but that one is closed and has no answer.





\evenoddheadheightdiff, but I'm scared to try what happens if I have a tabular there... – Andyc Jan 10 '22 at 23:38\evenoddheadheightdiffto a value that matches the actual heights of your headers. I just picked(-)10exat random for my MWE. If the content of your header is taller than\headheight, it will overflow (and you will get a warning telling you about it). You'll have to calculate/measure/guess the correct value for your headers. Useshowframeto see the bounding box of your headers when picking the value. – schtandard Jan 11 '22 at 10:37\headheightdiffs: one for the first page and one for the subsequent pages. This just in case the first header is much taller than the one for the other odd pages, which would end up putting a lot of white space before the odd page header starting from page 3 and it wouldn't look nice. – Andyc Jan 11 '22 at 19:00