Page LayoutProblem with "fancyhdr" header separation

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ivan_hr
Posts: 18
Joined: Fri Dec 10, 2010 12:32 pm

Problem with "fancyhdr" header separation

Post by ivan_hr »

Hello,

I have exactly the same problem as M.A. did. Here is the link to his/her post.
http://www.latex-community.org/forum/vi ... 47&t=10684
I've tried the suggested solution but unfortunately it didn't work out in my case.
Note that I'm not using the fullpage package.

Here is my code

Code: Select all

\usepackage{amsmath,array}
\usepackage[pdftex]{graphicx}
\usepackage{fancyhdr}
....
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\headsep = 1.5cm
\voffset = -1.5cm
\hoffset = -0.5cm

\begin{document}
\fancyhead[L]{\includegraphics[scale=0.38]{picture.pdf}}
text follows
For some reason header separation is smaller for the first page than it is for subsequent pages. I can't even add extra space between header and first lines of my document (on the first page) manualy with \vspace{} or \blankline.

Does anyone know what might be the problem here?
Thanks in advance.
Last edited by ivan_hr on Thu Feb 10, 2011 12:36 pm, 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.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

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

Problem with "fancyhdr" header separation

Post by localghost »

The values for horizontal and vertical offset should never be adjusted manually unless for some reason you have trouble with your printer hardware. Furthermore, if something doesn't work, you should be more precise in describing the malfunction. Furthermore you should always provide a full example. Otherwise the problem is not comprehensible for others.

Page and paper dimensions are usually specified by packages like geometry. For that reason I don't understand why the introduced solution in the topic you linked shouldn't work. It's up to you to show exactly what is not working by a minimal example.


Thorsten
ivan_hr
Posts: 18
Joined: Fri Dec 10, 2010 12:32 pm

Problem with "fancyhdr" header separation

Post by ivan_hr »

I'm sorry if my example wasn't clear enough the first time.

My problem is that the separation between the header and the remaining text is not the same on the first page and on subsequent pages. You can see this clearly in the attachments. Notice that the separation between header and the rest of the text is much smaller in the first attachment (Page1.png) than in the second (Page2.png). I want it to be the same naturally. Here is a modified (minimal) code that produces this undesired behavior.

Code: Select all

\documentclass[12pt]{article}

\usepackage[pdftex]{graphicx}
\usepackage{fancyhdr}

\oddsidemargin=0in \evensidemargin=0in \textwidth=6.2in
\topmargin=0in \textheight=8in

\listfiles
\fancyhead[L]{\includegraphics[scale=0.4]{logo.pdf}}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\headsep = 1.5cm

\begin{document}

THIS IS SOME TEXT
\newpage
THIS IS SOME TEXT 

\end{document}
I would be grateful if someone can help. Thanks.
Attachments
Page1.png
Page1.png (6.99 KiB) Viewed 12815 times
Page2.png
Page2.png (7.42 KiB) Viewed 12815 times
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Problem with "fancyhdr" header separation

Post by frabjous »

You have already been instructed to attempt to use the geometry package. Please try this, and let us know whether you still have the same problems.

Also, you should know that your sample code is useless to us without logo.pdf, since we cannot compile your code. See the Post on Avoidable Mistakes. Either supply that, or replace it with a \rule{<width>}{<height>} command of the same size.
ivan_hr
Posts: 18
Joined: Fri Dec 10, 2010 12:32 pm

Problem with "fancyhdr" header separation

Post by ivan_hr »

I've tried running the code listed below instead but I'm still getting the same undesired output.

Code: Select all

\documentclass[12pt]{article}

\usepackage[pdftex]{graphicx}
\usepackage{fancyhdr}
\usepackage[margin=1in]{geometry}


\listfiles
\fancyhead[L]{\includegraphics[scale=0.4]{logo.pdf}}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\headsep = 1.5cm


\begin{document}

THIS IS SOME TEXT
\newpage
THIS IS SOME TEXT 

\end{document}
Here is the "logo.pdf" file that I'm using in my code:
Attachments
logo.pdf
(16.13 KiB) Downloaded 351 times
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Problem with "fancyhdr" header separation

Post by frabjous »

Hmm, I can confirm the problem. It seems to be a bug in fancyhdr as far as I can tell.

Could you use a different package for setting the headers and footers? The titlesec package has some commands for headers and footers. I don't have any problems with, e.g.:

Code: Select all

\documentclass[12pt]{article}

\usepackage{graphicx}
\usepackage{titlesec}
\usepackage[margin=1in,headsep=1.5cm]{geometry}

\renewpagestyle{headings}{
\sethead{\includegraphics[scale=0.4]{logo.pdf}}% left
        {}% center
        {}% right
\setfoot{}% left
        {\thepage}% center
        {}% right
}
\pagestyle{headings}

\begin{document}

THIS IS SOME TEXT
\newpage
THIS IS SOME TEXT
\end{document}
ivan_hr
Posts: 18
Joined: Fri Dec 10, 2010 12:32 pm

Re: Problem with "fancyhdr" header separation

Post by ivan_hr »

I've tried the code you suggested and it works fine now :)
Thank you very much.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Problem with "fancyhdr" header separation

Post by localghost »

From time to time you should listen to the compiler and look at what it tells you in the log file.

Code: Select all

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

Code: Select all

\usepackage[%
  margin=1in,
  headheight=50pt
]{geometry}
Just supplement your example accordingly and it will work just fine.
Post Reply