我有几个框架,其中包含相同大小但不同长度的标题。我目前使用的代码如下:
\begin{frame}
\begin{figure}[!ht]
\centering
\includegraphics[width=0.7\textwidth]{image1}
\caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
\end{figure}
\end{frame}
\begin{frame}
\begin{figure}[!ht]
\centering
\includegraphics[width=0.7\textwidth]{image2}
\caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxx}
\end{figure}
\end{frame}
结果是两个图形在各自的框架内不在同一个位置:第一个图形的上边距比第二个图形的上边距更宽。
我怎样才能将这些图形对齐到顶部,以便它们在每一帧中占据相同的空间?
答案1
添加 \ vfill` 似乎可以解决问题:
\documentclass[demo]{beamer}
\usepackage{caption}
\begin{document}
\begin{frame}
\begin{figure}[!ht]
\centering
\includegraphics[width=0.7\textwidth]{image1}
\caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
\end{figure}
\vfill\null
\end{frame}
\begin{frame}
\begin{figure}[!ht]
\centering
\includegraphics[width=0.7\textwidth]{image2}
\caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxx}
\end{figure}
\end{frame}
\end{document}
答案2
根据您想要实现的确切输出,您还可以将选项添加[t]
到环境中frame
:
\documentclass[demo]{beamer}
\usepackage{caption}
\begin{document}
\begin{frame}[t]
\begin{figure}
\centering
\includegraphics[width=0.7\textwidth]{image1}
\caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
\end{figure}
\end{frame}
\begin{frame}[t]
\begin{figure}
\centering
\includegraphics[width=0.7\textwidth]{image2}
\caption{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxx}
\end{figure}
\end{frame}
\end{document}