![Beamer:对于两张相同大小的图像,如何避免由于下方文字的长度而导致图像发生偏移?](https://linux22.com/image/361165/Beamer%EF%BC%9A%E5%AF%B9%E4%BA%8E%E4%B8%A4%E5%BC%A0%E7%9B%B8%E5%90%8C%E5%A4%A7%E5%B0%8F%E7%9A%84%E5%9B%BE%E5%83%8F%EF%BC%8C%E5%A6%82%E4%BD%95%E9%81%BF%E5%85%8D%E7%94%B1%E4%BA%8E%E4%B8%8B%E6%96%B9%E6%96%87%E5%AD%97%E7%9A%84%E9%95%BF%E5%BA%A6%E8%80%8C%E5%AF%BC%E8%87%B4%E5%9B%BE%E5%83%8F%E5%8F%91%E7%94%9F%E5%81%8F%E7%A7%BB%EF%BC%9F.png)
这是我之前的一个问题的后续:Beamer:如何避免图像因下方文本的长度而发生偏移?
我有代码:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
%Information to be included in the title page:
\title{Sample title}
\author{Anonymous}
\institute{ShareLaTeX}
\date{2014}
\begin{document}
\frame{\titlepage}
\begin{frame}
\frametitle{Sample frame title}
\begin{figure}
\centering
\includegraphics[scale=0.3]{cat1.jpg}
\caption{Cat Lying on a Sofa}
\label{fig:my_label}
\end{figure}
Sunny, yesterday my life was filled with rain
Sunny, you smiled at me and really eased the pain
The dark days are gone, and the bright days are here
My Sunny one shines so sincere
Sunny one so true, I love you
Sunny, thank you for the sunshine bouquet
Sunny, thank you for the love you brought my way
You gave to me your all and all
Now I feel ten feet tall
Sunny one so true, I love you
\end{frame}
\begin{frame}
\frametitle{Sample frame title}
\begin{figure}
\centering
\includegraphics[scale=0.3]{cat2.jpg}
\caption{Cat Sitting Inside of a Box}
\label{fig:my_label}
\end{figure}
Sunny, thank you for the truth you let me see
\end{frame}
\end{document}
生成:
其次是
这两张图片都是 480 X 360。但是,由于下方的文本数量,图像的位置发生了偏移(与页面顶部的空白量不同)。
是否可以使用叠加和其他方法使两幅图像在第一张幻灯片的猫图像的位置对齐?
猫图像:
答案1
描述的技术这个答案非常适合您所考虑的场景。如果情况没有改变,请务必使用它。没有必要让生活变得比需要的更复杂。
我将在此提供另一组幻灯片,以演示需要图像和文本叠加的位置。请特别注意叠加内的幻灯片编号。
\documentclass{beamer}
\usepackage[utf8]{inputenc}
% Information to be included in the title page:
\title{Sample Title}
\author{Anonymous}
\institute{ShareLaTeX}
\date{2014}
\begin{document}
\frame{\titlepage}
\begin{frame}
\frametitle{Sample Frame Title}
\begin{overprint}
\onslide<1-2,4>
\begin{figure}
\centering
\includegraphics[scale=0.3]{cat1.jpg}
\caption{Cat Lying on a Sofa}
\label{fig:my_label1}
\end{figure}
\onslide<3,5>
\begin{figure}
\centering
\includegraphics[scale=0.3]{cat2.jpg}
\caption{Cat Sitting Inside of a Box}
\label{fig:my_label2}
\end{figure}
\end{overprint}
\begin{overprint}
\onslide<1>
Sunny, yesterday my life was filled with rain
Sunny, you smiled at me and really eased the pain
The dark days are gone, and the bright days are here
My Sunny one shines so sincere
Sunny one so true, I love you
Sunny, thank you for the sunshine bouquet
Sunny, thank you for the love you brought my way
You gave to me your all and all
Now I feel ten feet tall
Sunny one so true, I love you
\onslide<2-3>
Sunny, I can tell you this in many ways
\onslide<4-5>
Sunny, thank you for the truths you let me see
\end{overprint}
\end{frame}
\end{document}
答案2
与您上一个问题的答案相同:顶部对齐的框架将为您省去很多对齐的麻烦:
\documentclass[t]{beamer}
\begin{document}
\begin{frame}
\frametitle{Sample frame title}
\begin{figure}
\centering
\includegraphics[scale=0.3]{example-image}
\caption{Cat Lying on a Sofa}
\label{fig:my_label}
\end{figure}
Sunny, yesterday my life was filled with rain
Sunny, you smiled at me and really eased the pain
The dark days are gone, and the bright days are here
My Sunny one shines so sincere
Sunny one so true, I love you
Sunny, thank you for the sunshine bouquet
Sunny, thank you for the love you brought my way
You gave to me your all and all
Now I feel ten feet tall
Sunny one so true, I love you
\end{frame}
\begin{frame}
\frametitle{Sample frame title}
\begin{figure}
\centering
\includegraphics[scale=0.3]{example-image}
\caption{Cat Sitting Inside of a Box}
\label{fig:my_label_a}
\end{figure}
Sunny, thank you for the truth you let me see
\end{frame}
\end{document}
(由于文本和图像都在变化,我不明白为什么这应该是一个覆盖)