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

prosseek
  • 6,033

2 Answers2

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}
Tarass
  • 16,912
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? :)

yo'
  • 51,322