Beamer - 结合创建覆盖层的方式

Beamer - 结合创建覆盖层的方式

我想创建一个带有文本的框架,每次显示一个项目,底部有一张图片,当显示新文本时会发生变化。我做了以下天真的尝试:

\documentclass{beamer}

\begin{document}
\begin{frame}{title}

  \begin{itemize}
    \item text 1
    \pause
    \item text 2
  \end{itemize}

  \includegraphics<1>[height=40mm]{pic1.jpg}

  \includegraphics<2>[height=40mm]{pic2.jpg}

\end{frame}
\end{document}

然而,这失败了;pic1 没有显示。

我猜问题在于 pic1 的 includegraphics 出现在暂停之后,但我怎样才能将它放在暂停之前并确保它与 pic2 位于同一位置?

另一个解决方案是根本不使用暂停,但我看到的替代方法是对幻灯片中的所有项目使用数字,这在包含许多项目的幻灯片中会非常麻烦。

答案1

(请参阅下文我的第一个回答)

编辑:更完整和可定制的解决方案(使用列将图像放在左侧或右侧)。

在此处输入图片描述

\documentclass{beamer}
\usepackage{tikz}
\usepackage{calc}
\usepackage{lipsum}

% put a node on absolute position on the page
% (two compilations is necessary to get a good placement)
% #1: anchor of the page
% #2: shift vector
% #3: anchor of the node
% #4: minimum height of the node
% #5: minimum width of the node
% #6: content
\newcommand\absoluteput[6]{%
  \begin{tikzpicture}[overlay,remember picture]
    \path (current page.#1) ++ (#2)
    node[#3,minimum height=#4,minimum width=#5]{#6};
  \end{tikzpicture}%
}
% put a node 5mm above the south of the page
% #1: min height
% #2: content
\newcommand\putbottom[2]{\absoluteput{south}{0,5mm}{above}{#1}{0}{#2}}
% put a node 5mm to the left of the east of the page
% #1: min width
% #2: content
\newcommand\putright[2]{\absoluteput{east}{-5mm,0}{left}{0}{#1}{#2}}

% put a node 5mm to the right of the west of the page
% #1: min width
% #2: content
\newcommand\putleft[2]{\absoluteput{west}{5mm,0}{right}{0}{#1}{#2}}

\begin{document}

\begin{frame}{Frame with images at bottom}
  \begin{itemize}[<+->]
  \item Pellentesque interdum sapien sed nulla.
    \putbottom{42mm}{\includegraphics<.>[height=40mm]{example-image}}
  \item Proin tincidunt.
    \putbottom{42mm}{\includegraphics<.>[height=30mm]{example-image-a}}
  \item Aliquam volutpat est vel massa.
    \putbottom{42mm}{\includegraphics<.>[height=20mm]{example-image}}
  \item Sed dolor lacus, imperdiet non, ornare non, commodo eu,
    neque. Integer pretium semper justo.
    \putbottom{42mm}{\includegraphics<.>[height=42mm]{example-image-a}}
  \end{itemize}
  \vfill
  \vspace*{47mm} % 5mm (margin) + 42mm (max height of images)
\end{frame}

\begin{frame}{Frame with images on the right}
  \begin{columns}

    \column{\linewidth-5mm-47mm} % \linewidth - (margin) - (max width of images)

    \begin{itemize}[<+->]
    \item Pellentesque interdum sapien sed nulla.
      \putright{47mm}{\includegraphics<.>[width=40mm]{example-image}}
    \item Proin tincidunt.
      \putright{47mm}{\includegraphics<.>[width=30mm]{example-image-a}}
    \item Aliquam volutpat est vel massa.
      \putright{47mm}{\includegraphics<.>[width=20mm]{example-image}}
    \item Sed dolor lacus, imperdiet non, ornare non, commodo eu,
      neque. Integer pretium semper justo.
      \putright{47mm}{\includegraphics<.>[width=47mm]{example-image-a}}
    \item Proin tincidunt.
      \putright{47mm}{\includegraphics<.>[width=30mm]{example-image-a}}
    \item Aliquam volutpat est vel massa.
      \putright{47mm}{\includegraphics<.>[width=20mm]{example-image}}
    \item Sed dolor lacus, imperdiet non, ornare non, commodo eu,
      neque. Integer pretium semper justo.
      \putright{47mm}{\includegraphics<.>[width=42mm]{example-image-a}}
    \end{itemize}

    \column{47mm} % (max width of images)

  \end{columns}
\end{frame}

\begin{frame}{Frame with images on the left}
  \begin{columns}

    \column{30mm} % (max width of images)

    \column{\linewidth-5mm-30mm} % \linewidth - (margin) - (max xidth of images)

    \begin{itemize}[<+->]
    \item Pellentesque interdum sapien sed nulla.
      \putleft{30mm}{\includegraphics<.>[angle=90,width=30mm]{example-image}}
    \item Proin tincidunt.
      \putleft{30mm}{\includegraphics<.>[width=30mm]{example-image-a}}
    \item Aliquam volutpat est vel massa.
      \putleft{30mm}{\includegraphics<.>[width=20mm]{example-image}}
    \item Sed dolor lacus, imperdiet non, ornare non, commodo eu,
      neque. Integer pretium semper justo.
      \putleft{30mm}{\includegraphics<.>[width=30mm]{example-image-a}}
    \item Proin tincidunt.
      \putleft{30mm}{\includegraphics<.>[width=30mm]{example-image-a}}
    \item Aliquam volutpat est vel massa.
      \putleft{30mm}{\includegraphics<.>[width=30mm]{example-image}}
    \item Sed dolor lacus, imperdiet non, ornare non, commodo eu,
      neque. Integer pretium semper justo.
      \putleft{30mm}{\includegraphics<.>[width=16mm]{example-image-a}}
    \end{itemize}

  \end{columns}
\end{frame}
\end{document}

第一个答案:

您可以使用 TikZ 在绝对位置添加图片,并且可以使用选项<+->itemize使用增量叠加规范。我添加了调用vfill\vspace...保留图像空间。

你(们)能做到

在此处输入图片描述

这里,代码:

\documentclass{beamer}
\usepackage{tikz}

% put a node 5mm above the bottom of the page
% (two compilations required to get a good placement)
\newcommand\myabsoluteplace[1]{%
  \begin{tikzpicture}[overlay,remember picture]
    \node[anchor=south] at ([yshift=5mm]current page.south) {#1};
  \end{tikzpicture}%
}

\begin{document}
\begin{frame}{title}
  \begin{itemize}[<+->]
  \item text 1 \myabsoluteplace{\includegraphics<.>[height=40mm]{example-image}}
  \item text 2  \myabsoluteplace{\includegraphics<.>[height=30mm]{example-image-a}}
  \item text 3 \myabsoluteplace{\includegraphics<.>[height=20mm]{example-image}}
  \item text 4  \myabsoluteplace{\includegraphics<.>[height=42mm]{example-image-a}}
  \end{itemize}
  \vfill
  \vspace*{47mm} % 5mm (margin) + 42mm (max images)
\end{frame}
\end{document}

答案2

如果我正确理解了你想要做的事情,我认为下面的方法应该有效

\documentclass{beamer}
\usepackage{graphicx}
\setkeys{Gin}{draft}

\begin{document}

\begin{frame}{title}

  \begin{itemize}
    \item<1-> text1
    \item<2> text2
  \end{itemize}

\includegraphics<1>[height=40mm]{pic1.jpg}
\includegraphics<2>[height=40mm]{pic2.jpg}

\end{frame}

\end{document}

正如您所说,这意味着为每个提供叠加规范\item,但同一张幻灯片上不能有那么多(尤其是同一张幻灯片上的图像),对吗?

答案3

以下是一个比保罗的答案更弱的答案,但不需要 tikz,其中的数字是 foo-1.pdf、foo-2.pdf、foo-3.pdf 等等。

\documentclass[11pt]{beamer}
\usepackage{xmpmulti}
\usepackage{graphicx}
\begin{document}
\begin{frame}
  \begin{columns}[h]
    \column{3in}
    \begin{itemize}[<+->]
    \item one
    \item two
    \item three
    \end{itemize}
\column{3in}
\begin{figure}
  \centering
  \multiinclude[<+>][format=pdf,start=1]{foo}
\end{figure}
  \end{columns}
\end{frame}
\end{document}

相关内容