为什么 animategraphics 不再起作用?

为什么 animategraphics 不再起作用?

几十年前,我可以编译以下代码片段来pdflatex -shell-escape main.tex生成带有动画的 PDF 输出。

% the filename is main.tex
\documentclass[preview,border=12pt]{standalone}
\usepackage{filecontents}

\begin{filecontents*}{diagram.tex}

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\foreach \x in {1,...,10}{
\begin{pspicture}[showgrid](5,5)
    \pscircle(2.5,2.5){!\x\space 10 div}
\end{pspicture}}
\end{document}

\end{filecontents*}


\usepackage{pgffor}
\foreach \compiler/\ext in {latex/tex,dvips/dvi,{ps2pdf -dAutoRotatePages=/None}/ps}{\immediate\write18{\compiler\space diagram.\ext}}

\usepackage{animate}
\begin{document}
\animategraphics[autoplay,controls,loop,scale=1]{3}{diagram}{}{}
\end{document}

不幸的是,现在它只是一个 PDF 输出,动画不起作用。是什么导致了这个问题?

编辑

我似乎并不依赖于我是否使用 PSTricks 或 TikZ。

% filenanem is main.tex
% compile it with pdflatex -shell-escape main.tex

\documentclass[preview,border=12pt]{standalone}
\usepackage{filecontents}

\begin{filecontents*}{diagram.tex}

\documentclass[tikz,border=12pt]{standalone}
\begin{document}
\foreach \x in {1,...,10}{%
\begin{tikzpicture}
    \draw[white] (0,0) rectangle (5,5);
    \draw (2.5,2.5) circle (\x/10);
\end{tikzpicture}}
\end{document}

\end{filecontents*}


\immediate\write18{pdflatex diagram.tex}

\usepackage{animate}
\begin{document}
\animategraphics[autoplay,controls,loop,scale=1]{3}{diagram}{}{}
\end{document}

编辑2

我的观众是

在此处输入图片描述

编辑3

当使用article文档类代替standalone但它不能很好地工作。

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/W32TeX)
 \write18 enabled.
entering extended mode
(./main.tex
LaTeX2e <2011/06/27>
Babel <3.9k> and hyphenation patterns for 78 languages loaded.
(c:/texlive/2013/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(c:/texlive/2013/texmf-dist/tex/latex/base/size10.clo))
(c:/texlive/2013/texmf-dist/tex/latex/filecontents/filecontents.sty)This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/W32TeX)
 restricted \write18 enabled.
entering extended mode
(./diagram.tex
LaTeX2e <2011/06/27>
Babel <3.9k> and hyphenation patterns for 78 languages loaded.
(c:/texlive/2013/texmf-dist/tex/latex/standalone/standalone.cls
Document Class: standalone 2012/09/15 v1.1b Class to compile TeX sub-files stan
dalone
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(c:/texlive/2013/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(c:/texlive/2013/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(c:/texlive/2013/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(c:/texlive/2013/texmf-dist/tex/generic/xkeyval/keyval.tex)))
(c:/texlive/2013/texmf-dist/tex/latex/standalone/standalone.cfg)
(c:/texlive/2013/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(c:/texlive/2013/texmf-dist/tex/latex/base/size10.clo))
(c:/texlive/2013/texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty
(c:/texlive/2013/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty
(c:/texlive/2013/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty
(c:/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex
(c:/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-lists.tex)
) (c:/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def
(c:/texlive/2013/texmf-dist/tex/latex/ms/everyshi.sty))
(c:/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex))
(c:/texlive/2013/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty
(c:/texlive/2013/texmf-dist/tex/latex/graphics/graphicx.sty
(c:/texlive/2013/texmf-dist/tex/latex/graphics/graphics.sty
(c:/texlive/2013/texmf-dist/tex/latex/graphics/trig.sty)
(c:/texlive/2013/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(c:/texlive/2013/texmf-dist/tex/latex/pdftex-def/pdftex.def
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))))
(c:/texlive/2013/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty
(c:/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex
(c:/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(c:/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.tex)
) (c:/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-pdftex.def
(c:/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-pdf.def))
)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath.code.tex
)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol.code.tex
)) (c:/texlive/2013/texmf-dist/tex/latex/xcolor/xcolor.sty
(c:/texlive/2013/texmf-dist/tex/latex/latexconfig/color.cfg))
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.tex
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic.code.te
x)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonometric
.code.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.random.code.t
ex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.comparison.co
de.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.code.tex
)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.te
x)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.tex
)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integerarithm
etics.code.tex)))
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex))
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.code.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconstruct.cod
e.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage.code.te
x)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.code.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicstate.code
.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransformations.c
ode.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.code.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.code.tex)

(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathprocessing.co
de.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.code.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.code.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreimage.code.tex
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreexternal.code.tex
))
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcorelayers.code.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransparency.code
.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepatterns.code.tex
)))
(c:/texlive/2013/texmf-dist/tex/generic/pgf/modules/pgfmoduleshapes.code.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/modules/pgfmoduleplot.code.tex)
(c:/texlive/2013/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version-0-65.st
y)
(c:/texlive/2013/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version-1-18.st
y)) (c:/texlive/2013/texmf-dist/tex/latex/pgf/utilities/pgffor.sty
(c:/texlive/2013/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(c:/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex))
(c:/texlive/2013/texmf-dist/tex/latex/pgf/math/pgfmath.sty
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex))
(c:/texlive/2013/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex
(c:/texlive/2013/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex)))
(c:/texlive/2013/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
(c:/texlive/2013/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothandlers.co
de.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/modules/pgfmodulematrix.code.tex)
(c:/texlive/2013/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzli
brarytopaths.code.tex))))
No file diagram.aux.
ABD: EveryShipout initializing macros
(c:/texlive/2013/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (c:/texlive/2013/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty)
(c:/texlive/2013/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(c:/texlive/2013/texmf-dist/tex/latex/oberdiek/grfext.sty
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(c:/texlive/2013/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/etexcmds.sty)))
(c:/texlive/2013/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)) [1]
[2] [3] [4] [5] [6] [7] [8] [9] [10] (./diagram.aux) )
Output written on diagram.pdf (10 pages, 3756 bytes).
Transcript written on diagram.log.


LaTeX Warning: Writing file `./diagram.tex'.


(c:/texlive/2013/texmf-dist/tex/latex/animate/animate.sty
(c:/texlive/2013/texmf-dist/tex/latex/graphics/keyval.sty)
(c:/texlive/2013/texmf-dist/tex/latex/base/ifthen.sty)
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(c:/texlive/2013/texmf-dist/tex/latex/oberdiek/ifdraft.sty)
(c:/texlive/2013/texmf-dist/tex/latex/tools/calc.sty)
(c:/texlive/2013/texmf-dist/tex/latex/oberdiek/atenddvi.sty
(c:/texlive/2013/texmf-dist/tex/latex/oberdiek/zref-abspage.sty
(c:/texlive/2013/texmf-dist/tex/latex/oberdiek/zref-base.sty
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/etexcmds.sty))
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty)
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty)
(c:/texlive/2013/texmf-dist/tex/latex/oberdiek/auxhook.sty))
(c:/texlive/2013/texmf-dist/tex/generic/oberdiek/atbegshi.sty))
(c:/texlive/2013/texmf-dist/tex/latex/oberdiek/zref-lastpage.sty
(c:/texlive/2013/texmf-dist/tex/latex/oberdiek/atveryend.sty)))
(c:/texlive/2013/texmf-dist/tex/latex/animate/animfp.sty)
(c:/texlive/2013/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
))
No file main.aux.
 <./diagram.pdf> <1> <./diagram.pdf> <2> <./diagram.pdf> <3> <./diagram.pdf>
<4> <./diagram.pdf> <5> <./diagram.pdf> <6> <./diagram.pdf> <7> <./diagram.pdf>
<8> <./diagram.pdf> <9> <./diagram.pdf> <10>

LaTeX Warning: Reference `LastPage' on page 1 undefined on input line 27.

[1{c:/texlive/2013/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./main.aux

Package atenddvi Warning: Rerun LaTeX, last page not yet found.

)

LaTeX Warning: There were undefined references.


LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

 )<c:/texlive/2013/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on main.pdf (1 page, 22297 bytes).
Transcript written on main.log.

答案1

从类选项中删除preview。这是不必要的,而且会导致编译时出现问题。如果不删除,生成的带有动画的 PDF 是可以的。

顺便说一句,旧版本默认standalone设置preview选项。最新版本crop改为设置选项。

我的测试文件(pdflatex --shell-escape):

%\documentclass[border=12pt]{standalone} % <-- works as well
\documentclass{article}
\usepackage{filecontents}

\begin{filecontents*}{diagram.tex}

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\foreach \x in {1,...,10}{
\begin{pspicture}[showgrid](5,5)
    \pscircle(2.5,2.5){!\x\space 10 div}
\end{pspicture}}
\end{document}

\end{filecontents*}


\usepackage{pgffor}
\foreach \compiler/\ext in {latex/tex,dvips/dvi,{ps2pdf -dAutoRotatePages=/None}/ps}{\immediate\write18{\compiler\space diagram.\ext}}

\usepackage{animate}
\begin{document}
\animategraphics[autoplay,controls,loop,scale=1]{3}{diagram}{}{}
\end{document}

相关内容