Extra vertical space in header when using scrlayer-scrpage

I am trying to create a custom header including an image with a certain height. In an recent project, I have used the fancyhdr which worked pretty well. However, as the usage of fancyhdr together with KOMA classes is discouraged I would like to switch to scrlayer-scrpage.

Basically, it works but extra vertical space is added below the image. This looks strange and yields an overfull vbox warning. The following MWE demonstrates this behaviour:

\documentclass[twoside]{scrartcl}
%
\newlength{\theLogoHeight}
\setlength{\theLogoHeight}{10mm}
%
\usepackage[showframe]{geometry}
\newgeometry{top=3\theLogoHeight,
footskip=\theLogoHeight,
bottom=2\theLogoHeight,
inner=2\theLogoHeight,
outer=2\theLogoHeight
}
%
\RequirePackage{scrlayer-scrpage}
\clearpairofpagestyles
\newpairofpagestyles{firstpage}{%
\rule{0.1cm}{\theLogoHeight}%
}%
}
%
\begin{document}
\thispagestyle{firstpage}
Test Text Test Text Test Text Test Text Test Text Test Text
\end{document}


What is the reason for this extra vertical space? And how can I get rid of it?

headheight is the total height of the page header, i.e. the height plus the depth of the header. Your logo is put on the baseline with the height \theLogoHeight. So the height of the header must be at least \theLogoHeight, but there is also the depth of the header which depends on the font size.

Example to visualize the size of header depth:

\chead{%
\rule[-\dp\strutbox]{0.1cm}{\dp\strutbox}% to visualize the depth of the header
Example%
\rule[-\dp\strutbox]{0.1cm}{\dp\strutbox}% to visualize the depth of the header
\rule{0.1cm}{\theLogoHeight}%
}


You can enlarge headheight and reduce headsep or you can raise down the logo by \dp\strutbox:

\documentclass[twoside]{scrartcl}
%
\newlength{\LogoHeight}
\setlength{\LogoHeight}{10mm}
%
\usepackage[showframe]{geometry}
\newgeometry{top=3\LogoHeight,
footskip=\LogoHeight,
bottom=2\LogoHeight,
inner=2\LogoHeight,
outer=2\LogoHeight
}

\usepackage{scrlayer-scrpage}% sets page style scrheadings automatically
\clearpairofpagestyles
\newpairofpagestyles{firstpage}{%
\chead{\raisebox{-\dp\strutbox}{\rule{0.1cm}{\LogoHeight}}}% <- raise down the logo
}

\begin{document}
\thispagestyle{firstpage}
Test Text Test Text Test Text Test Text Test Text Test Text
\end{document}


The remaining space between the logo and the text body is defined by the value of headsep in your geometry options. You can reduce this value or remove the option to get a smaller sep between page header and text body.

• Thanks a lot, it works like a charm now! Tricky follow-up problem though, as I want to position three lines of text next to the logo. But I'll play around first... Jan 12, 2020 at 0:54
• I ended up just adding some extra space to headheight -- then both text (in a vbox) and image fitted in nicely without any warning. The extra space is calculated with 0.3\baselineskip or \dp\strutbox, which should yield the same, right? Jan 12, 2020 at 18:18