Beamer:对于两张相同大小的图像,如何避免由于下方文字的长度而导致图像发生偏移?

Beamer:对于两张相同大小的图像,如何避免由于下方文字的长度而导致图像发生偏移?

这是我之前的一个问题的后续: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. https://www.librarycat.com/boomer-cat-jejune/

  2. https://i.ytimg.com/vi/gCrxcjWjNA4/hqdefault.jpg

答案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}

在此处输入图片描述

(由于文本和图像都在变化,我不明白为什么这应该是一个覆盖)

相关内容