# Add page number with total page number on each page? [duplicate]

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?

## marked as duplicate by egreg, jub0bs, Svend Tveskæg, barbara beeton, GuidoJan 1 '14 at 12:03

• 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

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

\documentclass{article}

\usepackage{lastpage}

\usepackage{fancyhdr}

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

% Uncomment to remove the header rule

\pagestyle{fancy}

\usepackage{lipsum}

\begin{document}

\lipsum[1-10]

\end{document}


The Output

Further Tweaking


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

• 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