sinandrei
sinandrei

Reputation: 189

Can knitr save figures with file names corresponding figure counter?

I'm using bookdown/papaja and knitr in generating a pdf file with figures. By default it seams the knitr names the figures according to their code chunk label (e.g.: fig_cars-plot), but is there a way to have it name them/save them according to their figure counter/numbered caption (e.g.: fig_1)?

knitr::opts_chunk$set(echo = TRUE, fig.align = "center",fig.pos = "H",out.extra = "", fig.path = "figures/XYZ_Fig-")

See Figure @ref(fig:cars-plot).

par(mar = c(4, 4, .2, .1))
plot(cars)  # a scatterplot

Upvotes: 1

Views: 23

Answers (0)

Related Questions