Vertical alignment of headers and footers with fancyhdr

fancyhdrheader-footervertical alignment

I have seen this, this and this questions and tried all the solutions in the answers. None of them has worked so far.

\documentclass[11pt,a4paper]{article}

\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage[left=2.00cm, right=3.00cm, top=0.75cm, bottom=4.50cm, includefoot, includehead, headsep=1.5cm]{geometry}

\pagestyle{fancy}
\fancyhf{}

\renewcommand{\headrulewidth}{1.5pt}

\setlength{\headheight}{150pt}

\lhead{{\textbf{{\Large Meine\\ schöne\\ Schule}}}\\[3ex]\phantom{K}\\[3ex]
    Name:\\[3ex] Datum:\\[-0.5ex]}%
%\chead{}
\rhead{{\textbf{{\Large Arbeitsblatt Mathematik\\ Binomische Formeln}}}\\[3ex] Klasse 8\underline{\phantom{unaclasse}}\\[3ex]
    Seite \thepage/\pageref{LastPage}\\[-0.5ex]}

\setlength{\parindent}{0pt}

\begin{document}
    
    \section*{Some section title here}
    
    The main body of the section here.

\end{document}

I get the space between "Meine", "schöne" and "Schule" inconsistent and, especially annoying, the left and right footer do not vertically align. I have also tried several linebreaks (\\[...]) and with them I could get it acceptable, but every time I change something, I have to adjust it all over again.

Result of MWE

Anything else I could try?

Best Answer

The inconsistency between the text elements is because a font size change (like \Large) only applies the appropriate baseline skip once a paragraph is issued. You don't do that explicitly, only issuing \\. The following approach sets the header elements in tabulars that helps with this issue and presents things a bit more clearly.

Note the tabular alignment is set to [b]ottom to assure proper alignment.

enter image description here

\documentclass{article}

\usepackage{fancyhdr}
\usepackage{lastpage}

\pagestyle{fancy}
\fancyhf{}% Clear header/footer
\renewcommand{\headrulewidth}{1.5pt}
\setlength{\headheight}{150pt}
\fancyhead[L]{\begin{tabular}[b]{ @{} l }
  \bfseries\Large
  \begin{tabular}[b]{ @{} l }
    Meine \\ schöne \\ Schule
  \end{tabular} \\[3ex]
  Name: \\[3ex]
  Datum:
\end{tabular}
}%
\fancyhead[R]{\begin{tabular}[b]{ r @{} }
  \bfseries\Large
  \begin{tabular}[b]{ r @{} }
    Arbeitsblatt Mathematik \\
    Binomische Formeln
  \end{tabular} \\[3ex]
  Klasse 8 \rule{4em}{.4pt} \\[3ex]
  Seite \thepage/\pageref{LastPage}
\end{tabular}
}
\setlength{\parindent}{0pt}

\begin{document}

\section*{Some section title here}

The main body of the section here.

\end{document}

If you want the two heading components (those in \bfseries\Large) to be top-aligned, add a \strut on a new line for the Right header:

\fancyhead[R]{\begin{tabular}[b]{ r @{} }
  \bfseries\Large
  \begin{tabular}[b]{ r @{} }
    Arbeitsblatt Mathematik \\
    Binomische Formeln \\
    \strut
  \end{tabular} \\[3ex]
  Klasse 8 \rule{4em}{.4pt} \\[3ex]
  Seite \thepage/\pageref{LastPage}
\end{tabular}
}

enter image description here

Related Question