Title picture misplaced in Beamer when using 'show notes on second screen' and absolute 'pgf' positioning

When I try to do something like the following, everything works fine and dandy; The title graphic (here represented by the LaTeX logo with the reddish background) is shown just fine.

\documentclass{beamer}
\usepackage{pgfpages,tikz}
%\setbeameroption{show notes on second screen=right}
\author{Euclid}
\title{There Is No Largest Prime Number}
\titlegraphic{%
\begin{tikzpicture}[inner sep=0, remember picture, overlay]
\node[anchor=south west, inner sep=0, shift={(5mm,5mm)}]
at (current page.south west)
[fill=red!20,rounded corners, above right]
{\Huge\LaTeX};
\end{tikzpicture}%
}
\begin{document}
\maketitle
\end{document}


If, however, I try to produce output that includes the notes in a separate logical page by enabling the commented line in above code, it seems that the pgf node current page is completely off and the title graphic ends up outside of the logical page. That this is the case can be seen from the small preview in the top-right corner of the notes page, where the title graphic is far to the south west of the preview.

If I remove the at (current page.south west) stanza, the title graphic ends up inside the frame again, but then positioning it correctly is almost impossible. Anybody got an idea of what is going on and how I can fix this?

-

This is because show notes on second slide uses pgfpages and pgfpages works by putting logical pages in boxes which then get set in places on the physical page. Unfortunately, this messes up absolute coordinates because there are now two coordinate systems in place: the internal one (where something is on a logical page) and the external one (where something is on a physical page). For absolute positioning, PGF needs to know the internal position but it is the absolute one that gets recorded to the aux file. The "solution" is to ensure that when PGF uses coordinates then it uses ones that are computed when the internal and external are the same. The way to do this is to use a two-step process:

1. Compile without the show notes on second screen option. In this scenario the coordinates are the same and so the correct coordinates are recorded in the aux file.

2. Compile with the show notes on second screen option but also use \nofiles. Here, the aux file is not updated and so the new coordinates are not recorded. Thus the correct coordinates are used.

Here's the code:

\documentclass{beamer}
%\url{http://tex.stackexchange.com/q/86378/86}
\usepackage{pgfpages,tikz}
%\setbeameroption{show notes on second screen=right}\nofiles

\author{Euclid}
\title{There Is No Largest Prime Number}
\titlegraphic{%
\begin{tikzpicture}[inner sep=0, remember picture, overlay]
\node[anchor=south west, inner sep=0, shift={(5mm,5mm)}]
at (current page.south west)
[fill=red!20,rounded corners, above right]
{\Huge\LaTeX};
\end{tikzpicture}%
}
\begin{document}
\maketitle
\end{document}


(It's not important that the \setbeameroption{...} and \nofiles are on the same line, just makes it easier to comment them out together.)

The result of the double run is:

-
Thanks, that did the trick. I read about running with \nofiles in the pgf manual, but somehow I didn't connect the dots... –  Michael Wild Dec 12 '12 at 9:36

This was tricky. I have rewritten the slides using an approach i have used in the past. I am sure it can be a good starting point for additional work. I have opted to use a picture environment and to \put the picture relative to the lower left corner. As you will see the picture ends up where I think you want it but the origin is for some reason vertically shifted possibly due to the footer line. I also use \titlepage (instead of \maketitle)to produce the title slide which I think is the preferred way.

\documentclass{beamer}
\usepackage{pgfpages,tikz}
\setbeameroption{show notes on second screen=right}
\setlength{\unitlength}{1mm} % sets unit length for pic env to mm
% note that a beamer slide by default is 128 mm wide and 96 mm high
\author{Euclid}
\title{There Is No Largest Prime Number}

\begin{document}
\begin{frame}

\titlepage

\begin{picture}(25,25)(0,0)% inserts a picture 25 by 25 mm (Should contain the text)
\put(0,0){%put the image in the ll corner
\begin{tikzpicture}%[inner sep=0, remember picture, overlay]%
% the following sets the image 5 mm in and 0 mm up, nudged by me!
\node [fill=red!20,rounded corners] at (5mm,0mm) {\Huge\LaTeX};
\end{tikzpicture}
}
\end{picture}

\end{frame}

\end{document}

-
Thanks, but if I put your picture environment into a \titlegraphic call, it ends up just somewhere close to the centre of the slide. This is so frustrating! –  Michael Wild Dec 12 '12 at 9:19