# Using fancyhdr in titlepage using Report Class

In the report class I am having trouble getting the header to show up on the title page. From what I understand, the \maketitle command automatically sets the pagestyle to empty. I had tried redefining empty to my header style using

\fancypagestyle{empty}{
\fancyhf{}
\fancyhead[R]{Team \#3243 Page \thepage  { }of \pageref{LastPage}}
}


However, that just makes both the title page and the second page say "Page 1 of N".

Right now the regular header is coded such that

\documentclass[12pt]{report}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rhead{Team \#3243 Page \thepage  { }of \pageref{LastPage}}


How can I get the proper header to be used on the title page? Any help will be much appreciated.

The problem is caused because the titlepage environment sets the page counter to zero using

\setcounter{page}\z@


You can redefine titlepage to avoid this (perhaps a patching would make the code shorter):

\documentclass[12pt,titlepage]{report}
\usepackage{lastpage}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{Team \#3243 Page \thepage\ of \pageref{LastPage}}

\makeatletter
\renewenvironment{titlepage}
{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse\newpage
\fi
\thispagestyle{empty}%
%\setcounter{page}\z@
}%
{\if@restonecol\twocolumn \else \newpage \fi
}
\makeatother

\title{Title}
\author{Author}

\begin{document}

\fancypagestyle{empty}{
\fancyhf{}
\fancyhead[R]{Team \#3243 Page \thepage\ of \pageref{LastPage}}
}
\begin{titlepage}
\maketitle
\end{titlepage}
test

\end{document}


An image of the header in the title page:

and of the header in the test page:

I placed the redefinition of the empty page style in the body so you can easily make it local (in case, it shouldn't affect all pages with empty style) by grouping; otherwise, it can be moved to the preamble.

The problem is that the counter page does not get incremented on the title page. So although redefining empty gets you the header, you end up with the same header as on the first page of the document itself. To remedy this, you can just increment the counter yourself to compensate:

\documentclass[12pt,titlepage]{report}
\usepackage{lastpage}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{Team \#3243 Page \thepage\ of \pageref{LastPage}}

\fancypagestyle{empty}{
\fancyhf{}
\fancyhead[R]{Team \#3243 Page \thepage  { }of \pageref{LastPage}}
}

\title{Title}
\author{Author}

\begin{document}
\maketitle
\stepcounter{page}
test

\end{document}


This produces: