
答案1
在邊界框設定為圖片大小的範圍內新增雲註解。這樣雲就不會佔用額外的空間。 (實際上在這個例子中不需要範圍,但是有了它,圖形可以在範圍之後繼續,而不會影響雲部分。)
\documentclass{beamer}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc,shapes}
\begin{document}
\begin{frame}
\frametitle{Test}
\centering
\begin{tikzpicture}
\node[inner sep=0pt](Img){\includegraphics[width=0.7\linewidth]{example-image}};
\draw<2->[line width=2pt,red](Img.north west) rectangle +(4,-2.5);
\draw<3->[line width=2pt,black!20!green](Img.south west) rectangle ($(Img.south east) + (0,3.1)$);
\onslide<4->{%
\begin{scope}
\useasboundingbox(Img.south west)--(Img.north east);
\node[draw,cloud,anchor=south east,aspect=3,fill=blue,text=white] (Cloud) at ($(Img.north east)+(-0.5,0.5)$){2 variables};
\draw[-latex,very thick] (Cloud.south west) to[bend right] ($(Img.center)+(2,1)$);
\end{scope}}
\end{tikzpicture}
\end{frame}
\end{document}