Refer to the current page number, but not \thepage, but the real absolute

The package xassoccnt provides a mean to force a stepping of an associated counter each time a driver counter is stepped as well -- the driver counter is page here.

This has an advantage over the totcount or lastpage packages, since the associated counter realpage (any name will do, but section etc. is unwise, of course ;-)) is not reset (unless explicitly done so with \setcounter) -- As such, it counts the total absolute values of pages.

So even in case of \pagenumbering commands, this does not have an effect on the realpage counter.

Please note that page is an unrealiable counter in some sense!

\documentclass[a5paper, 11pt]{scrbook}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}

\usepackage{xassoccnt}

\newcounter{realpage}
\DeclareAssociatedCounters{page}{realpage}
\AtBeginDocument{%
  \stepcounter{realpage}
}

\begin{document}
Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage

\pagenumbering{gobble}

Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage

\pagenumbering{arabic}

Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage

\end{document}

A version with \NewTotalDocumentCounter (needs xassoccnt v.1.2. and above)

\documentclass[a5paper, 11pt]{scrbook}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}

\usepackage{xassoccnt}

\NewTotalDocumentCounter{totalrealpage}
\NewDocumentCounter{realpage}

\DeclareAssociatedCounters{page}{realpage,totalrealpage}
\makeatletter
\AtBeginDocument{%
  \setcounter{realpage}{1}
}

\makeatother

\begin{document}
In diesem Dokument sind insgesamt \TotalValue{totalrealpage} Seiten!

Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage

\pagenumbering{gobble}

Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage

\pagenumbering{arabic}

Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage
Seite \therealpage
\newpage

\end{document}

zref's abspage module provides access to an "absolute page number" property. Together with the lastpage module, you can extract the last absolute page number using \zref[abspage]{LastPage}. Here is a minimal example:

enter image description here

\documentclass{article}

\usepackage[paper=a5paper]{geometry}% Just for this example
\usepackage[abspage,user,lastpage]{zref}

\begin{document}
Seite \thepage
\newpage
Seite \thepage
\newpage
Seite \thepage
\newpage
Seite \thepage
\newpage
Seite \thepage
\newpage

\pagenumbering{gobble}

Seite \thepage
\newpage
Seite \thepage
\newpage
Seite \thepage
\newpage
Seite \thepage
\newpage

\pagenumbering{arabic}

Seite \thepage
\newpage
Seite \thepage
\newpage
Seite \thepage
\newpage
Seite \thepage

Last page: \zref[abspage]{LastPage}

\end{document}

The interface to use \zref[<prop>]{<label>} requires the user module. Any specific page's absolute page number (other than LastPage, say) can be obtained using a \zlabel{<label>} and subsequent \zref[abspage]{<label>}.


The memoir class provides two macros, namely \lastpage and \lastsheet which will print the page number of the last page and the number of sheets of paper required for printing the document single sided. To date I have not heard of any problems with these. They can be used like this:

\documentclass[a4paper,...]{memoir}
...
\begin{document}
...
The last page is number \lastpage\ and requires \lastsheet\ of A4
paper for printing single sided.
\end{document} 

There is also a \thesheetsequence macro that prints the current number of sheets like \thepage which prints the current page number.