Page LayoutHeader image growing in every page

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
sk
Posts: 8
Joined: Wed Sep 08, 2010 10:11 am

Header image growing in every page

Post by sk »

Hi,

I am having problems inserting images in the header, using the package fancyhdr. The problem is that the images are getting bigger in everypage by itself. This is a small example code that ilustrates the problem:

Code: Select all

\usepackage[top=2cm, bottom=3cm, left=3cm, right=3cm]{geometry} 
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{lipsum}

\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\headheight}{40pt}

\fancyhf{}

\lhead{\includegraphics[height=\headheight , width=5in]{img/degradadoEncabezado.PNG}}
\chead{}
\rhead{\includegraphics[height=\headheight]{img/logoEncabezado.PNG}}
\rfoot{}
\cfoot{\thepage}
\lfoot{}

\begin{document}
\lipsum[1-50]
\end{document}
I attach the .tex file together with the images and the pdf file, so you can see the behaviour by yourselves. Any hints on how to solve the problem are deeply appreciated.

Thanks in advance
Attachments
example.zip
(59.63 KiB) Downloaded 142 times
Last edited by sk on Thu Sep 09, 2010 9:46 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Header image growing in every page

Post by localghost »

I guess I have found the probable cause of the problem. Compiling your code, I obtain warnings about an insufficient value for the length \headheight. The compiler tries to increase this length self-handed to balance that on every new page. Since you declared your images in dependence of that length, they become bigger. I suggest to scale your images with respect to the length \textwidth or with another fixed height and then accommodate \headheight as suggested by the compiler.

As soon as the problem is solved, please act exactly according to Section 3 of the Board Rules.


Best regards and welcome to the board
Thorsten
sk
Posts: 8
Joined: Wed Sep 08, 2010 10:11 am

Header image growing in every page

Post by sk »

Thanks, that information help me to solve the problem. I just hard-coded the height of the images as the same height of the header, without using the macro

Code: Select all

\headheight
Post Reply