tags:

views:

403

answers:

1

I am working on a book in latex, which uses the \frontmatter, \mainmatter, and \backmatter commands from the book class. I am also using lastpage which gives me page n of m for the pages counted in the \mainmatter. How would I get the n of m page count for the \frontmatter using roman numerals?

+2  A: 

You can do by hand for the front matter what the lastpage package is doing for the main matter. A simple way is to put

\label{lastoffront}

somewhere that you can guarantee to be on the last page of the front matter like just before a \clearpage that you use before \mainmatter. Then, just replace the page number command in the front matter by

\thepage~of~\protect\pageref{lastoffront}

like inside the \fancyfoot command (I assume you're also using fancyhdr). You'll need to also set the page numbering style in the beginning of the main matter; the same setting works, except use the LastPage label provided by the lastpage package instead of lastoffront.

(This is not quite how lastpage handles things as the last page of the document is not always correctly determined by this technique, but I understand it is sufficient for the front matter.)

jk