3

My 3 pages long article having the following code in the preamble produces "Page x of ??" in the header, rather than "Page x of 3" (where x stands for current page number).

What am I missing?

\usepackage{lastpage}
\usepackage{scrpage2}
\pagestyle{scrheadings}
\clearscrheadfoot
\ohead{Page \thepage\ of \pageref{lastpage}}
3
  • 1
    Did you run the compiler for three times? Welcome to TeX.SE!
    – Mensch
    Oct 25, 2016 at 16:10
  • I was looking at the pdf preview; just compiled it 3 times with no difference in the output. Still ?? for last page. Oct 25, 2016 at 16:13
  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – ebosi
    Oct 25, 2016 at 16:15

1 Answer 1

3

Your issue is that the number of the "last page" is not computed by LaTeX. If you look at the log-file, you should see something like:

LaTeX Warning: Reference `lastpage' on page 1 undefined on input line 11.

It means that LaTeX doesn't know what lastpage is (i.e. this label have not been defined previously).

If you look at the documentation of the lastpage package, it is said that the label defined on the last page is LastPage (with L and P as capital letters).

Thus, you should write \pageref{LastPage} instead of \pageref{lastpage}. (Indeed, caps does matter in LaTeX.)

1
  • Thank you. The typo has been corrected and the issue resolved. Dec 6, 2016 at 15:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .