2

Combing answers from this question:

How to use \pageref{foo} as a number?

Positioning TikZ picture on page background to be on each page of twosided document

I was able to create picture of my logo ("artistic" planetary model of atom) that is rotating with nucleus and electrons rotating separately (nested pictures, if I understand it correctly), but when my document exceeded about 90 pages, It stopped compiling with "Arithmetic overflow" error.

In response of Ms. Fischer to first question (I am using that one, because I have in my book arabic and roman counters; sadly after switch those are restarted), there is argument to set default value of last page

\zref@extractdefault{LastPage}{abspage}{1}

I am failing at using that instead of

\getpagerefnumber{LastPage}

I think its because of "@" character being in that statement, and I dont know how to fix it with \makeatletter and \makeatother with correct syntax.

I am opened to any solutions, even those with different approaches (I read also about using package "xassoccnt," in this question:

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

but I dont know how to set default value of both counters to make it work for my case. For compilation I am using luaLaTeX and learning lua too, so that might be also a way, but my limited knowledge is still not enough.

Next i present MWE, which is pretty extensive given my (kinda) complicated picture, but with MWEs from mentioned questions, I can make it work by simple changing default counter value, but in my specific case I dont know how to do that.

Mwe is compilable, for "incompilable" state please uncomment the \newpage \lipsum commands.

EDIT: MWE shows not "arithmetic overflow," but exceeding dimensions, which I hope is simillar. My orginal document shows "Arithmetic overflow" error.

EDIT2: Edited MWE to represent my issue, compiling MWE now brings error (at least on my side). Lowering ammount of pages (removing some "newpages" and "lipsum" makes MWE compilable again).

Thank you very much for any help in this, regards

Tomas

MWE:

\documentclass[12pt,twoside]{book}

\usepackage{lastpage}
\usepackage[lastpage]{zref}
\makeatletter
\zref@newprop*{numpage}{\the\value{page}}
\zref@addprop{main}{abspage}
\makeatother

\usepackage{refcount}
\setrefcountdefault{-1}

\usepackage{eso-pic}

\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{shapes,calc,positioning,shadows.blur,decorations.pathreplacing}

\newcommand{\nuclei}[1]{%
    \shade[ball color=white] (#1) circle (.4);
}

\newcommand{\nucleus}{%
    \nuclei{0.1,0.3}
    \nuclei{0,0}
    \nuclei{0.3,0.2}
    \nuclei{-0.2,0.1}
    \nuclei{-0.1,0.3}
    \nuclei{0.2,-0.15}
    \nuclei{-0.05,-0.12}
    \nuclei{0.17,0.21}
}

%\electron{xwidth,ywidth,rotation angle}
\newcommand{\electron}[3]{%
    \draw[rotate = #3](0,0) ellipse (#1 and #2)[color=blue];
    \shade[ball color=black] (0,#2)[rotate=#3] circle (.2);
}

\usepackage{changepage}
\strictpagecheck

\newcommand{\MyTikzLogo}{% For a logo drawn with TikZ
\begin{tikzpicture}[remember picture,overlay,scale=1]
\checkoddpage
\ifoddpage
  \begin{scope}[shift={([xshift=2cm,yshift=2cm]current page.south west)}, scale=0.25]
  \begin{scope}[rotate=360*\the\value{page}/\getpagerefnumber{LastPage}]
    \nucleus
  \end{scope}       
    \electron{1.2}{1.4}{260+(360*\the\value{page}/\getpagerefnumber{LastPage})}
    \electron{4}{2}{30+(360*\the\value{page}/\getpagerefnumber{LastPage})}
    \electron{5}{1}{60+(360*\the\value{page}/\getpagerefnumber{LastPage})}
    \electron{5.5}{1.5}{150+(360*\the\value{page}/\getpagerefnumber{LastPage})}
    \electron{4.8}{2.25}{80+(360*\the\value{page}/\getpagerefnumber{LastPage})}
  \end{scope}
\else
  \begin{scope}[shift={([xshift=-2cm,yshift=2cm]current page.south east)}, scale=0.25,local bounding box=test]
  \begin{scope}[rotate=360*\the\value{page}/\getpagerefnumber{LastPage}]
    \nucleus
  \end{scope}       
    \electron{1.2}{1.4}{260+(360*\the\value{page}/\getpagerefnumber{LastPage})}
    \electron{4}{2}{30+(360*\the\value{page}/\getpagerefnumber{LastPage})}
    \electron{5}{1}{60+(360*\the\value{page}/\getpagerefnumber{LastPage})}
    \electron{5.5}{1.5}{150+(360*\the\value{page}/\getpagerefnumber{LastPage})}
    \electron{4.8}{2.25}{80+(360*\the\value{page}/\getpagerefnumber{LastPage})}
  \end{scope}
\fi
 \end{tikzpicture}
}

\AddToShipoutPictureBG{\MyTikzLogo}

\begin{document}
\section*{Lorem Ipsum}
\pagenumbering{roman}
\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\pagenumbering{arabic}

\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\lipsum[1-60]

\newpage

\end{document}
  • 1
    Your example compiles without error for me. But before trying to implement solutions you should be sure that your diagnose of the source of the problem is correct. So better make a sensible minimal example which doesn't contain a mix of your various tries. – Ulrike Fischer Jun 6 at 14:04
  • Thank you very much for your comment Mrs. Fischer. On my part, the MWE such as it is now (uncomented lines of code) produces error that is pestering me. I admit that the MWE code is compilation of your solution and solution of Mr. Lev, but it (somehow) works, until I reach approximately 90 pages of document (in case of my original file). I dont know why that is. Maybe because of computing restrictions with counters in TeX? – Tomáš Kruliš Jun 6 at 14:19
  • 2
    Exchange everywhere (also in the rotate) the calculation order: divide first and multiplicate later: 360/\getpagerefnumber{LastPage}*\the\value{page}. Btw: this a problem of pgf, as it uses internally dimensions it can't handle large value well. – Ulrike Fischer Jun 6 at 14:44
  • @UlrikeFischer Thank you very much for your help and insight Mrs. Fischer. Now everything works. Trying out this did not occured to me in the slightest, but at least I was close by suspecting I have hit an limitation -somewhere-. Would you be kind to create an answer to this question for anybody else to look upon, if they would have some kind of similar situation, or do you want me to create answer and accept it myself? – Tomáš Kruliš Jun 7 at 6:07
2

Change everywhere (also in the rotate) the calculation order: divide first and multiplicate later:

  360/\getpagerefnumber{LastPage}*\the\value{page}

This will avoid that the numbers gets too large - something that pgf can't handle very well as it uses internally dimensions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.