# 如何用animateinline实现动画效果

## 编译环境 操作系统 * [x ] Windows 7/8/10 * [ ] macOS * [ ] Linux 若需勾选，请把[ ]改成[x] Tex发行版 * [ ] TexLive 2020 * [ ] MikTeX 版本号 * [ ] CTeX 若需勾选，请把[ ]改成[x] ## 我的问题 如何使用animateinline实现动画效果

## 1 回答

texdoc animate, sec 6.1 Basic options > A short note on the ‘tikzpicture’ environment: Unlike ‘pspicture’, the ‘tikzpic- > ture’ environment is able to determine its size from the graphical objects it encloses. > However, this may result in differently sized frames of a sequence, depending on the > size and position of the graphical objects. Thus, in order to ensure that all frames > of the sequence be displayed at the same scale in the animation widget, a common > bounding box should be shared by the frames. A bounding box can be provided by > means of an invisible ‘rectangle’ object: tex \documentclass{article} \usepackage{graphicx} \usepackage{animate} \usepackage{tikz} \usetikzlibrary{positioning} \begin{document} \begin{animateinline}[loop,autopause,begin={ \begin{tikzpicture} \useasboundingbox (0,0) rectangle (10,10); }, end={\end{tikzpicture}}]{1} \newframe \draw[red] (0,0)--(1,1); \newframe \draw[blue] (0,0)--(-1,1); \end{animateinline} \end{document}