The chunk form of stageFigure(): stages path and hands the result to
knitr::include_graphics(), so a module chapter includes the same figure
whether it renders on its own or staged into a manual.
Arguments
- path
figure path(s) relative to the module directory, i.e. what the module uses when it renders on its own – for example
"figures/schematic.png". A vector is staged element by element.- ...
further arguments to
knitr::include_graphics(), e.g.dpi.
Value
what knitr::include_graphics() returns.
Details
knitr::include_graphics(stageFigure(path)) does not work from a staged
chapter. include_graphics() checks that the file exists relative to the
working directory, which for a staged chapter is the module's (knitr's
root.dir), while the path stageFigure() returns is relative to the book
root, where the rendered document resolves it. So this turns that check off
– stageFigure() has already made the same check, against the right
directory – and passes everything else through.
Use stageFigure() directly only to write the markdown yourself, e.g. for a
linked badge, cat(paste0("[, ")](", url, ")")).