From 978acd84b3bfae731eac9367ce3e546026a2f76d Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Mon, 8 Oct 2018 15:24:55 -0500 Subject: [PATCH] when fig.show='animate' and the output format is LaTeX, use the plot hook for LaTeX (i.e. generate \animategraphics{}) https://github.com/thomasp85/gganimate/issues/134#issuecomment-420605864 --- DESCRIPTION | 2 +- R/hooks-md.R | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9885fa5dc2..e337ebf80b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: knitr Type: Package Title: A General-Purpose Package for Dynamic Report Generation in R -Version: 1.20.15 +Version: 1.20.16 Authors@R: c( person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")), person("Adam", "Vogt", role = "ctb"), diff --git a/R/hooks-md.R b/R/hooks-md.R index 93ded8b2a5..03fe834e29 100644 --- a/R/hooks-md.R +++ b/R/hooks-md.R @@ -4,11 +4,13 @@ hook_plot_md = function(x, options) { # if not using R Markdown v2 or output is HTML, just return v1 output if (is.null(to <- pandoc_to()) || is_html_output(to)) return(hook_plot_md_base(x, options)) + if (options$fig.show == 'animate' && is_latex_output()) + return(hook_plot_tex(x, options)) office_output = to %in% c('docx', 'pptx', 'rtf', 'odt') if (!is.null(options$out.width) || !is.null(options$out.height) || !is.null(options$out.extra) || options$fig.align != 'default' || !is.null(options$fig.subcap)) { - if (to %in% c('beamer', 'latex')) { + if (is_latex_output()) { # Pandoc < 1.13 does not support \caption[]{} so suppress short caption if (is.null(options$fig.scap)) options$fig.scap = NA return(hook_plot_tex(x, options))