[Tex/LaTex] Add page number with total page number on each page?

page-numbering

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?

Best Answer

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
% \renewcommand{\headrulewidth}{0pt} 

\pagestyle{fancy}

\usepackage{lipsum}

\begin{document}

\lipsum[1-10]

\end{document}

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.