4

I'm trying to keep body text inside its box but it overlaps the header. I tried using \voffset, \headsep and \headheight, but it seems they do not work as I expect

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{showframe,blindtext,fontawesome} 
\usepackage{fancyhdr}
\usepackage[a4paper, nomarginpar,margin=1in]{geometry}
\pagestyle{fancy}
\rhead{
    {
        \fontsize{40pt}{60pt}\selectfont
        Foo Bar\\
    }
    555\faPhone\\
    555\faPhone\\
    555\faPhone\\
\noindent\makebox[\linewidth]{\rule{\linewidth}{0.4pt}}
}
\begin{document}
\blindtext
\end{document}
2

Please have a look into the logfile of your code. There you find:

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

That means you have to add an command to enlarge the \headheight to 81pt:

\setlength{\headheight}{81pt}

With the following MWE

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{blindtext,fontawesome} 
\usepackage{fancyhdr}
\usepackage[showframe, nomarginpar,margin=1in]{geometry}
\pagestyle{fancy}
\rhead{
    {
        \fontsize{40pt}{60pt}\selectfont
        Foo Bar\\
    }
    555\faPhone\\
    555\faPhone\\
    555\faPhone\\
\noindent\makebox[\linewidth]{\rule{\linewidth}{0.4pt}}
}
\setlength{\headheight}{81pt} % <=======================================

\begin{document}
\blindtext
\end{document}

you get the result:

enter image description here

0
3

Your header is too tall and fancyhdr warns you about this:

Package Fancyhdr Warning: \headheight is too small (12.0pt): 
 Make it at least 80.59785pt.
 We now make it that large for the rest of the document.
 This may cause the page layout to be inconsistent, however.

The important part here is that you'll see the header fitting better from page two onward.

enter image description here

Below is a similar example with an oversized image requiring at least 63.60004pt; setting headheight to 65pt is sufficient:

enter image description here

\documentclass{article}
\usepackage{fancyhdr,graphicx,blindtext}
\usepackage{geometry}
\geometry{
  margin = 1in, % Set all margins to 1in
  headheight = 65pt, % Update header height to accommodate for large content
  tmargin = \dimexpr1in+65pt % Update top margin to accommodate for large header content
}

\rhead{\includegraphics[height=5\baselineskip]{example-image}}% Something big
\pagestyle{fancy}

\begin{document}

\blindtext[50]

\end{document}
1
  • Thank you @Werner, your solution adjusts the header but body text seems to be misaligned, at least in my example. – Rod Dec 5 '18 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.