我有一系列圖像想要製作動畫beamer
。在每一幀中,我希望有兩個圖像,例如 A 和 B,垂直對齊並在頁面上居中。所有影像的尺寸相同。
我嘗試使用 來對齊圖像\vspace{}
,但是當我在圖像中過渡時,垂直空間會累積並且圖像會向下滑動。
我應該如何對齊每個畫面中的影像?
這是一個最小的工作範例:
\documentclass{beamer}
\begin{document}
\frame{
\begin{figure}[t!]
\includegraphics<1>[scale=.5]{fig/imageA1} \vspace{.1in}
\includegraphics<1>[scale=.5]{fig/imageB1}
\includegraphics<2>[scale=.5]{fig/imageA2} \vspace{.1in}
\includegraphics<2>[scale=.5]{fig/imageB2}
\includegraphics<3>[scale=.5]{fig/imageA3} \vspace{.1in}
\includegraphics<3>[scale=.5]{fig/imageB3}
\includegraphics<4>[scale=.5]{fig/imageA4} \vspace{.1in}
\includegraphics<4>[scale=.5]{fig/imageB4}
\end{figure}
}
\end{document}
答案1
在框架中使用浮動環境(例如 figure
或)無法以應有的方式運作。table
為了實現您的目標,請打開allowpagebreak
和T
。使用選項調整圖形height
。其餘部分請參閱下面的程式碼。
\documentclass{beamer}
\usepackage{graphicx}
\begin{document}
\frame[allowpagebreak,T]
{%
\only<1>
{%
\centering
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-a}
\vfill
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-a}
}%
\only<2>
{%
\centering
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-b}
\vfill
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-b}
}%
\only<3>
{%
\centering
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-c}
\vfill
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-c}
}%
\only<4>
{%
\centering
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image}
\vfill
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image}
}%
}
\end{document}
若要建立 GIF 動畫,請參閱我的另一個答案在這裡。
答案2
\vspace
您可以使用\\
來強制換行,而不是使用。
\documentclass{beamer}
\begin{document}
\frame{
\begin{figure}[t!]
\includegraphics<1>[scale=.5]{img} \\
\includegraphics<1>[scale=.5]{img}
\includegraphics<2>[scale=.5]{img} \\
\includegraphics<2>[scale=.5]{img}
\includegraphics<3>[scale=.5]{img} \\
\includegraphics<3>[scale=.5]{img}
\includegraphics<4>[scale=.5]{img} \\
\includegraphics<4>[scale=.5]{img}
\end{figure}
}
\end{document}
答案3
如果總共只有一個換行符,而不是每個圖像對都有一個換行符,那麼您的問題應該會消失。關鍵在於你的\vspace{.1in}
命令沒有被<1>
、<2>
、<3>
或掩蓋<4>
:
\documentclass{beamer}
\begin{document}
\frame{
\begin{figure}[t!]
\includegraphics<1>[scale=.5]{fig/imageA1}
\includegraphics<2>[scale=.5]{fig/imageA2}
\includegraphics<3>[scale=.5]{fig/imageA3}
\includegraphics<4>[scale=.5]{fig/imageA4}
\vspace{.1in}
\includegraphics<1>[scale=.5]{fig/imageB1}
\includegraphics<2>[scale=.5]{fig/imageB2}
\includegraphics<3>[scale=.5]{fig/imageB3}
\includegraphics<4>[scale=.5]{fig/imageB4}
\end{figure}
}
\end{document}