This is going to be something so obvious that I'm almost embarrassed to ask! I've been using fancyhdr
to put some fancy headers and footers in my thesis template – in fact, doing what it says on the tin! A sample from the code is as follows:
\documentclass[chapterprefix=false]{scrreprt}
\usepackage{fancyhdr}
\usepackage[textheight=1.618\textwidth,
lmargin=37mm, rmargin=22mm, driver=pdftex,
heightrounded, headsep=7mm,
footskip=11mm, vmarginratio=1:1]{geometry}
\fancypagestyle{plain}{
\lhead{\small{Thesis Title}}
\chead{}
\rhead{\small{My Name}}
\lfoot{\small{Project Name}}
\cfoot{$-$~\thepage~$-$}
\rfoot{\small{Submission Date}}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}}
\pagestyle{plain}
I hope that's enough code for a diagnosis. Everything works fine, except that the header text is sitting immediately on top of the 'headrule' line with virtually no space between them – and I would like a little white space between the text and the line. Curiously all the examples in the fancyhdr
documentation show space between the header text and the line, but I can't fathom how to achieve this! It's straightforward enough with a footer, because there's an extra parameter \footruleskip
, but there doesn't seem to be an equivalent for the header. If anyone can help, it would be much appreciated.
Best Answer
The "modern" notation for
fancyhdr
is preferable. Note that\small
is not a command taking an argument, but rather a declaration.Adjust the dimension of the strut, that is, the invisible
\rule[-2ex]{0pt}{2ex}
to suit you.A strut is an invisible object that, however, contributes to the height (what's above the baseline) or the depth (what's below) of the line in which it is inserted. A rule of width zero is the ideal object, as we can control precisely its size. The
\rule
command has two mandatory arguments (width and height). With the optional argument we can dictate that it has also a depth. With this trick, the headline has a depth of 2ex (or what we prefer), so TeX will move down the headrule in order not to overlap the headline. It might turn out to be necessary to increase the space reserved for the headline; in this casefancyhdr
will issue a warning that can be found in the.log
file.Note that LaTeX has a
\strut
command, which inserts an invisible rule roughly as high and deep as a parenthesis (in this application it's insufficient).