0

I'm using the fancyhdr command to incorporate a header in the first page of a document. This is the code I wrote:

\thispagestyle{fancy}\hspace{0.2cm}
\chead{\includegraphics[height=80pt]{Header.pdf}}

In the second page, I don't want neither the header image nor the space that's being generated so at some point I use:

\thispagestyle{plain}

While that solves the problem in the second page, it eliminates the header in the first one. Could you help me here? Thanks.

MWE

\documentclass[12pt]{article} 
\usepackage{geometry} 
\usepackage{setspace} 
\usepackage[active]{srcltx} 
\usepackage{fancyhdr} 
\usepackage[pdftex]{color,graphicx} 
\usepackage[usenames,dvipsnames]{xcolor} 
\usepackage{marvosym,pifont} 
\usepackage{setspace} 
\geometry{dvips,paperwidth=8.5in,paperheight=11in,right=1in, left=1in,top=1in,bottom=1in} \renewcommand{\headrulewidth}{0pt} 
\begin{document} 
\thispagestyle{fancy}\hspace{0.2cm} 
\chead{\rule{80pt}{80pt}} 
\vspace{0.4cm} 
{\fontfamily{put}\selectfont \onehalfspacing \noindent xxxxx. TEXT TEXT TEXT }    
\end{document} 
  • Are you issuing the command \thispagestyle{plain} while being on the first page still? Answer this question via a minimal working example (MWE) that replicates the problem (not by saying "Yes" or "No"). We want to copy-and-paste-and-compile your complete document code (yet it should be minimal) and see exactly what you're seeing. It should start with \documentclass and end with \end{document}. – Werner Nov 6 '14 at 18:40
  • (la)tex doesn't output a page the instant there is enough material to fill it up. instead, it continues to process content until a really good break point can be determined. in my experience, this could mean that as much as an extra half page could be under consideration before the page break is chosen -- or even more, if the paragraphs are exceptionally long. (a paragraph will always be considered in full before tex stops to make a decision.) therefore, the command to change the page style must be far enough down on the second page to ensure that the first page has already been output. – barbara beeton Nov 6 '14 at 18:48
  • Barbara, the command is almost at the end of the second page and I've tried put it in different parts without any success. – Xtruggle Nov 6 '14 at 19:02
  • @Werner: Should I copy the two pages of text here? Also, what about the pdf that I'm using as a header? (I would like to keep it private.) Thanks to both of you for helping me with this. – Xtruggle Nov 6 '14 at 19:04
  • @Xtruggle: Read the linked post about a MWE. Post the code (excluding private components, which you replace with fictional content) so we can copy-and-paste-and-compile as see what you're experiencing. – Werner Nov 6 '14 at 19:06
2

I cannot reproduce the effect you describe (making the black box disappear). However, if you look at the output, you will see why the gap is left on all pages:

Package Fancyhdr Warning: \headheight is too small (12.0pt): 
 Make it at least 84.35004pt.
 We now make it that large for the rest of the document.

This is telling you how large the header needs to be to accommodate the image.

Basically, this is not the kind of thing you should try to configure using commands which are designed to layout running heads. What you should do is layout the first page differently from the rest - not layout the first page as standard and then make every other page non-standard.

I am not really sure what your document is meant to look like or what role the header on the first page serves. So there are likely more semantically appropriate ways of doing this. However, here is a start:

\documentclass[12pt,letterpaper]{article}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{fancyhdr}
\pagestyle{fancy}% headers and footers standard for the document
\usepackage{kantlipsum}
\geometry{right=1in, left=1in, top=1in, bottom=1in, headheight=15pt}
\renewcommand{\headrulewidth}{0pt}
\begin{document}
  \thispagestyle{plain}%
  \noindent%
  \begin{minipage}{.35\linewidth}
    \hspace*{0.2cm}\fontfamily{put}\selectfont\onehalfspacing\noindent xxxxx. TEXT TEXT TEXT
  \end{minipage}%
  \begin{minipage}{.3\linewidth}
    \centering
    \rule{80pt}{80pt}
    \vspace{.4cm}
  \end{minipage}

  \kant[1-6]
\end{document}

plain and fancy pages

  • @Xtruggle Please consider accepting the answer if it helped you so that others can see that the question has a solution. This will also give me and you some points of reputation and is the local way of saying 'thanks'. To accept, click on the tick you'll find by the vote count at the top left of the answer. – cfr Nov 14 '14 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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