使用animateinline制作动画出现CJK报错 非法字符:Package CJK Error: Invalid character code
\documentclass{beamer}
\usepackage{ctex}
\usepackage{tikz}
\usetheme{CambridgeUS}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{animate}
\begin{document}
\begin{frame}
\frametitle{问题探究}
如图,在单位圆上,将点$A$绕着点$O$旋转$x_0$弧度至点$B$,根据正弦函数的定义,点$B$的纵坐标$y_0=\sin x_0$.
由此,以$x_0$为横坐标,$y_0$为纵坐标画点,即得到函数图象上的点$T\left(x_0,\sin x_0\right)$.
\begin{animateinline}[autoplay,loop,begin={\begin{tikzpicture}
\draw[->] (-2.1,0) -- (7,0) node[below,font=\tiny]{$x$};
\node[below,sep=2pt,fill=white,font=\tiny] at (0,0) {$O$};
\draw[->] (0,-2.1) -- (0,2) node[right,font=\tiny]{$y$};
\node[below,outer sep=2pt,fill=white,font=\tiny] at (6.28,0) {$2\pi$};
\node[below,outer sep=2pt,fill=white,font=\tiny] at (1.570,0) {$\frac{\pi}{2}$};
\node[below,outer sep=2pt,fill=white,font=\tiny] at (3.141,0) {$\pi$};
\node[below,outer sep=2pt,fill=white,font=\tiny] at (4.712,0) {$\frac{3\pi}{2}$};
\node[left,outer sep=2pt,fill=white,font=\tiny] at (0,1) {$1$};
\node[left,outer sep=2pt,fill=white,font=\tiny] at (0,-1) {$-1$};
\node[below,outer sep=2pt,fill=white,font=\tiny] at (1,0) {$A$};
\filldraw (1,0) circle (1pt);
},end={\end{tikzpicture}}][5]
\multiframe{25}{rp=0+10}
{
\draw[fill=yellow,domain=0:\rp] (0,0) -- (1,0) arc (0:\ip:1)node[font=\tiny,right]{$A$} -- cycle;
}
\end{animateinline}
\end{frame}
\end{document}
直接编译,报错为
! Missing number, treated as zero.
<to be read again>
[
l.243 \end{frame}
?
结合阅读 texdoc animate
可知,你写错了代码,将
},end={\end{tikzpicture}}][5]
改为
},end={\end{tikzpicture}}]{5}
再次编译,报错为
! Package pgfkeys Error: I do not know the key '/tikz/sep', to which you passed
'2pt', and I am going to ignore it. Perhaps you misspelled it.
See the pgfkeys package documentation for explanation.
Type H <return> for immediate help.
...
l.243 \end{frame}
?
查看代码,错误的代码在
\node[below,sep=2pt,fill=white,font=\tiny] at (0,0) {$O$};
这一行,结合上下文,你应该是想写 outer sep=2pt
。
再次编译,报错
! Undefined control sequence.
<argument> 0:\ip
:1
l.243 \end{frame}
?
此报错为变量不统一导致,将 \ip
改为 \rp
即可。
修改后编译无误。
学会 debug 以及通读手册 ok?
给代码的时候不要群里和论坛两个版本,也不要自己瞎改,读完手册再写代码。
感谢大佬