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 have created a custom simple layout with the fancyhdr package. Because the header I must use is somewhat big, LaTeX instructed me to increase the headheight to at least a minimum value. The problem is, the footer gets moved down until it eventually disappears.

Here is a MWE, where the footer can still be seen at the bottom:

\documentclass[12pt,a4paper,oneside]{article}
\usepackage[utf8]{inputenc}
\usepackage[landscape,left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{fancyhdr}

\setlength{\headheight}{60pt}
\pagestyle{fancy}

\lhead{This is header \\ This is header \\ This is header \\ This is header \\ This is header}
\chead{}
\rhead{}
\lfoot{}
\cfoot{This is the footer}
\rfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\begin{document}

First line of the document.

Second line of the document.

\end{document}

Now change 60pt for 80pt and compile again. Goodbye, footer!

Is there any way to fix this? I can't change the header, and I must have both header and footer.

Edit: The amount of support is incredible, 3 answers plus comments in one hour! Upvoting you all, and choosing most simple and idiot-proof solution as correct. Thanks!

share|improve this question
3  
Use the geometry options to change the headheight. –  Ulrike Fischer Mar 1 '13 at 9:28
    
Welcome to TeX.sx! –  Peter Jansson Mar 1 '13 at 9:41
1  
@PeterJansson Thanks! Quite a nice place to be in. –  user2061099 Mar 1 '13 at 11:34

3 Answers 3

up vote 6 down vote accepted

You may want to fiddle around with the includeheadfoot option that comes with the geometry package (and adjust your geometry settings accordingly to suit your needs):

\documentclass[12pt,a4paper,oneside]{article}
\usepackage[utf8]{inputenc}
\usepackage[includeheadfoot,landscape,left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{fancyhdr}

\setlength{\headheight}{80pt}
\pagestyle{fancy}

\lhead{This is header \\ This is header \\ This is header \\ This is header \\ This is header}
\chead{}
\rhead{}
\lfoot{}
\cfoot{This is the footer}
\rfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\begin{document}

First line of the document.

Second line of the document.

\end{document}

enter image description here

share|improve this answer
3  
you can add the option showframe to the geometry-package. It sould be easier to manually set the sizes. –  ralfix Mar 1 '13 at 9:37

First of all, you should leave to geometry all settings about page dimensions; setting \headheight post facto will ruin all the computations made by geometry.

Second, your setting of \headheight to 80pt is incompatible with the top margin you want, because the default head separation is 25pt and

80pt + 25pt = 105pt = 3.69cm

Your header is computed by fancyhdr to almost 71pt, actually; if you want to fit the header and have a top margin of 3cm, just do the exact computation for the headsep:

headheight=72pt, % give a bit more room
headsep=\dimexpr3cm-72pt\relax,

So finally you'll have

\usepackage[a4paper,landscape,
  left=3cm,right=3cm,top=3cm,bottom=3cm,
  headsep=\dimexpr3cm-72pt\relax,
  headheight=72pt]{geometry}
\usepackage{fancyhdr}

Here's a picture, where I used a slightly larger paper size, in order to show precisely what happens:

\usepackage[paperwidth=31.7cm,paperheight=23cm, % larger paper
  layoutwidth=29.7cm,layoutheight=21cm, % A4 landscape
  layouthoffset=1cm,layoutvoffset=1cm, % 1cm to crop on all sides
  left=3cm,right=3cm,top=3cm,bottom=3cm,
  headsep=\dimexpr3cm-72pt\relax,
  headheight=72pt,showframe,showcrop]{geometry}
\usepackage{fancyhdr}

The crop marks show the "real" paper size which is A4 landscape.

enter image description here

share|improve this answer

Here is an exakt solution, without playing around to find the correct size.

You have to calculate the totalheight of the page, that is the phyical paper height, on DIN A4 it's 21cm, minus the top margin, in your example that is 3cm, minus the headheight, which is 80pt in your example, minus the bottom margin, which is 3cm, minus the headsep and finally plus the footskip.

By default, headsep and footskip are the same, so they cancel each other in this example.

80pt corresponds to 2.8169014084507cm, according to wikibooks.

So your totalheadheight should be 12.1830985915493cm, say 12.183cm which sould be precise enough.

Now use geometry with the following options:

\usepackage[landscape,left=3cm,right=3cm,top=3cm,includeheadfoot,totalheight=12.183cm,showframe]{geometry}

Do not set the bottom margin directly with bottom=..., it is included in the calculation.

\documentclass[12pt,a4paper,oneside]{article}
\usepackage[utf8]{inputenc}
\usepackage[landscape,left=3cm,right=3cm,top=3cm,includeheadfoot,totalheight=12.183cm,showframe]{geometry}
\usepackage{fancyhdr}

\setlength{\headheight}{80pt}
\pagestyle{fancy}

\lhead{This is header \\ This is header \\ This is header \\ This is header \\ This is header}
\chead{}
\rhead{}
\lfoot{}
\cfoot{This is the footer}
\rfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\begin{document}

First line of the document.

Second line of the document.

\end{document}

Screenshot

Edit : added footskip and headsep to the calculation

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.