Specifying multiple simultaneous output formats in knitr (new)

試著忘記壹切 提交于 2019-12-10 01:02:55

问题


Can I write a YAML header to produce multiple output formats for an R Markdown file using knitr? I could not reproduce the functionality described in the answer for the original question with this title.

This markdown file:

---
title: "Multiple output formats"
output: 
    pdf_document: default
    html_document:
      keep_md: yes
---

# This document should be rendered as an html file and as a pdf file

produces a pdf file but no HTML file.

And this file:

---
title: "Multiple output formats"
output: 
  html_document:
    keep_md: yes
  pdf_document: default
---

# This document should be rendered as an html file and as a pdf file

produces an HTML file (and an md file) but no pdf file.

This latter example was the solution given to the original question. I have tried knitting with Shift-Ctrl-K and with the Knit button in RStudio, as well as calling rmarkdown::render, but only a single output format is created, regardless of the method I use to generate the output file.

Possibly related, but I could not identify solutions:

  • How do I produce R package vignettes in multiple formats?
  • Render all vignette formats #1051
  • knitr::pandoc can't create pdf and tex files with a single config #769
  • Multiple formats for pandoc #547
  • An allusion to multiple output format support in a three year old RStudio blog post

Using R version 3.3.1 (2016-06-21), knitr 1.14, Rmarkdown 1.3


回答1:


I actually briefly mentioned in Render all vignette formats #1051 and you missed it:

rmarkdown::render('your.Rmd', output_format = 'all')

It is documented on the help page ?rmarkdown::render.



来源:https://stackoverflow.com/questions/44685485/specifying-multiple-simultaneous-output-formats-in-knitr-new

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!