[Tex/LaTex] Using `\headsep` with the geometry and fanchyhdr packages

geometryheader-footer

I thought that the text on the page was supposed to start \headsep below the header, but that does not seem to be the case when I use the geometry and fancyhdr packages

\documentclass{article}
\usepackage{geometry}
\usepackage{fancyhdr}
\fancypagestyle{foo}{\renewcommand{\headrulewidth}{1pt}\fancyhead[L]{\hrulefill\hspace{\fill}}}
\pagestyle{foo}
\geometry{includeall, vmargin=0pt, headheight=\baselineskip, headsep=72pt}
\begin{document}
\vspace*{-\headsep}\hrulefill\par
\vspace{\fill}
\end{document}

How much \vspace needs to be added so that the \hrulefill in the body lines up with the fanchyhdr rule? What about so the \hrulefill in the body lines up with the rule in \fancyhead[L]?

Best Answer

\hrulefill (unlike \hrule) starts a paragraph so you need

\documentclass{article}
\usepackage{geometry}
\usepackage{fancyhdr}
\fancypagestyle{foo}{\renewcommand{\headrulewidth}{1pt}\fancyhead[L]{\hrulefill\hspace{\fill}}}
\pagestyle{foo}
\geometry{includeall, vmargin=0pt, headheight=\baselineskip, headsep=72pt}
\begin{document}
\vspace*{\dimexpr-\topskip-\headsep-\baselineskip+0.4pt\relax}\hrulefill\par
\vspace{\fill}
\end{document}
Related Question