# Easy absolute positioning in beamer

For my presentaton slides I'd like to have list uncovered and highlighted by time and each item supported by appropriate image/graph/table.

Thinking about it in wider application, I'd like to find/create command:

\abspos{<anchor-spec>}{<coords>}{<content>}


where:

• <anchor-spec> specifies anchor point of positioned object. IE. NE for NorthEast corner point, etc.,
• <coorrds> specifies x-y-z coordinates on frame using standard LaTeX dimensions,
• <content> contain positioned graphics, table or text.

Idea of code for my purpose:

\begin{minipage}{.5\textwidth}
\begin{itemize}
\item<1-> Foo
\item<2-> Bar
\end{itemize}
\end{minipage}
\begin{minipage}{.5\textwidth}
\uncover<1>\abspos{C}{.5\textwidth,.5\textheight,1}{\includegraphics{foo}}
\uncover<2>\abspos{C}{.5\textwidth,.5\textheight,1}{\includegraphics{bar}}
\end{minipage}

• z? Are you able to project 3-dimensional PDFs? – Qrrbrbirlbel Dec 3 '12 at 2:22
• In HTML/CSS you have also z-index although web pages are 2D. This z coordinate should define order of visibility of objects. That's why there's no dimension in my MWE (minimal wanted example) – Crowley Dec 3 '12 at 9:32
• Ah, very well, you may add that to your question, although, it might be the trickiest part. I don’t have time now, but I can see a solution with either pst-abspos or textpos and/or TikZ using the special current page node. – Qrrbrbirlbel Dec 3 '12 at 15:39
• Something along the lines of \tikz[remember picture,overlay]\node[anchor=center] at (current page.center) {\includegraphics{foo}}; would do. The z part can be achieved by defining appropiate layers. – JLDiaz Dec 14 '12 at 18:50

Ok that's my try:

\documentclass{beamer}

\usepackage{tikz, etoolbox}

\usepackage{etoolbox}

\newcount\mycount

\def\mytempcoord{}
\def\mytempopa{}
%
\newcommand\doatpos[3]{%
\bgroup
\renewcommand*{\do}[1]{\ifnum\mycount<2
\edef\mytempcoord{\mytempcoord ##1%
\ifnum\mycount<1
,
\fi
}
\else
\edef\mytempopa{##1}
\fi
}
\begin{tikzpicture}[remember picture, overlay]
\node[anchor=#1, opacity=\mytempopa] at (\mytempcoord) {#3};
\end{tikzpicture}%
%
%
\egroup
%
}

\begin{document}
\frame{
\doatpos{west}{0cm, 3cm,.5}{This is text \rule{1cm}{1cm}}
\doatpos{west}{1cm, -3 cm,.7}{This is text a\rule{1cm}{1cm}}
}

\end{document}


I basically wrote a parser which divides this three item comma list in such a way that it can be used by an ordinary sequence like my TikZ overlay thing here. You might find that your third argument, the pseudo z-variable, needs no dimension. Well yes. Involving a certain key handler here could be useful. However, my opinion is different. I rather would introduce a new argument (in braces). That would make things much easier. (My very personal view is that mimicking the behavior of completely different systems is rather pointless.)

Same output, but no etoolbox:

\documentclass{beamer}

\usepackage{tikz}

\def\mytemparray{}

%
\newcommand\doatpos[3]{%
\bgroup
\def\mytemparray{{ #2 }}
\pgfmathparse{\mytemparray[0]} \edef\mya{\pgfmathresult}
\pgfmathparse{\mytemparray[1]} \edef\myb{\pgfmathresult}
\pgfmathparse{\mytemparray[2]} \edef\myc{\pgfmathresult} %also possible \pgfmathsetmacro
\begin{tikzpicture}[remember picture, overlay]
\node[anchor=#1, opacity=\myc] at ( \mya pt, \myb  pt) {#3};
\end{tikzpicture}%
%
%
\egroup
%
}

\begin{document}
\frame{
\doatpos{west}{0, 3 cm, .5}{This is text \rule{1cm}{1cm}}
\doatpos{west}{1cm, -3 cm,.7}{This is text a\rule{1cm}{1cm}}
}
\end{document}


This alternative uses pgfmath for list-processing. Since pgfmathparse is very expansion unfriendly i decided to hard-code and put those three elements in distinguished macros. This solution is again very specific and inflexible, but i think it's more obvious how to process more items in the list.

• Very useful. I have tried this with images and it works great. – dorien May 20 '14 at 11:51