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.
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-L259I 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