Page LayoutProblem with fancyhdr

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
M.A
Posts: 58
Joined: Sun Nov 30, 2008 10:42 am

Problem with fancyhdr

Post by M.A »

Hello Everybody!

I have strange problem with fancyhdr. I generated a header with certain header separation. However, the header separation is correct for all the document except its first occurrence!

Here is a minimal example:

Code: Select all

\documentclass[12pt,oneside]{book}


\usepackage{fullpage,fancyhdr,lipsum}
 
\pagestyle{fancy} 
\addtolength{\headsep}{15pt}

\chead{} \cfoot{} \lfoot{} \rfoot{}
 \rhead{\textbf{\thepage}}
 \lhead{\chaptername \ \thechapter}

\begin{document}

\chapter{This the title of chapter 1}
 \lipsum[1-20]
 
 \chapter{This the title of chapter 2}
 \lipsum[1-20]
\end{document} 
Note: the command lipsum generates dummy text only.

The attached images highlight the problem.
Attachments
1.png
1.png (65.56 KiB) Viewed 3451 times
2.png
2.png (69.23 KiB) Viewed 3451 times
3.png
3.png (73.38 KiB) Viewed 3451 times
Last edited by M.A on Mon Nov 08, 2010 8: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

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Problem with fancyhdr

Post by frabjous »

The problem seems to be caused by the fullpage package. I'd drop it and try to achieve the same thing with the geometry package (with margin=1in, for example). The geometry package has a lot more options, and you'll probably want to read the package documentation.

Note that by default there is spacing between the header and the first line of text--even more with your line \addtolength{\headsep}{15pt}! But with geometry it will be consistent and controllable. You can change it by changing \headsep. I think things look poor if you leave no space at all between the header and the text, but maybe something like 0.5ex would do.

Try, e.g.:

Code: Select all

\documentclass[12pt,oneside]{book}
\usepackage[margin=1in]{geometry}
\setlength{\headsep}{0.5ex}
\usepackage{fancyhdr,lipsum}
\pagestyle{fancy}

\chead{} \cfoot{} \lfoot{} \rfoot{}
\rhead{\textbf{\thepage}}
\lhead{\chaptername \ \thechapter}

\begin{document}

\chapter{This the title of chapter 1}
\lipsum[1-20]

\chapter{This the title of chapter 2}
\lipsum[1-20]
\end{document} 
M.A
Posts: 58
Joined: Sun Nov 30, 2008 10:42 am

Re: Problem with fancyhdr

Post by M.A »

I tried geometry package upon your suggestion. It worked with me and things are consistent now.
Thank you very much for help.

Best Regards,
M.A
Post Reply