I have an image that I want to explain with floating texts, arrows, and circles. To do so, I thought about creating a textblock
environment (to put text) and a picture environment (to put the arrows and ovals) nested into an onlyenv
environment. Into a unique frame, I could put as many \onlyenv
as I want to move the texts, arrows, and circles around the picture.
Expected behaviour: The textblock
and the picture environment should appear only in the layers defined by the onlyenv
environment.
Observed behaviour: Only the picture environment obeyed the \onlyenv
setting. The textblock
environment appears in all layers.
For instance, consider the following LaTeX
file
\documentclass{beamer}
\usepackage{lipsum}
\usepackage[absolute,overlay]{textpos}
% graphical config
\setlength{\unitlength}{1cm} % set default length
\thicklines
\begin{document}
\begin{frame}{Title}
\begin{onlyenv}<+>
\begin{figure}
\vspace{3cm}
% \centering
\includegraphics[scale=0.25]{example-image-a}
\end{figure}
\begin{picture}(1,1)
\put(6.5,5){\vector(1,-1){0.85}}
\put(8.7,3.1){\oval(3.1,2.5)}
\put(8.7,3.1){\thebeamerpauses}
\end{picture}
\begin{textblock}{10}(1,3)
\lipsum[66] \thebeamerpauses
\end{textblock}
\end{onlyenv}
\begin{onlyenv}<+>
\begin{figure}
\vspace{3cm}
% \centering
\includegraphics[scale=0.25]{example-image-b}
\end{figure}
\begin{picture}(1,1)
\put(6.5,1){\vector(1,-1){0.85}}
\put(6.7,2.1){\oval(3.1,2.5)}
\put(6.7,2.1){\thebeamerpauses}
\end{picture}
\begin{textblock}{10}(1,9)
\lipsum[75] \thebeamerpauses
\end{textblock}
\end{onlyenv}
\end{frame}
\end{document}
This yields
Best Answer
The
textpos
[overlay] option uses a fairly simple-minded mechanism to control the order in which elements are added to the output page. Thebeamer
environment does quite sophisticated things to control positioning on the page, and these are unlikely to interact well with the [overlay] mode.Instead, use
textpos
without options:\usepackage{textpos}
. In this mode, the{textblock}
environment simply adds a zero size box to the page, and the offset(hpos,ypos)
is relative to the location of this box on the page. Specifically, in this modetextpos
does nothing clever about adding material, so can't confuse, or be confused by, beamer.If you move the
{textblock}
to the beginning of the{frame}
, which will have a consistent, predictable position, and writethen you might get the effect you're looking for.