Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing a short note. I would like to include a graphics file with a logo in the header of all pages including the front page. The logo is roughly the size of the box generated in the example below.

I am trying to use the fancyhdr package. There are (at least) two problems:

  1. Too little space between the logo and the title on the front page
  2. The page margin at the bottom of page 2 and subsequent pages is too small and moreover different from the bottom margin of the front page.

I realize that something has to give. Any suggestions? If I can use/tweak my headings as an alternative that would be fine too.

\documentclass[11pt,a4paper]{article}

\usepackage{lipsum}
\usepackage{graphicx}

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\chead{\rule{360pt}{70pt}} % instead of \chead{\includegraphics{top.jpg}}

\begin{document}
\title{Title here} 
\date{November 2011}
\author{Jesper Jensen}
\maketitle

\thispagestyle{fancy}
\lipsum[1-9]
\end{document}
share|improve this question

3 Answers 3

After compiling your document you will receive the following warning:

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

To correct \headheight, add the following line to the preamble:

\setlength\headheight{74.1pt}

Another option would be to use the background package to add the image at the desired position:

\documentclass[11pt,a4paper]{article}
\usepackage{background}
\usepackage{graphicx}
\usepackage{lipsum}

\SetBgContents{\rule{360pt}{70pt}}% \includegraphics would be here
\SetBgAngle{0}
\SetBgPosition{current page.north}
\SetBgOpacity{1}
\SetBgScale{1}
\SetBgColor{black}
\SetBgVshift{-2.5cm}

\title{Title here} 
\date{November 2011}
\author{Jesper Jensen}

\begin{document}
\maketitle

\lipsum*[1-9]
\end{document}
share|improve this answer

You've to add the necessary height to \headheight: fancyhdr suggests to make it 74.08003pt, that is, 62.1 more than the default of 12pt.

However, this would push too low the text block, so we have to reduce the text height. The baseline skip at 11pt size is 13.6pt, and the nearest integer multiple to 62 of it is 68:

\setlength{\headheight}{75pt}    % round to the point
\addtolength{\textheight}{-68pt} % -5\baselineskip to avoid a too low text block

You might consider also reducing the top margin, say

\setlength{\headheight}{75pt}    % round to the point
\addtolength{\topmargin}{-2\baselineskip}
\addtolength{\textheight{-3\baselineskip}

so as to avoid shortening the text height too much. It mostly depends on your top page logo.

share|improve this answer
    
I'm trying to figure out what \addtolength{\textheight}{} should be when I have \setlength\headheight{42.5pt} and a font size of 12pt. Am I right in using \addtolength{\textheight}{-29pt}? (I think that -29pt is equal to -2\baselineskip.) –  Svend Tveskæg Nov 6 '13 at 3:54
1  
@SvendTveskæg Yes, at 12pt the baselineskip is 14.5pt; but \headheight depends on the material you want to put in the header. Let fancyhdr make the computation: just look at the warning message and act consequently. –  egreg Nov 6 '13 at 7:33

Beside adjusting the headheight, you can also set the height and depth of the graphics to zero with the option arguments of \raisebox and – if you want – raise the graphics with the mandatory argument.

\chead{\raisebox{0pt}[0pt][0pt]{\rule{360pt}{70pt}}}
 %               ^^^ change to raise. 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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