为幻灯片中各列的“动画”图像添加符合图片编号的标题

为幻灯片中各列的“动画”图像添加符合图片编号的标题

我需要在图片下添加标题,我使用的是列环境,这样我就可以把图片放在彼此的顶部并创建一个“动画”,但这样做我必须删除图形,因此我无法为图片添加标题。有没有办法保留这个“动画”并让标题遵循与其他图形相同的编号?

%% DOCUMENT CLASS %%
\documentclass[compress]{beamer}

%% PACKAGES %%
\usepackage{graphicx}
\usepackage{caption}

%% ADD FIGURE NUMBERING %%
\DeclareCaptionLabelSeparator{horse}{:\quad} 
\captionsetup{
  labelsep = horse,
  figureposition = bottom
} 
\setbeamertemplate{caption}[numbered]

%% BEGIN DOCC %% 
\begin{document}

\frame{ 
  \begin{figure}[H]
    \begin{center}
      \includegraphics[width=0.5025\textwidth]{scr/1.png}
      \caption{Some caption}
    \end{center}
  \end{figure}
}

\subsection{First subsection}
\frame{ \frametitle{Title}
  \begin{columns}
    \column{0.3\textwidth}
      \begin{enumerate}
        \item 1
        \item 2
        \item 3
        \item 4
      \end{enumerate}

    \column{0.7\textwidth}
      \centering
      \includegraphics<1>[width=0.3\textwidth]{scr/2.png}%
      %\caption{I would like a caption here}
  
      \includegraphics<2>[width=0.4\textwidth]{scr/3.png}%
      %\caption{And I would like a caption here as well}
  \end{columns}
}
\end{document}

这是上面示例代码的结果:

第一张幻灯片

第二张幻灯片(第一部分)

第二张幻灯片(第二部分)

答案1

您可以使用figure带有列和动画的环境。无需删除它们:

%% DOCUMENT CLASS %%
\documentclass[compress]{beamer}

%% PACKAGES %%
\usepackage{caption}

%% ADD FIGURE NUMBERING %%
\DeclareCaptionLabelSeparator{horse}{:\quad} 
\captionsetup{
  labelsep = horse,
  figureposition = bottom
} 
\setbeamertemplate{caption}[numbered]

%% BEGIN DOCC %% 
\begin{document}

\begin{frame} 
  \begin{figure}
      \includegraphics[width=0.5025\textwidth]{example-image-duck}
      \caption{Some caption}
  \end{figure}
\end{frame}

\subsection{First subsection}
\begin{frame}
  \frametitle{Title}
  \begin{columns}
    \begin{column}{0.3\textwidth}
      \begin{enumerate}
        \item 1
        \item 2
        \item 3
        \item 4
      \end{enumerate}
    \end{column}
    \begin{column}{0.7\textwidth}
      \begin{figure}
      \includegraphics<1>[width=0.3\textwidth]{example-image-duck}%
      \only<1>{\caption{I would like a caption here}}
      \includegraphics<2>[width=0.4\textwidth]{example-image-duck}%
      \only<2>{\caption{And I would like a caption here as well}}
      \end{figure}
    \end{column}
  \end{columns}
\end{frame}

\end{document}

但是如果您更喜欢没有figure环境的解决方案,则可以使用\captionof{figure}{...}标题包为不在环境中的图像添加标题figure

%% DOCUMENT CLASS %%
\documentclass[compress]{beamer}

%% PACKAGES %%
\usepackage{caption}

%% ADD FIGURE NUMBERING %%
\DeclareCaptionLabelSeparator{horse}{:\quad} 
\captionsetup{
  labelsep = horse,
  figureposition = bottom
} 
\setbeamertemplate{caption}[numbered]

%% BEGIN DOCC %% 
\begin{document}

\begin{frame} 
  \begin{figure}
      \includegraphics[width=0.5025\textwidth]{example-image-duck}
      \caption{Some caption}
  \end{figure}
\end{frame}

\subsection{First subsection}
\begin{frame}
  \frametitle{Title}
  \begin{columns}
    \begin{column}{0.3\textwidth}
      \begin{enumerate}
        \item 1
        \item 2
        \item 3
        \item 4
      \end{enumerate}
    \end{column}
    \begin{column}{0.7\textwidth}
      \centering
      \includegraphics<1>[width=0.3\textwidth]{example-image-duck}%
      \only<1>{\captionof{figure}{I would like a caption here}}
      \includegraphics<2>[width=0.4\textwidth]{example-image-duck}%
      \only<2>{\captionof{figure}{And I would like a caption here as well}}
    \end{column}
  \end{columns}
\end{frame}

\end{document}

相关内容