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.

I'm new to TeX and LaTeX, so I might not explain it all that well.

I'm trying to put pagenumbers on each footer in the form "Page X of XX" using fancyhdr. So far I have this:

\cfoot{Page \thepage\ of \pageref{LastPage}}

This works fine, except on page 1, which just contains "1".

I suppose this is because the first page is a sort of "special page", since it doesn't contain the header as well.

How do I disable this special first page, so that all pages contain both the header and footer?

share|improve this question
    
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  Torbjørn T. Dec 3 '11 at 16:34
1  
You should use \cfoot{Page \thepage\ of \pageref{LastPage}} (note the \ after \thepage) -- otherwise a space will be gobbled. –  lockstep Dec 3 '11 at 16:43
1  
Or \cfoot{Page \thepage{} of \pageref{LastPage}}. –  Schweinebacke Dec 3 '11 at 16:45
add comment

3 Answers 3

up vote 10 down vote accepted

If you make the first page using \maketitle this may execute \thispagestyle{plain}. You may either redefine page style plain (see the fancyhdr manual for this), or simply add \thispagestyle{fancy} after \maketitle:

\documentclass{article}
\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\cfoot{Page \thepage{} of \pageref{LastPage}}
\begin{document}
\title{Title}
\author{Me}
\maketitle
\thispagestyle{fancy}
\end{document}

BTW: If you're using more versatile KOMA-Script class scrartcl instead of standard class article. You may redefine the page style of the page with the in page title head:

\documentclass{scrartcl}
\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\cfoot{Page \thepage{} of \pageref{LastPage}}
\renewcommand*{\titlepagestyle}{fancy}
\begin{document}
\title{Title}
\author{Me}
\maketitle
\end{document}

There are more of those page style commands at KOMA-Script, e.g., \chapterpagestyle for the page with chapter heading (only scrbook and scrreprt). Have a look at the KOMA-Script manual for all these commands.

share|improve this answer
add comment

Without saying \thispagestyle:

...
\pagestyle{fancy}
<customizations related to fancyhdr>
\expandafter\let\csname ps@plain\expandafter\endcsname
  \csname ps@fancy\endcsname
...
\begin{document}
...
\maketitle
share|improve this answer
3  
Maybe a beginner would understand it a little easier without \expandafter and \csname using \makeatletter\let\ps@plain\ps@fancy\makeatother. I know: beginners ofter do not understand why to use \makeatletter but \expandafter together with \endcsname\csname may be one step to high … –  Schweinebacke Dec 3 '11 at 16:43
    
I don't really understand why I would do this instead of just writing \thispagestyle{fancy} (as suggested). I suppose there are advantages of doing this, however the other way is fine for me right now. –  Anders Hovgaard Dec 3 '11 at 16:46
    
@Schweinebacke It was just to show a different approach. Definitely not for beginners, I agree. :) –  egreg Dec 3 '11 at 16:46
    
@AndersHovgaard It was only to show that it's not necessary. This trick may become handy when using the book class, where each \chapter command issues a \thispagestyle{plain} and it would be cumbersome to write every time \thispagestyle{fancy}. –  egreg Dec 3 '11 at 16:48
1  
@Schweinebacke \pagestyle{fancy} always uses the current values assigned with the \fancy... commands, so \let\ps@plain\ps@fancy is good as well. –  egreg Dec 3 '11 at 16:55
show 2 more comments

Many packages or styles issue the command \thispagestyle{plain} in \maketitle, so the first page is indeed "special". Try to override this with \thispagestyle{fancy} on title page.

share|improve this answer
add comment

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.