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.

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.

share|improve this question

2 Answers 2

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:

enter image description here

and of the header in the test page:

enter image description here

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.

share|improve this answer

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:

Headers on title page and page following

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.