3

I am trying to write a recommendation letter with a fancy heading at the top of the first page, using fancyhdr. I copy my code below.

The results are that the first page looks good but subsequent pages do not. Subsequent pages omit the logo (as desired) but leave enough space for it, and the text starts from the same place on every page. Starting from the second page, I would like the text to start higher.

It seems that the only code which could cause the text to appear lower is within the \fancypagestyle{firstpage}{...}, and I use \thispagestyle{firstpage} with the intent that this should only affect the first page -- but this is not what happens when I compile and view my document.

I read related posts here and here, and attempted to modify my code based on what I read there, but without achieving the results I was looking for.

Thank you very much.

LaTeX code (which compiles):

\documentclass[11pt]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{color,hyperref}
\usepackage{graphics}
\usepackage{times}
\usepackage{fancyhdr}
\usepackage{datetime}


\definecolor{darkblue}{RGB}{0,0,50}
\hypersetup{colorlinks,breaklinks,
            linkcolor=darkblue,urlcolor=darkblue,
            anchorcolor=darkblue,citecolor=darkblue}


%%%%%%%%%%%%%%%%%%date in format Sunday, October 25, 2011$$$
\usdate
\def\theday {\dayofweekname{\day}{\month}{\year}}
\def\mydate {\theday , \today}

%%%%%%%%%%return address%%%%%%%%%%
\def\myname     {Frank Thorne}
\def\mydeptname     {Department of Mathematics}
\def\myaffiliation  {University of South Carolina}
\def\mystreet       {1523 Greene Street}
\def\mycitystatezip {Columbia,\ SC\ \ 29208}
\def\myphone        {{\it Phone:} (803)404-4057 (home)}
\def\office     {(803)777-4224}
\def\fax        {{\it Fax:}(803)777-3783}
\def\email      {[email protected]}
\def\url        {http://www.math.sc.edu/$\sim$thornef} % NOTE: use $\sim$ for tilde
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%margins%%%%%%%%%%%%%%%%%%
\oddsidemargin   0in
\evensidemargin  0in
\topmargin  -0.75in
\textwidth   6.5in
\textheight  6.25in
\headwidth  \textwidth
\parindent      0ex %controls how the indentation of new paragraphs behaves
\parskip        6pt %controls the space between paragraphs
\headheight     1.25in
\headsep    1in %This controls how far below the letterhead the text of the letter will begin



\addtolength{\textheight}{.5in}
%%%%%%%%%%%%%%%%letterhead%%%%%%%%%%%%%%%%
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

%\thispagestyle{fancy}
\fancypagestyle{firstpage}{
\fancyhf{}
%%%usc logo
\fancyhead[L]{\resizebox{2.5in}{!}{
%\includegraphics{USC_Linear.jpg}
} \vspace{0.6in}}

%%%%%%%%%%return address on right%%%%%%%
\fancyhead[R]{
\parbox[t]{3.1in}{ \footnotesize   \em \vspace{0.5in}
                \myname \\
                \mydeptname   \\
                \myaffiliation \\
                \mystreet \\
                \mycitystatezip \\
                \email \\
\\ 
                \mydate
                }\hspace{-1.3in}
\vspace{0.2in}}
}

\begin{document}

\thispagestyle{firstpage}

Blah blah blah.


Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.

Blah blah blah.



\hspace{.5\textwidth}\parbox[t]{2.95in}{
            Sincerely,\\

            Frank Thorne\\
            Assistant Professor of Mathematics
           }

\vfill





\end{document}

6
  • 2
    Welcome to TeX.SE. Please complete your code and turn it into a fully compilable MWE including \documentclass and the appropriate packages that reproduces the problem. You can include \usepackage{lipsum} and insert dummy text in the document via \lipsum[1-12] for instance. Commented Oct 30, 2014 at 22:01
  • 1
    You mustn't set \headheight and \headsep in \fancyhead to begin with. Only one \headheight can be used throughout the document unless one changes the page geometry, but this makes it very difficult to get paragraphs flowing from one page to the other.
    – egreg
    Commented Oct 30, 2014 at 22:27
  • @PeterGrill, Thank you both very much. I replaced my code with something self-contained that compiles, and I also removed the \headheight and \headsep from the \fancyhead. I still have the problem I described with the newly replaced code above. Commented Oct 31, 2014 at 17:11
  • Seems you have been TeXing for a long time, some things in there can be done in a cleaner way. You say you want to make a letter, why not using a class designed to make letters? The standard class letter comes to mind and the much more advanced and feature rich scrlttr2.
    – Johannes_B
    Commented Oct 31, 2014 at 18:58
  • But looking at the output, why not simply use a minipage or parbox? Since you aren't using any real headers, a minipage should do just fine`
    – Johannes_B
    Commented Oct 31, 2014 at 18:59

1 Answer 1

5

If you don't set a proper head height, fancyhdr reports the following:

Package Fancyhdr Warning: \headheight is too small (XX.Xpt): 
 Make it at least YY.YYYYpt.
 We now make it that large for the rest of the document.
 This may cause the page layout to be inconsistent, however.

As such, the newly-set \headheight will be the same throughout the document. To avoid this, I've created the following minimal document that sets a consistent head height, adding a vertical space (gap) on the first page to simulate a larger header:

enter image description here

\documentclass{article}

\usepackage{fancyhdr,datetime,geometry,lipsum,graphicx}

%%%%%%%%%%%%%%%%%%date in format Sunday, October 25, 2011
\usdate
\def\theday {\dayofweekname{\day}{\month}{\year}}
\def\mydate {\theday , \today}

%%%%%%%%%%return address%%%%%%%%%%
\def\myname         {Frank Thorne}
\def\mydeptname     {Department of Mathematics}
\def\myaffiliation  {University of South Carolina}
\def\mystreet       {1523 Greene Street}
\def\mycitystatezip {Columbia,~SC \quad 29208}
\def\myphone        {\textit{Phone:} (803)404-4057 (home)}
\def\office         {(803)777-4224}
\def\fax            {\textit{Fax:}(803)777-3783}
\def\email          {[email protected]}
\def\url            {\texttt{http://www.math.sc.edu/~thornef}} % NOTE: use $\sim$ for tilde
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%margins%%%%%%%%%%%%%%%%%%
\geometry{
  margin = 1in,
  headheight = 13.5pt
}
\setlength{\parindent}{0pt} %controls how the indentation of new paragraphs behaves
\setlength{\parskip}{6pt} %controls the space between paragraphs

%%%%%%%%%%%%%%%%letterhead%%%%%%%%%%%%%%%%
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\pagestyle{fancy}%

\fancypagestyle{firstpage}{
  \fancyhf{}% Clear header/footer
  %%%usc logo
  \fancyhead[L]{\raisebox{\dimexpr-\height+\baselineskip}[0pt][0pt]{\includegraphics[width=2.5in]{example-image}}}
  %%%%%%%%%%return address on right%%%%%%%
  \fancyhead[R]{\leavevmode\footnotesize\itshape%
  \begin{tabular}[t]{l@{}}
    \myname \\ \mydeptname \\
    \myaffiliation \\ \mystreet \\
    \mycitystatezip \\ \email \\[\normalbaselineskip]
    \mydate
  \end{tabular}}
}

\begin{document}

\thispagestyle{firstpage}

\vspace*{8\baselineskip}

\lipsum[1-10]

\bigskip

\hspace{.5\textwidth}%
\begin{tabular}{@{}l}
  Sincerely, \\[2\normalbaselineskip]
  Frank Thorne \\
  \textit{Assistant Professor of Mathematics}
\end{tabular}

\end{document}

I've used geometry to adjust the page layout - it's just easier/more convenient.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .