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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When inserting page numbers into beamer slides, I usually use:

\setbeamertemplate{footline}[page number]

Is it possible to do this for headline, something like:

\setbeamertemplate{headline}[page number]
share|improve this question
Have you tried \insertframenumber? – Matten Dec 1 '10 at 11:07
It seems that \insertframenumber only shows the current page number, but I also want the total page number (excluding appendix). – Li Wang Dec 1 '10 at 23:34
up vote 4 down vote accepted

Sure, it's not installed by default, but you do something like this:

\defbeamertemplate{headline}{page number}{%
    \setbeamertemplate{footline}[page number]%
\setbeamertemplate{headline}[page number]

Since the footline template is set inside the group it's not affected by your global theme. You can have a regular footline that's something else like infolines--although I assume you don't want that one because it's already got the page number in it.

This does seem to clobber the headline in some of the fancier themes. So you might try instead \addtobeamertemplate:

    \setbeamertemplate{footline}[page number]%
    \setbeamercolor{page number in head/foot}{use=headline,fg=headline.fg,bg=headline.bg}
}{% don't add anything after
share|improve this answer
Both methods work perfectly:) Thank you very much! Strangely, the colours of the page numbers in these two methods are different (grey vs. dark) – Li Wang Dec 1 '10 at 23:44
@user2015: Notice that in the second example I played around with the color by setting the beamer-color page number in head/foot to be the same as that of headline – Matthew Leingang Dec 2 '10 at 0:35
I see:) The second method is much more flexible then. Thank you very much! – Li Wang Dec 2 '10 at 5:54

Your Answer


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.