1

I have a slide consisting of 1. a block of text, followed by 2. an image, that is replaced by 3. a second image. My code looks like this:

\begin{frame}

\onslide<1->{Some text}%

\begin{center}
\only<2> {\includegraphics{image1}}%
\only<3> {\includegraphics{image2}}%
\end{center}

\end{frame}

The problem is, the text doesn't seem to know that an image is going to appear next, and then it moves when the image shows. Look:

enter image description here enter image description here

Obviously, I don't want the text to move (it should assume its final position on the first slide). How should I correct this code?

1
  • Try to use \uncover instead of \only. To show you, how this work, please extend your code snippet to complete small document.
    – Zarko
    Commented Sep 1, 2020 at 12:09

2 Answers 2

1

You were on right track, You only need to insert empty lines between images. Extending and slightly correcting your code fragment to:

\documentclass{beamer}

\begin{document}
\begin{frame}

Some text

\begin{center}
\only<2> {\includegraphics[width=0.8\linewidth]{example-image-a}} 

\only<3> {\includegraphics[width=0.8\linewidth]{example-image-b}} 
\end{center}

\end{frame}
\end{document}

should works as desired.

2
  • Just tried, the text is now placed correctly, but image1 is now flushed left and image2 flushed right, instead of both centered (image2 is supposed to replace image1 exactly at the same position). Any idea how to fix that?
    – Seub
    Commented Sep 1, 2020 at 12:38
  • @Seub,I misunderstood your question. You were on right track ... Now corrected.
    – Zarko
    Commented Sep 1, 2020 at 12:50
2

Beamer places the contents vertically centered, if not defined otherwise. Based on this you may use the option that the contents start on top.

\begin{frame}[t]
   Contents 
\end{frame}
1
  • Good to know, thank you.
    – Seub
    Commented Sep 1, 2020 at 15:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .