# Problem

I'm trying to create fancy headers for my documents using fancyhdr. I want the headrule to be dotted, which can be achieved using

as stated in the fancyhdr-documentation on page 12. Now I also want to move the rule nearer to the content of the header. For the footer, there is \footruleskip , but unfortunately no \footruleskip. If I just elevate the box of the headrule by using \raisebox I get

Package Fancyhdr Warning: \headheight is too small (38.32509pt):
Make it at least 39.58127pt.

How do I automatically adjust \headheight or how can I get rid of the overfull box produced by raising the headrule box.

Bonus: Currently I specify \setlength{\headheight}{3.5em} because of the \Huge\thechapter. How can I automatically set \headheight?

# MWE

\documentclass{scrbook}
\usepackage{eso-pic}
\AtTextUpperLeft{%
}%
}%
}

\usepackage{fancyhdr}
\pagestyle{fancy}

% From fancyhdr documentation
\fancyhf{}
\begin{document}

\chapter{Test Chapter}
\eject

\hbox{}
\eject

\hbox{}

\end{document}

# Output

• If you \smash{\Huge\thechapter} and use \renewcommand{\headrule}{\raisebox{0.25\headheight}{\makebox[\headwidth]{\dotfill}}}, then I don't get any warnings. You still have to set \headheight manually. – Werner Nov 30 '13 at 14:22

Use the center field, without redefining \headrule:

\documentclass{scrbook}
\usepackage{fancyhdr}
\usepackage{picture} % directly specify lengths with their unit in picture commands
\usepackage{lipsum}
\usepackage{eso-pic}
\AtTextUpperLeft{%
}%
}%
}

\pagestyle{fancy}
\newcommand{\dotrule}{%
\makebox[0pt][l]{%
\hspace{-.5\textwidth}%
\raisebox{-8pt}{%
\makebox[\textwidth][l]{%
\kern-.00625\textwidth
\kern-.00625\textwidth
}%
}%
}%
}

% From fancyhdr documentation
\fancyhf{}
\begin{document}

\chapter{Test Chapter}
\lipsum

\end{document}

I defined “by hand” the dot filling, because \xleaders should be used.

Personal comment: I rarely saw something this ugly.

• Thank you for your answer and your opinion. I'm trying to recreate the pagestyle of this thesis (70MB). Do you have any suggestions for a more pleasing header? How do you get the 24.4pt for \headheight? – Henri Menke Nov 30 '13 at 16:06
• @HenriMenke Just don't set \headheight (or set it to zero) and look in the .log file for the warning fancyhdr emits. – egreg Nov 30 '13 at 16:10
• @HenriMenke The layout is not bad, but it has many defects. The chapter number in the header is too big; the dots have no place either. Usage of color is inconsistent: it doesn't make sense to use gray and colored backgrounds. The equations with a background have the equation number misplaced. Some notes are introduced by a blue title, others by a title with a dotted line. Skimming through it gives an overall impression of inconsistency. – egreg Nov 30 '13 at 16:23