3

I have five images, want to show first image1 on frame 1-> then press enter or click then->image2 appears on same frame....till 5th image5

\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{image of txs}
\begin{itemize}
\item
  \only<1>{\includegraphics[height=5cm]{images/ps1.png}}
  \only<1>{\includegraphics[height=5cm]{images/ps2.png}}
\only<1>{\includegraphics[height=5cm]{images/ps3.png}}
  \only<1>{\includegraphics[height=5cm]{images/ps4.png}}
\only<1>{\includegraphics[height=5cm]{images/ps5.png}}

 \end{itemize}
\end{frame}
\end{document}

Which package i shouls use? In first image, i have empty boxs in second have A B C,so that after overlapping , boxes fill with content.

2
  • 2
    It's not a question of which package. Beamer is sufficient. You just need to fix the overlay specifications and maybe use something other than \only. Right now, you are showing every image on the first slide of the frame and no other. Maybe you want \only<2>, \only<3>, \only<4> and \only<5> for images 2-5? But more likely you want overlay specifications such as <1->, <2-> etc. Without code we can compile to test it is hard to help, but you will need to undo the spacing the first 4 images take if they are supposed to overlap. Can you provide the code for the images?
    – cfr
    Dec 2, 2023 at 3:22
  • Or if you can't provide the code for the images, you can \includegraphics{example-image} and {example-image-a} and -b and -c. We all have those automatically.
    – Teepeemm
    Dec 2, 2023 at 3:42

3 Answers 3

3

Without code for the pictures (or some equivalent), it isn't possible to test this properly. The following assumes that all 5 images have the same dimensions. If this is false, you would need to adjust the horizontal and/or vertical spacing to align things correctly.

\PassOptionsToPackage{draft}{graphicx}
\documentclass{beamer}
\begin{document}
\begin{frame}
  \frametitle{image of txs}
  \begin{itemize}
    \item 
    \raisebox{-25mm}{% https://tex.stackexchange.com/a/702887/
      \includegraphics<1->[height=5cm]{images/ps1.png}%
      \smash[c]{\llap{\includegraphics<2->[height=5cm]{images/ps2.png}}}%
      \smash[c]{\llap{\includegraphics<3->[height=5cm]{images/ps3.png}}}%
      \smash[c]{\llap{\includegraphics<4->[height=5cm]{images/ps4.png}}}%
      \smash[c]{\llap{\includegraphics<5->[height=5cm]{images/ps5.png}}}}    
  \end{itemize}
\end{frame}
\end{document}

overlapping draft images

This overlays/overlaps the images rather than replacing them. If you want replacement, you don't need the \smash or \llap at all. In the case, you can just delete the hyphens from the overlay specifications to implement sequential use.

    \raisebox{-25mm}{% https://tex.stackexchange.com/a/702887/
      \includegraphics<1>[height=5cm]{images/ps1.png}%
      \includegraphics<2>[height=5cm]{images/ps2.png}%
      \includegraphics<3>[height=5cm]{images/ps3.png}%
      \includegraphics<4>[height=5cm]{images/ps4.png}%
      \includegraphics<5>[height=5cm]{images/ps5.png}}    

Note that \includegraphics is itself 'overlay-aware' in Beamer and you can configure an overlay specification directly rather than needling a command such as \only, at least in simple cases.

sequential images

3

It seems that you after something like this:

\documentclass{beamer}

\begin{document}
\begin{frame}
\frametitle{image of txs}
    \begin{center}
\setkeys{Gin}{height=5cm}
\only<1>{\includegraphics{example-image}}%{images/ps1.png}}
\only<2>{\includegraphics{example-image-a}}%{images/ps2.png}}
\only<3>{\includegraphics{example-image-b}}%{images/ps3.png}}
\only<4>{\includegraphics{example-image-c}}%{images/ps4.png}}
\only<5>{\includegraphics{example-image-duck}}%{images/ps5.png}}
    \end{center}
\end{frame}
\end{document}

enter image description here

10
  • Clearly, the setkeys is passing height=5cm to all of the includegraphics, but how? Or perhaps more relevantly, how would I find out that Gin is the correct first argument?
    – Teepeemm
    Dec 2, 2023 at 4:01
  • 2
    (+1) though I'm not sure this is what the OP wants. (As in: I really don't know and couldn't decide between 2 interpretations, hence a binary answer.) @Teepeemm page 14 of graphicx manual? (Section on globally setting keys.)
    – cfr
    Dec 2, 2023 at 4:12
  • 1
    @cfr, me either not sure what OP means with "merging" images. +1 for your nice answer!
    – Zarko
    Dec 2, 2023 at 4:28
  • I must remember that technique with \setkeys. That's very neat.
    – cfr
    Dec 2, 2023 at 5:10
  • Still all images are appearing on different frames. At end of all images, i am not getting combine form of all images.
    – sara lee
    Dec 2, 2023 at 6:36
2

Beamer makes \includegraphics overlay aware, this means you don't have to wrap it into the \only macro, you can simply use \includegraphics<...>{...} to specify on which overlay the image should be visible.

\documentclass{beamer}
\begin{document}
\begin{frame}
  \frametitle{image of txs}
  \includegraphics<1->[height=1cm]{example-image-a}%
  \includegraphics<2->[height=1cm]{example-image-b}%
  \includegraphics<3->[height=1cm]{example-image-c}%
  \includegraphics<4->[height=1cm]{example-image}%
  \includegraphics<5->[height=1cm]{example-image-duck}%
\end{frame}
\end{document}

enter image description here

1
  • As I already pointed out ;).
    – cfr
    Dec 3, 2023 at 1:43

You must log in to answer this question.

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