13

I'm trying to show images step by step at the same location. This is my code:

\documentclass[xcolor=dvipsnames]{beamer}

\begin{document}
\section{Approach}

\begin{frame}{Approaches}
\only<1->{
Hello, world.
}

\only<2>{
   \begin{figure}[ht]
       \includegraphics[width=5cm]{pic/intro2.pdf}
    \end{figure}
 }
\only<3>{
   \begin{figure}[ht]
       \includegraphics[width=5cm]{pic/intro3.pdf}
    \end{figure}
 }

\end{frame}

\end{document}

The issue is that the texts (Hello, world) varies in its location for each slide. How can I fix the location?

enter image description here

When used with \visible command, the texts are located in the same locations, but this is not what I expect as I want to have the diagrams at the same location also.

enter image description here

The compiled pdf can be downloaded at: https://dl.dropboxusercontent.com/u/10773282/2014/tex.pdf

6
  • \begin{frame}[t] \frametitle{Approaches} \vspace*{1cm} and then your code with \only... -- this should work. The [t] stands for top -- the frame won't be centered but rather top-aligned, therefore the presence or the size of the figures won't matter. \vspace*{1cm} is necessary only if you want to somehow center the thing.
    – yo'
    Oct 15, 2014 at 17:26
  • @tohecz: It works; could you make it as an answer?
    – prosseek
    Oct 15, 2014 at 17:38
  • You could also use the animate package. Oct 15, 2014 at 17:38
  • @Uwe Ziegenhagen; could you give some examples?
    – prosseek
    Oct 15, 2014 at 17:39
  • I just got started (right now I am working on an article for the German TeX Magazine) but yes: uweziegenhagen.de/?p=3048 This example uses the inline animation feature, the package however also supports externally generated animations. I'll post an example via my blog in a few days. Oct 15, 2014 at 17:47

2 Answers 2

11

enter image description here

\documentclass[xcolor=dvipsnames]{beamer}

\begin{document}
\section{Approach}

\begin{frame}{Approaches}
\only<1->{
Hello, world.
}

\begin{figure}[ht]
    \begin{overlayarea}{5cm}{4cm} % your height
     \includegraphics[width=2cm]<2>{1.jpg}
     \includegraphics[width=2cm]<3>{3.jpg}
     \end{overlayarea}
\end{figure}

Bouh !
\end{frame}

\end{document}
1
  • If only I could create such an animation using beamer.
    – user4417
    Mar 2, 2017 at 23:45
3

To me, it always seemed the simplest to just align the problematic frame on top using [t], as in:

\documentclass[xcolor=dvipsnames]{beamer}

\begin{document}
\section{Approach}

\begin{frame}[t]{Approaches}

\vspace*{1cm}

Hello, world.

\only<2>{\centerline{
  \color{red}\rule{4cm}{3cm}% put the first figure here
}}

\only<3>{\centerline{
  \color{green}\rule{4cm}{5cm}% put the second figure here
}}

\end{frame}

\end{document}

As well notice that I removed the figure environment and used \centerline instead. If there's no need for a caption, there's no need for figure environment, and there's never a need for a caption on slides. Moreover, you don't want anything to "float", right? :)

You must log in to answer this question.

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