我希望动画从第四帧开始出现,而不是从第一帧开始。如何实现?
\documentclass[12pt,aspectratio=1610]{beamer}
\usepackage{adjustbox}
\usepackage{animate}
\begin{document}
\section{Section 1}
\begin{frame}[t]{Frame Title}
\begin{columns}[t]
\begin{column}{0.5\textwidth}
\pause
\adjincludegraphics[width=\linewidth,valign=t,center]{example-image-a}
\pause
\[
Kim=Jong+Un
\]
\end{column}
\begin{column}{0.5\textwidth}
\pause
\begin{adjustbox}{width=\linewidth,valign=t,center}
\animategraphics[controls,loop]{1}{example-image-duck}{}{}
\end{adjustbox}
\pause
\begin{itemize}
\item Kim Jong Un\pause
\item Peace Be Upon Him\pause
\end{itemize}
\begin{center}
The end of the world!
\end{center}
\end{column}
\end{columns}
\end{frame}
\end{document}
附加问题:
如何防止幻灯片向前导航时动画重新启动?下一张幻灯片必须显示动画的当前帧,而不是动画的第一帧。
答案1
从本质上来说,它是旧帖针对问题中给出的具体示例进行了调整。解决方案基于 的animate
JS API 以及beamer
类的内部\ifbeamer@anotherslide
。
所有请求的功能都已解决。此外,当前播放状态(暂停或播放、前进或后退)和动画的当前帧速率在叠加层之间传递。已成功测试与 Acrobat Reader 和 Okular 配合使用。
按照以下方式使用,并注意动画的标记方式,<label>_\thepage
以及标签如何与括号命令一起使用,\putBeforeAnim{<label>}
/ \putAfterAnim{<label>}
。另外,请注意 的draft
备选子句中的选项\doifvisible
。
\doifvisible{%
\putBeforeAnim{duck}%
\animategraphics[label=duck_\thepage,controls,loop]{1}{example-image-duck}{}{}%
\putAfterAnim{duck}%
}{
\phantom{\animategraphics[draft,controls,loop]{1}{example-image-duck}{}{}}%
}
完整示例。只需忽略undefined references
警告即可。(警告是无害的,只是因为放在\animategraphics
框中\phantom
。将在下一版本中修复。)
\documentclass[12pt,aspectratio=1610]{beamer}
\usepackage{adjustbox}
\usepackage{animate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \putBeforeAnim{<label>}
% \animategraphics[label=<label>_\thepage,...]{..}{..}{..}{..}
% or
% \begin{animateinline}[label=<label>_\thepage,...]{..}
% ...
% \end{animateinline}
% \putAfterAnim{<label>}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\putBeforeAnim[1]{%
\myPdfAnnot{1ex}{1ex}{0pt}{%
/Subtype/Widget/FT/Btn/Ff 65537/T (#1_a_\thepage)%
/AA <<%
/PC << % exec on page-close
/S/JavaScript /JS (
try{
var #1CurFrame =anim['#1_\thepage'].frameNum;
var #1CurSpeed =anim['#1_\thepage'].speed;
var #1PlayingFwd=anim['#1_\thepage'].isPlaying&& anim['#1_\thepage'].playsFwd;
var #1PlayingBwd=anim['#1_\thepage'].isPlaying&&(!anim['#1_\thepage'].playsFwd);
} catch(e){}
)
>>
>>%
}%
}
\newcommand\putAfterAnim[1]{%
\myPdfAnnot{1ex}{1ex}{0pt}{%
/Subtype/Widget/FT/Btn/Ff 65537/T (#1_b_\thepage)%
/AA <<%
/PO << % exec on page-open
/S/JavaScript /JS (
try{
anim['#1_\thepage'].frameNum=#1CurFrame;
anim['#1_\thepage'].speed=#1CurSpeed;
if(#1PlayingFwd){anim['#1_\thepage'].playFwd();}
if(#1PlayingBwd){anim['#1_\thepage'].playBwd();}
} catch(e){}
)
>>
>>
}%
}
\ExplSyntaxOn
\let\myPdfAnnot\pbs_pdfannot:nnnn
\ExplSyntaxOff
\makeatletter
\newcommand\doifvisible[2]{\ifbeamer@anotherslide #2\else #1\fi}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section{Section 1}
\begin{frame}[t]{Frame Title}
\begin{columns}[t]
\begin{column}{0.5\textwidth}
\pause
\adjincludegraphics[width=\linewidth,valign=t,center]{example-image-a}
\pause
\[
Kim=Jong+Un
\]
\end{column}
\begin{column}{0.5\textwidth}
\pause
\begin{adjustbox}{width=\linewidth,valign=t,center}
\doifvisible{%
\putBeforeAnim{duck}%
\animategraphics[label=duck_\thepage,controls,loop]{1}{example-image-duck}{}{}%
\putAfterAnim{duck}%
}{%
\phantom{\animategraphics[draft,controls,loop]{1}{example-image-duck}{}{}}%
}
\end{adjustbox}
\pause
\begin{itemize}
\item Kim Jong Un\pause
\item Peace Be Upon Him\pause
\end{itemize}
\begin{center}
The end of the world!
\end{center}
\end{column}
\end{columns}
\end{frame}
\end{document}