Possible Duplicate:
How can I add “page # of ##” on my document?
While submitting Test paper in LaTeX, I was asked to display page numbers as current page number out of total page numbers.
I am using article class.
For example it should look like: 1 out of 4, 2 out of 4, 3 out of 4 etc.
or 1/4,2/4 etc.
How to obtain it?
Best Answer
You could simply use the
lastpage
package and use the following MWE to get the1/3
,2/3
, etc "look". If you want "out of" instead of "/", just replace\thepage/\pageref{LastPage}
with\thepage\ out of \pageref{LastPage}
. Be sure to compile the document twice to give LaTeX a chance to get the cross-referencing right.Note that the code in the MWE doesn't require you to use any additional packages (such as
fancyhdr
) to manipulate the page headers and footers.Addendum: Should you be using the
hyperref
package as well, you may want to replace the instruction\pageref
with\pageref*
. The former command would instructhyperref
to make its argument into a hyperlink -- probably not an intended effect. Thehyperref
package provides the variant command\pageref*
(as well as\ref*
...) to avoid creating hyperlinks out of the cross-reference.