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.
\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage{refcount}
\usepackage{pageslts}
\pagenumbering{arabic}
\begin{document}
Here is label A. \label{A}
\newpage
text
\newpage
text
\newpage
Here is label B \label{B}
\makeatletter
\@tempcnta=\getpagerefnumber{B}\relax%
\advance\@tempcnta by -\getpagerefnumber{A}%
% (maybe
% \advance\@tempcnta by -1%
% depending on your definition of "between")
\xdef\pagedifference{\the\@tempcnta}%
\makeatother
There are \pagedifference~pages between labels A and B.
\makeatletter
\@tempcnta=-\getpagerefnumber{A}\relax%
\advance\@tempcnta by \thepage%
% (maybe \advance\@tempcnta by -1, depending on definition of "between")
\xdef\pagedifference{\the\@tempcnta}%
\makeatother
There are \pagedifference~pages between labels A and the current page.
\newpage
\pagenumbering{Roman}
Here is page \thepage{} (the \theCurrentPage{}.~page).
\xdef\mypageA{\theCurrentPage}
\newpage
text
\newpage
text
\addtocounter{page}{10}
Just added 10 to the page number here.
\newpage
Here is page \thepage{} (the \theCurrentPage{}.~page).
\xdef\mypageB{\theCurrentPage}
\makeatletter
\@tempcnta=\mypageB\relax%
\advance\@tempcnta by -\mypageA%
% (maybe \advance\@tempcnta by -1, depending on definition of "between")
\xdef\pagedifference{\the\@tempcnta}%
\makeatother
There are \pagedifference~pages between page A and the current page B.
\end{document}
I'm not entirely sure of what you're trying to create here. This is my guess
\documentclass[a4paper, 10pt]{article} % for A4 size paper
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[remember picture,
overlay,
normal lines/.style={gray, very thin},
margin lines/.style={gray, thick},
mm lines/.style={gray, ultra thin},
strong lines/.style={black, very thin},
master lines/.style={black, very thick},
dashed master lines/.style={loosely dashed, black, very thick}
]
\coordinate (origin) at (current page.north west);
\path
[draw,dashed] (current page.north) -- (current page.south)
[draw,dashed] (current page.north) -- ($(current page.north west)+(0,-0.5\paperwidth)$)
[draw,dashed] (current page.north) -- ($(current page.north east)+(0,-0.5\paperwidth)$)
[draw,dashed] (current page.south) -- ($(current page.south west)+(0,0.5\paperwidth)$)
[draw,dashed] (current page.south) -- ($(current page.south east)+(0,0.5\paperwidth)$)
;
\end{tikzpicture}
\end{document}1
which produces
Here's an approach which illustrates what @Qrrbrbirlbel
was suggesting (though I'm sure this is not the image you're after)
\documentclass[a4paper, 10pt]{article} % for A4 size paper
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[remember picture,
overlay,
normal lines/.style={gray, very thin},
margin lines/.style={gray, thick},
mm lines/.style={gray, ultra thin},
strong lines/.style={black, very thin},
master lines/.style={black, very thick},
dashed master lines/.style={loosely dashed, black, very thick}
]
\coordinate (origin) at (current page.north west);
\path
coordinate (my top center) at (current page.north)
coordinate (my bot center) at (current page.south)
coordinate (my top left) at ($(current page.north west)+(0,-0.5\paperwidth)$)
coordinate (my top right) at ($(current page.north east)+(0,-0.5\paperwidth)$)
coordinate (my bot left) at ($(current page.south west)+(0,0.5\paperwidth)$)
coordinate (my bot right) at ($(current page.south east)+(0,0.5\paperwidth)$)
;
\draw[dashed] (my top center) -- (my top left);
\path let
\p1=($(my top left)-(my top center)$),
\p2=($(my top right)-(my top center)$),
\n1={veclen(\x1,\y1)},
\n2={atan2(\y1,\x1)},
\n3={atan2(\y2,\x2)}
in
[draw,dashed] (my top left) arc (\n2:180:\n1);
\end{tikzpicture}
\end{document}1
If I had a better idea of what you were after, I'm sure I could give a much better answer.
Best Answer
Use the e-TeX structure:
The macro
\settowidth
is used with finding the width of a portion of text such as in:The documentation can be found by running
texdoc etex
from the command line. Amoung other things, e-TeX provides several nice commands to facilitate calculations using\dimexpr
,\numexpr
, and several other flavors. Since I've discovered these, I find I don't use thecalc
package that much anymore.