Sign up ×
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.

This question already has an answer here:

I am using \pagestyle{plain} to add page number to each page in its bottom. If I want something like " page number / total page number" or " page number out of total page number", how shall I do that?

share|improve this question

marked as duplicate by egreg, Jubobs, Svend Tveskæg, barbara beeton, Guido Jan 1 '14 at 12:03

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.

I hope you don't insist to use \pagestyle{plain} and still want to get the desired result. Please see the solution below. – Masroor Jan 1 '14 at 1:19

1 Answer 1

Solution Idea

  1. Use package lastpage to define the label LastPage, allowing us to refer to the last page via \pageref{LastPage}.

  2. Use fancyhdr to control your footer.

The Solution




\fancyfoot[C]{Page \thepage\ of \pageref{LastPage}}

% Uncomment to remove the header rule
% \renewcommand{\headrulewidth}{0pt} 






The Output

enter image description here

Further Tweaking

  1. If you really like it plain, perhaps you will want to use \renewcommand{\headrulewidth}{0pt} (and may be \renewcommand{\footrulewidth}{0pt}) as well to get rid of the rules.

  2. Use of fancyhdr actually gives you a ton of other controls which should be rewarding. Please see the package documentation for further details.

share|improve this answer
You probably want to add \renewcommand{\headrulewidth}{0pt} unless using a header. – cfr Jan 1 '14 at 1:19
Yes, all those tweakings are definitely possible. I left them for the end user. Please note that I did not reset the header-footer using \fancyhf{}. That was intentional, along with the rules. – Masroor Jan 1 '14 at 1:21
Right but setting \pagestyle{fancy} adds a header rule which is not present with \pagestyle{plain} so if the idea is to show a solution which just does what's asked, I guess I thought you'd nullify the rule added by changing the pagestyle. But of course you're right that the user will need to read the documentation to tweak to their liking. – cfr Jan 1 '14 at 1:31
@cfr Get your point and agreed upon. Added a few lines to the end of my answer. – Masroor Jan 1 '14 at 1:34
\footrulewidth is 0pt by default though it does no harm to show how to change it, of course. – cfr Jan 1 '14 at 1:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.