{% include figure image_path="file.svg" alt="Lorem ipsum" caption="Dolor sic" %}
因此,我想更改plot的默认输出,以便自动使用该语法。
我设置了这个钩子:
knitr::knit_hooks$set(figure = function(before, options, envir) {
if (!before) {
## after a chunk has been evaluated
name <- paste(options$fig.path, options$label, sep = '')
message(name)
return(sprintf("{%% include figure image_path=\"%s\" alt=\"%s\" caption=\"%s\" %%}", name, options$fig.alt, options$fig.cap))
}
})
但这是我在.md文件中得到的输出:
{% include figure image_path="assets/figures/cars" alt="Test" caption="A scatterplot of the cars data" %}
这里有两个问题: