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

In document of \documentclass[12pt, twoside]{book} I am trying to position a bit more complicated picture, consisting of two \scope in it. I tryed to use answer of this question: Place a TikZ picture on every page

but as far as I am able to troubleshoot this, I am unable to pass the \VOffset and \HOffset commands from answer of forementioned question to the \scope{} environment.

As is in MWE down, I had to place the logo manually (with finding parameters for shift by trial-error). Is there better, more convenient and controlled way of doing this, simillar to code from forementioned answer?

MWE is pretty lengthy, because I think that full code of my logo is necessary to troubleshoot this. If you have any suggestions to further simplify code of logo, any help would be appreciated.

Thank you very much

MWE:

\documentclass[12pt,twoside]{book}

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

\usepackage{refcount}
\setrefcountdefault{-1}

\usepackage[scale=1,opacity=1]{background}

\usepackage{lipsum}
\usepackage{tikz}

\newcommand{\nuclei}[1]{%
}

\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];
}

\usepackage{changepage}
\strictpagecheck

\newcommand{\MyTikzLogo}{% For a logo drawn with TikZ
\begin{tikzpicture}[remember picture,overlay,scale=1]
\checkoddpage
\ifoddpage
\begin{scope}[shift={(-7.7,17.9)}, 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={(0.9,2.9)}, 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}
\fi
\end{tikzpicture}
}

\SetBgContents{\MyTikzLogo}% Set tikz picture

\SetBgPosition{current page.south east}% Select location

\begin{document}
\section*{Lorem Ipsum}
\lipsum[1-25]
\end{document}

• (+1) A very nice picture! – user156344 Apr 11 at 13:49
• @JouleV Thank you very much, but needed to admit, I cannot be considered as author. I found very similar work on TeX examples, adapted it to my liking and added rotations in order to change with each page (and to have one revolution after reading whole document). – Tomáš Kruliš Apr 11 at 13:53
• @TomášKruliš [off-topic] In a way it is funny that the electrons evolves over-time ;) (+1). – Raaja Apr 11 at 14:45
• @Raaja That was the plan ;) – Tomáš Kruliš Apr 12 at 7:30

I always thought electrons were green because this is how they look on an oscilloscope. ;-) With eso-pic it is straightforward.

\documentclass[12pt,twoside]{book}

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

\usepackage{refcount}
\setrefcountdefault{-1}

%\usepackage[scale=1,opacity=1]{background}
\usepackage{eso-pic}

\usepackage{lipsum}
\usepackage{tikz}

\newcommand{\nuclei}[1]{%
}

\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];
}

\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}
}