我有五幅图像,想要在第 1 帧上显示第一幅图像 1->然后按回车键或单击->图像 2 出现在同一帧上....直到第 5 幅图像 5
\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}
我应该使用哪种包装?在第一张图片中,我有空盒子,第二张图片中有 ABC,因此重叠后,盒子会填充内容。
答案1
如果没有图片代码(或类似代码),就无法正确测试。以下假设所有 5 张图片的尺寸相同。如果这是错误的,您需要调整水平和/或垂直间距以正确对齐。
\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}
这会覆盖/重叠图像,而不是替换它们。如果您想要替换,则根本不需要\smash
或\llap
。在这种情况下,您只需从覆盖规范中删除连字符即可实现顺序使用。
\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}}
请注意,\includegraphics
在 Beamer 中,它本身是“覆盖感知”的,您可以直接配置覆盖规范,而不必使用诸如 之类的命令\only
,至少在简单情况下是这样。
答案2
看起来你正在追求这样的事情:
\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}
答案3
Beamer 使\includegraphics
覆盖层可感知,这意味着您不必将其包装到\only
宏中,您只需使用它\includegraphics<...>{...}
来指定图像应该在哪个覆盖层上可见。
\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}