Description Usage Arguments Details Value Note Author(s) References See Also
Record animation frames and insert them into a LaTeX document with the
animate
package. Compile the document if an appropriate LaTeX command
is provided.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
expr |
an expression to generate animations; use either the animation
functions (e.g. |
nmax |
maximum number of animation frames (if missing and the graphics
device is a bitmap device, this number will be automatically calculated);
note that we do not have to specify |
img.name |
basename of file names of animation frames; see the Note
section for a possible adjustment on |
ani.opts |
options to control the behavior of the animation (passed to
the LaTeX macro |
centering |
logical: whether to center the graph using the LaTeX
environment |
caption, label |
caption and label for the graphics in the figure environment |
pkg.opts |
global options for the |
documentclass |
LaTeX document class; if |
latex.filename |
file name of the LaTeX document; if an empty string
|
pdflatex |
the command for pdfLaTeX (set to |
install.animate |
copy the LaTeX style files ‘animate.sty’ and
‘animfp.sty’? If you have not installed the LaTeX package
|
overwrite |
whether to overwrite the existing image frames |
full.path |
whether to use the full path ( |
... |
other arguments passed to the graphics device
|
This is actually a wrapper to generate a LaTeX document using R. The document
uses the LaTeX package called animate
to insert animations into PDF's.
When we pass an R expression to this function, the expression will be
evaluated and recorded by a grahpics device (typically png
and
pdf
). At last, a LaTeX document will be created and compiled if
an appropriate LaTeX command is provided. And the final PDF output will be
opened with the PDF viewer set in getOption('pdfviewer')
if
ani.options('autobrowse') == TRUE
.
Invisible NULL
This function will detect if it was called in a Sweave environment –
if so, img.name
will be automatically adjusted to
prefix.string-label
, and the LaTeX output will not be a complete
document, but rather a single line like
1 | \animategraphics[ani.opts]{1/interval}{img.name}{}{}
|
This automatic feature can be useful to Sweave users (but remember to set
the Sweave option results=tex
). See demo('Sweave_animation')
for a complete example.
PDF devices are recommended because of their high quality and usually they
are more friendly to LaTeX, but the size of PDF files is often much larger;
in this case, we may set the option 'qpdf'
or 'pdftk'
to
compress the PDF graphics output. To set the PDF device, use
ani.options(ani.dev = 'pdf', ani.type = 'pdf')
So far animations created by the LaTeX package animate can only be
viewed with Acrobat Reader (Windows) or acroread
(Linux). Other
PDF viewers may not support JavaScript (in fact the PDF animation is driven
by JavaScript). Linux users may need to install acroread
and set
options(pdfviewer = 'acroread')
.
Yihui Xie
Examples at https://yihui.org/animation/example/savelatex/
To know more about the animate
package, please refer to
http://www.ctan.org/tex-archive/macros/latex/contrib/animate/. There
are a lot of options can be set in ani.opts
and pkg.opts
.
Other utilities:
im.convert()
,
saveGIF()
,
saveHTML()
,
saveSWF()
,
saveVideo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.