![更新:用动画代替覆盖](https://linux22.com/image/281419/%E6%9B%B4%E6%96%B0%EF%BC%9A%E7%94%A8%E5%8A%A8%E7%94%BB%E4%BB%A3%E6%9B%BF%E8%A6%86%E7%9B%96.png)
我希望能够在投影仪中绘制动画线
在同一帧内添加动画
感谢@Kevin C 提供这些图片
\documentclass[leqno,mathserif]{beamer}
\usepackage[english,french]{babel}
\usepackage{dsfont}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{animate}
\setbeamercovered{transparent}
\usepackage{pifont}
\usepackage{xcolor}
\usepackage{enumitem}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\begin{axis}[axis y line=none, y=0.5cm/3, restrict y to domain=0:20, axis lines=left]
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}
答案1
更新:用动画代替覆盖
要使用该包为所有三个帧制作动画animate
,可以将animateinline
环境与文本文件(stack.txt
在下面的示例中)一起使用,为环境指定“时间线”。
代码
\documentclass{beamer}
\usepackage{tikz,animate}
\usetikzlibrary{decorations.pathreplacing}
\begin{filecontents}{stack.txt}
::0x0
::1x0
::2x0
::3x0
\end{filecontents}
\newcommand\tick[2][]{\draw(#2,3pt)--(#2,-3pt)node[below]{#1};}
\newcommand\tikzmark[1]{\tikz[remember picture,baseline=(#1.base)]\node[inner sep=0](#1){$#1$};}
\begin{document}
\begin{frame}
\centering
\begin{animateinline}[autoplay,loop,poster=last,
begin={\begin{tikzpicture}[remember picture]\useasboundingbox(0,-1)rectangle(8,1.7);},
end={\end{tikzpicture}},
timeline={stack.txt}
]{1}
\newframe
\draw[line width=2pt,-latex](0,0)--(8,0);
\tick[$0$]{.5}
\tick[\tikzmark{T}]{6}
\newframe
\tick[$Dt$]{1.3}
\tick[$2Dt$]{2.1}
\node[anchor=west] at (T.east) {$=Dt\cdot L$};
\foreach \x in {2.9,3.7,4.5,5.3} {\tick{\x}}
\newframe
\draw[decorate,decoration={brace,amplitude=4pt}](.5,4pt)--(1.3,4pt)node[midway,above,align=center]{$Dt$\\step size};
\draw[decorate,decoration={brace,amplitude=4pt}](.5,1.1)--(6,1.1)node[midway,above]{$L$ steps};
\end{animateinline}
\end{frame}
\end{document}
Beamer 叠加
TikZ 支持叠加。只需<overlay spec>
照常使用语法即可。
代码
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\newcommand<>\tick[2][]{\draw#3(#2,3pt)--(#2,-3pt)node[below]{#1};}
\begin{document}
\begin{frame}
\centering
\begin{tikzpicture}[font=\footnotesize]
\draw[line width=2pt,-latex](0,0)--(7,0);
\tick[$0$]{.5}
\tick[\alt<2->{\hskip35pt$T=Dt\cdot L$}{$T$}]{6}
\tick<2->[$Dt$]{1.3}
\tick<2->[$2Dt$]{2.1}
\foreach \x in {2.9,3.7,4.5,5.3} {\tick<2->{\x}}
\draw<3->[decorate,decoration={brace,amplitude=4pt}](.5,4pt)--(1.3,4pt)node[midway,above,align=center]{$Dt$\\step size};
\draw<3->[decorate,decoration={brace,amplitude=4pt}](.5,1.1)--(6,1.1)node[midway,above]{$L$ steps};
\end{tikzpicture}\par
\end{frame}
\end{document}