我刚开始尝试在 Beamer 中制作 tikz 图片动画。作为测试,我想让球向右移动。这是代码。任何建议都将不胜感激。
\documentclass{beamer}
\usepackage{tikz}
\usepackage{animate}
\begin{document}
\begin{frame}
\begin{animateinline}[loop]{10}
\multiframe{10}{rPos=0.1+0.5}{
\begin{tikzpicture}
[electron/.style={draw,fill,circle,shading=ball,text=white}]
\node[electron] (e) at (\rPos,1) {$e^{-}$};
\end{tikzpicture}
}
\end{animateinline}
\end{frame}
\end{document}
答案1
您需要为所有动画帧设置一个公共边界框,该边界框包含电子的所有位置。否则动画的视口会随电子移动。
\documentclass{beamer}
\usepackage{tikz}
\usepackage{animate}
\begin{document}
\begin{frame}
\begin{animateinline}[loop]{10}
\multiframe{10}{rPos=0.1+0.5}{
\begin{tikzpicture}
[electron/.style={draw,fill,circle,shading=ball,text=white}]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\useasboundingbox (-0.4,0.5) rectangle (5.1,1.5);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node[electron] (e) at (\rPos,1) {$e^{-}$};
\end{tikzpicture}
}
\end{animateinline}
\end{frame}
\end{document}