我使用knitr和rmarkdown为R包编写晕影.由于pandoc的神奇之处,很容易将这些文档转换为各种格式.我想通过提供HTML和PDF的插图来利用这一点.rmarkdown支持在文档元数据块中指定多种输出格式的参数.例如,我可能会有这样的事情:
output:
html_document:
standalone: true
smart: true
normalize: true
toc: true
highlight: tango
self-contained: true
theme: cerulean
pdf_document:
toc: true
highlight: tango
geometry: margin=2cm
documentclass: article
classoption: a4paper
Run Code Online (Sandbox Code Playgroud)
从R命令行我可以rmarkdown::render用来构建一个或两个输出文档没有困难.但是,在构建包时,仅使用首先列出的输出格式.我试图包含一个Makefile,它通过包含一些东西来构建
all: %.Rmd
$(R_HOME)/bin/Rscript -e "rmarkdown::render('$*.Rmd', 'all')"
Run Code Online (Sandbox Code Playgroud)
并且这是成功的,因为生成了所有输出文件但是其中只有一个被R识别为晕影.要获得包含的其他输出,docs/必须将它们添加到.install_extras.虽然这确保它们可以通过HTML索引访问,但它们与小插图分开列出,我认为不能从R(via vignette())中访问它们.
有没有更好的方法(或任何自动方式)来做到这一点?