3

This question already has an answer here:

I'm trying to use \ifthenelse from the ifthen package to vary the size of \headheight within a document. I'd like this to be larger for the first page and then smaller for each subsequent page.

I had thought I could accomplish this using code like the following in my preamble.

\ifthenelse{\thepage=1}
  {\setlength\headheight{72pt}}
  {\setlength\headheight{14pt}} 

Unfortunately, that's not working for some reason. Below is some code that illustrates what I'm trying to do.

\documentclass{article}

%%%% Margins %%%%

\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{0in}

%%%% Packages %%%%

\usepackage[usenames,dvipsnames]{color} 
\usepackage[lastpage,user]{zref}
\usepackage{fancyhdr}
\usepackage{ifthen}
\usepackage{parskip}
\usepackage[pdfstartview=Fit]{hyperref}

%%%% Headers/Footers %%%%

\setlength\headheight{72pt}
\renewcommand\headrule{{\color{BrickRed} \hrule height 1pt width\headwidth}}
\pagestyle{fancy}
\definecolor{light-gray}{gray}{0.65}

\lhead{\ifthenelse{\thepage = 1}
              {\textcolor{light-gray}{My Name} \\ [4ex] \vspace{36pt} \textcolor{light-gray}{Telephone Number}}
              {\textcolor{light-gray}{My Name}}}

\rhead{\ifthenelse{\thepage = 1}
              {\textcolor{light-gray}{Page \thepage \ of \zpageref{LastPage}} \\ [4ex] \vspace{36pt}
               \textcolor{light-gray}{Email Address}}
              {\textcolor{light-gray}{Page \thepage \ of \zpageref{LastPage}}}}

\chead{\ifthenelse{\thepage = 1}
              {{\large\bfseries MY NAME, TITLE} \\
               Address Line 2 \\
               Address Line 3 \\
               Address Line 4 \\ [1ex]}
              {}}

\cfoot{}

%%%% Main Document %%%%

\begin{document}

Some text

\newpage
\setlength\headheight{14pt}

More text

\end{document}

This code produces the desired output. The drawback though is that I need to manually specify where the first page break should occur and then reset the headheight using:

\newpage
\setlength\headheight{14pt}

Is there some way to automate this, using \ifthenelse or some other means? Setting things manually when the contents of the first page change doesn't require much effort, but I'd like to understand what's going wrong and how to do this properly.

marked as duplicate by Joseph Wright Nov 1 '14 at 22:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.