rmarkdown icon indicating copy to clipboard operation
rmarkdown copied to clipboard

Activate graphics for Pandoc also for custom template when `md` source contains only LaTeX figures.

Open cderv opened this issue 2 years ago • 1 comments

Related to https://github.com/rstudio/bookdown/issues/1350#issuecomment-1163595061

\includegraphics in LaTeX requires the graphics package, which Pandoc only adds after a variable graphics https://github.com/jgm/pandoc/blob/e0dea96d6c1e7d6f19040cafd9ffde432de330d8/data/templates/default.latex#L258-L259

I think Pandoc activate the variable if images are detected in the document (Img in AST ?) but if the figure in the markdown file is inserting using LaTeX directly (which knitr can do), and not markdown syntax then Pandoc won't activate the variable probably.

In rmarkdown we do activate by default when the default template is used https://github.com/rstudio/rmarkdown/blob/7eb75a81c7e8ea124b224842c63c19fcaddb8802/R/pdf_document.R#L148-L149

Maybe we could detect a LaTeX figure and activate it also in a non default template so that it does not suprise user ? https://github.com/rstudio/bookdown/issues/1350#issuecomment-1163413321

Just noting the idea here. Need to see what it means to do that

cderv avatar Jun 22 '22 21:06 cderv

I'm okay with always activating it, regardless of the template.

yihui avatar Jun 23 '22 03:06 yihui