Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix the postion of blocks while changing images in beamer presentation?

I would like to make an animation using beamer. A picture should replace another during the transition. I have a problem that the text will move its position during this animation. I have tried \only and \onslide but the question is not solved.

\begin{frame}{}
\onslide<1->{some text }
 \onlide<1>{
 \begin{figure}[H]
  \centering
  \includegraphics[width=4in]{Figures/fig1.pdf}
\label{fig2}
\end{figure}
}
\onslide<2->{
\begin{figure}[H]
  \centering
  \includegraphics[,width=4in]{Figures/fig2.pdf}
\label{fig2}
\end{figure}
}


\end{frame}

The position of "some text" moves during animation.

like image 840
C SI Avatar asked Oct 31 '25 22:10

C SI


1 Answers

  • your code has many unprotected line endings (missing % at the end of lines) that act like a space

  • onlide should be onslide

  • \onslide<> makes the content just invisible, but still reserves space. You want to use \only instead

  • floating specifier such as [H] don't make sense in a documentclass without floating mechanism

  • \centering is unnecessary, beamer figures are centred by default

  • you must not use the same lable multiple times

  • \includeggraphics is overlay aware, just use that and avoid all the other pitfalls:

\documentclass{beamer}

\begin{document}
    
\begin{frame}
\begin{figure}
  \includegraphics<+>[width=4in]{example-image}
  \includegraphics<+>[width=4in]{example-image-duck}
\end{figure}
\end{frame} 
    
\end{document}
like image 168
samcarter_is_at_topanswers.xyz Avatar answered Nov 04 '25 19:11

samcarter_is_at_topanswers.xyz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!