I want to change the page numbering of my document to say "Page # of ##" instead of just "#". The fancyhdr package appears to change a lot, and it seem unfortunate to have to import it for one small thing.
- 4,899
- 2,058
-
1What do you have at the moment? Please show us a short compilable code ... – Mensch Jul 05 '18 at 18:58
1 Answers
For the last page you'll always want to
\usepackage{lastpage}
This gives you
\pageref{LastPage}
which will put in the last page of your document. After that it depends on your class:
KOMA
Using KOMA this is quite easy:
\renewcommand\pagemark{\usekomafont{pagenumber}Page \thepage of \pageref{LastPage}}
Base classes
Using a base class, e.g. article, one needs a little more work. I would recommend to create a new style based on the plain (or headings) style and use this:
\documentclass{article}
\usepackage{lastpage}
\usepackage{etoolbox}
\usepackage{lipsum}
\makeatletter
\let\ps@mystyle\ps@plain % Copy the plain style to mystyle
\patchcmd{\ps@mystyle}{\thepage}{Page\ \thepage\ of\ \pageref{LastPage}}{}{} % replace number by desired string
\makeatother
\title{test}
\pagestyle{mystyle}
\begin{document}
\maketitle\thispagestyle{mystyle}
\lipsum
\end{document}
Note that \maketitle (if not using book) uses \thispagestyle{plain}. That's why you have to override it manually. If you do use the book class, you need to do the same after \chapter. Also don't forget to use \pagestyle to declare a default page style, even if you want it to be plain.
Memoir
In memoir, you can easily use
\makeevenfoot{pagestyle}{left}{center}{right}
\makeoddfoot{pagestyle}{}{}{}
\makeevenhead{pagestyle}{}{}{}
\makeoddhead{pagestyle}{}{}{}
and use your desired Page\ \thepage\ of\ \thelastpage in the corresponding brackets. You can copy a style, to create your own from it, by
\copypagestyle{mystyle}{headings}
memoir is an exception, regarding loading lastpage or an equivalent. It provides \thelastpage already.
- 4,160
- 12
- 26