![在投影机中将图形对齐到顶部](https://linux22.com/image/398997/%E5%9C%A8%E6%8A%95%E5%BD%B1%E6%9C%BA%E4%B8%AD%E5%B0%86%E5%9B%BE%E5%BD%A2%E5%AF%B9%E9%BD%90%E5%88%B0%E9%A1%B6%E9%83%A8.png)
我有几个框架,其中包含相同大小但不同长度的标题。我目前使用的代码如下:
\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}