-
How can I calculate the difference between 2 counters (like page numbers), so that
pdfLateX
outputs "3" in the last line of my example? -
and how could I calculate the difference between the "current" page (where the calculation is printed) and
\pageref{A}
(without explicitly defining\label{B}
)?
Example:
\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc}
\begin{document}
Here is label A \label{A}
\newpage
text
\newpage
text
\newpage
Here is label B \label{B}
There are \pageref{B}-\pageref{A} pages between labels A and B.
\end{document}
Best Answer
The refcount package can extract the number from a reference. That only works for
arabic
page numbers, of course. And there must not be any\addtocounter{page}{...}
or\setcounter{page}{...}
between A and B. For those more complicated situations,\theCurrentPage
of the pageslts package can be used.