Skip to content

Instantly share code, notes, and snippets.

@kohske
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kohske/9044996 to your computer and use it in GitHub Desktop.
Save kohske/9044996 to your computer and use it in GitHub Desktop.
knitr+animation+latex
\documentclass{ltjsarticle}
\usepackage{luatexja}
\let\ifdraft\relax % おまじない
\usepackage{animate}
\title{PDFレポートでアニメーション}
\author{@kohske}
\begin{document}
\maketitle
\begin{figure}[h]
\centering
<<newton, include=FALSE, tidy=TRUE, echo=FALSE>>=
library(animation)
ani.options(outdir = getwd())
saveLatex(
{
ani.options(interval = 0.5)
par(mar = c(3, 3, 1, 1.5), mgp = c(1.5, 0.5, 0), pch = 19)
newton.method(function(x) 5 * x^3 - 7 * x^2 - 40 * x + 100,
7.15, c(-6.2, 7.1), main = "")
}, ani.dev = 'pdf', ani.type = 'pdf', img.name = "figure/animate-newton",
ani.height = 4, ani.width = 7, ani.opts='controls,width=.8\\linewidth',
install.animate=FALSE, pdflatex = "lualatex")
@
\animategraphics[controls,width=.8\linewidth]{1}{figure/animate-newton}{}{}
\caption{saveLatexによるアニメーション}
\end{figure}
\end{document}
\documentclass{ltjsarticle}
\usepackage{luatexja}
\pagestyle{empty}
\let\ifdraft\relax % おまじない
\usepackage{animate}
\title{PDFレポートでアニメーション}
\author{@kohske}
\begin{document}
\maketitle
\begin{figure}[h]
\centering
<<clock, fig.show="animate", out.width='.5\\linewidth', echo=FALSE>>=
par(mar = rep(3, 4))
newton.method(function(x) 5 * x^3 - 7 * x^2 - 40 * x + 100,
7.15, c(-6.2, 7.1), main = "")
@
\caption{saveLatexによるアニメーション}
\end{figure}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment