39

I would to \pause two different images (as I can to do with text). This is the ideal code:

\documentclass{beamer}

\usetheme{Copenhagen}
\setbeamercovered{dynamic}

\begin{document}

\begin{frame}
\centering
\includegraphics{gfx/img1} \\
\pause
\includegraphics{gfx/img2}
\end{frame}

\end{document}

What is the real code?

I see both the images on each pause.

Edit: I would to preserve the absolute position of the images and the dynamic behaviour.

5
  • 1
    Your code is the real code (adding \par or a blank line after the second \includegraphics). Commented Dec 7, 2011 at 19:32
  • @GonzaloMedina It doesn't work =(
    – Baduel
    Commented Dec 7, 2011 at 19:41
  • 3
    Saying just "it doesn't work" is useless. What exactly doesn't work? What error(s) do you get? I did a test before posting my comment and it worked, so please explain what exactly doesn't work. Commented Dec 7, 2011 at 19:44
  • @GonzaloMedina It compiles but I see both the images. I now also add something in the preamble. Maybe the dynamic option is the problem?
    – Baduel
    Commented Dec 7, 2011 at 19:47
  • Yes, dynamic was the key here! Commented Dec 7, 2011 at 19:58

3 Answers 3

45

You can also use

\visible<1>{content}

in order to have content only visible on slide 1, but reserve space for it on the other slides. This may help you with your positioning problem.

4
  • 1
    I added to my answer a complete example using your suggestion; I hope it's OK with you. Commented Dec 7, 2011 at 23:33
  • Thank you. Is it possible to preserve the dynamic behaviour? i.e. not visible image semitransparent.
    – Baduel
    Commented Dec 8, 2011 at 10:26
  • 1
    @Baduel I don't think it is possible with \includegraphics, as beamer does not know how to make the image semitransparent. That is in fact why you saw both images in your first version. You can try drawing a tikz picture instead of using \includegraphics, and it should show semitransparent even in your first code version.
    – silvado
    Commented Dec 8, 2011 at 11:49
  • Ok thanks. I don't know tikz, but I will remedy.
    – Baduel
    Commented Dec 8, 2011 at 11:56
26

You can use \only:

\documentclass{beamer}
\setbeamercovered{dynamic}

\begin{document}

\begin{frame}
\centering
\only<1->{\includegraphics[width=4cm]{ctanlion}}
\only<2>{\includegraphics[width=4cm]{ctanlion}}\par
\end{frame}

\end{document}

To preserve the relative position in slide one, you can use overlayarea:

\documentclass{beamer}
\setbeamercovered{dynamic}

\begin{document}

\begin{frame}
\vskip10pt
\begin{overlayarea}{\textwidth}{.45\textheight}
  \centering
  \only<1-|handout:0>{\includegraphics[width=4cm]{ctanlion1}}
\end{overlayarea}%
\begin{overlayarea}{\textwidth}{.45\textheight}
  \centering
  \only<2>{\includegraphics[width=4cm]{ctanlion2}}
\end{overlayarea}
\end{frame}

\end{document}

and, since \includegraphics is overlay-aware, you can also say

\documentclass{beamer}
\setbeamercovered{dynamic}

\begin{document}

\begin{frame}
\vskip10pt
\begin{overlayarea}{\textwidth}{.45\textheight}
  \centering
  \includegraphics<1-|handout:0>[width=4cm]{ctanlion}
\end{overlayarea}%
\begin{overlayarea}{\textwidth}{.45\textheight}
  \centering
  \includegraphics<2>[width=4cm]{ctanlion}
\end{overlayarea}
\end{frame}

\end{document}

or, even simpler, \visible, as suggested by silvado; here's a complete version of the code:

\documentclass{beamer}
\setbeamercovered{dynamic}

\begin{document}

\begin{frame}
  \centering
  \visible<1-|handout:0>{\includegraphics[width=4cm]{ctanlion1}\\}
  \visible<2>{\includegraphics[width=4cm]{ctanlion2}}\par
\end{frame}

\end{document}
11
  • Perfect, is possible to preserve the original position? I wouldn't that first image disappears.
    – Baduel
    Commented Dec 7, 2011 at 20:02
  • @Baduel: see my updated answer. Commented Dec 7, 2011 at 20:06
  • Just make only the second one only. Also note that you can use ranges, e.g. only<2-> for one image and only<3-> fo the next. Then in the first subslide no image would be seen, in the second only the first, and in the third (and all following, if any follow) both.
    – celtschk
    Commented Dec 7, 2011 at 20:06
  • @GonzaloMedina Very nearly to what I want. Is it possible to preserve the absolute position in each step?
    – Baduel
    Commented Dec 7, 2011 at 20:42
  • Also note that want to do this in order to print the frame in only one slide, when I will put the handouts option.
    – Baduel
    Commented Dec 7, 2011 at 20:50
6

I have just answered a very similar question here on tex.stackexchange, and I figured it would be a good solution for your problem too.

So, in short, your code is almost perfect if you download this custom style file and add it with a usepackage statement:

\documentclass{beamer}

%% %% %% ADD THIS LINE
\usepackage{fixpauseincludegraphics}

\usetheme{Copenhagen}
\setbeamercovered{dynamic}

\begin{document}

\begin{frame}
\centering
\includegraphics{gfx/img1} \\
\pause
\includegraphics{gfx/img2}
\end{frame}

\end{document}

(the style file contains a rewritten version of \includegraphics that will draw your image with some added opacity).

5
  • 2
    I just tried this and I get "! Undefined control sequence. <argument> \transparent@value /100 "
    – Simd
    Commented Oct 22, 2013 at 16:01
  • @Jealie, the second link is not working as expected.
    – epsilone
    Commented Dec 4, 2014 at 9:18
  • 1
    Check this for the package Commented Apr 27, 2015 at 1:15
  • @ArturoVolpe: thank you for the new link! I have updated the response.
    – Jealie
    Commented Apr 27, 2015 at 17:58
  • @felix apparenlty, you need a \begin{itemize}[<+->] somewhere before the \includegraphics. Commented Apr 27, 2015 at 21:52

You must log in to answer this question.

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