[Tex/LaTex] Increasing \footheight with scrlayer-scrpage

header-footerkoma-scriptscrlayer-scrpage

I am experiencing a very strange issue. I am using scrlayer-scrpage to generate headers and footers. For headers, everything works great, but for footers, on every next page the footer height is getting larger (see example). What could be the reason for this?..

\documentclass{scrartcl}

\usepackage[headsepline]{scrlayer-scrpage}
\ifoot[\the\footheight\quad\rule{2px}{\footheight}]{\the\footheight\quad\rule{2px}{\footheight}}

\usepackage{lipsum}
\title{test}

\begin{document}

\lipsum[1-40]

\end{document}

enter image description here

Best Answer

\footheight is total height of the foot, including height (space above the baseline) and depth (space below the baseline) of the foot.

Your rule starts on the baseline. So the height of the foot must be at least the height of your rule plus the depth of a \strutbox. Therefore scrlayer-scrpage enlarges the former \footheight by \dp\strutbox. On the next page your rule starts again on the baseline and so scrlayer-scrpage enlarges the\footheight from the last page by \dp\strutbox again ...

You can shift the rule down by \dp\strutbox:

\documentclass{scrartcl}
\usepackage[headsepline]{scrlayer-scrpage}

\ifoot*{\the\footheight\quad\rule[-\dp\strutbox]{2px}{\footheight}}

\usepackage{lipsum}
\begin{document}
\lipsum[1-40]
\end{document}

enter image description here

Or you have to shorten the rule \dp\strutbox

\documentclass{scrartcl}
\usepackage[headsepline]{scrlayer-scrpage}

\ifoot*{\the\footheight\quad\rule{2px}{\dimexpr\footheight-\dp\strutbox\relax}}

\usepackage{lipsum}
\begin{document}
\lipsum[1-40]
\end{document}

enter image description here

Or you can hide the height of the rule using \smash

\documentclass{scrartcl}
\usepackage[headsepline]{scrlayer-scrpage}

\ifoot*{\the\footheight\quad\smash{\rule{2px}{\footheight}}}

\usepackage{lipsum}
\begin{document}
\lipsum[1-40]
\end{document}

enter image description here


Note that

\ifoot*{\the\footheight\quad\rule[-\dp\strutbox]{2px}{\footheight}}

is a short version of

\ifoot
  [{\the\footheight\quad\rule[-\dp\strutbox]{2px}{\footheight}}]
   {\the\footheight\quad\rule[-\dp\strutbox]{2px}{\footheight}}
Related Question