【发布时间】:2023-01-31 18:11:12
【问题描述】:
是否可以通过在 YAML 标头中指定来一次从 Quarto/R Markdown 文档创建多种输出格式?
我的猜测没有奏效:
---
title: Stacked Area chart with Annotations
format:
- html
- gfm
---
【问题讨论】:
标签: r-markdown quarto
是否可以通过在 YAML 标头中指定来一次从 Quarto/R Markdown 文档创建多种输出格式?
我的猜测没有奏效:
---
title: Stacked Area chart with Annotations
format:
- html
- gfm
---
【问题讨论】:
标签: r-markdown quarto
试试这种方式(假设文件名是格式_测试.qmd)
格式_测试.qmd
---
title: "Untitled"
format:
html: default
gfm: default
---
## Quarto
Quarto enables you to weave together content and executable code
into a finished document. To learn more about Quarto
see <https://quarto.org>.
## Running Code
When you click the **Render** button a document will
be generated that includes both content and the output
of embedded code. You can embed code like this:
```{r}
1 + 1
```
然后从控制台运行以下代码以同时生成 html 和 github 风格的 markdown (gfm) 文件。
# install.packages("quarto")
quarto::quarto_render("format_test.qmd", output_format = "all")
或者,如果您更喜欢使用终端(或者如果您不是 R 用户),您可以在终端中运行以下命令,
quarto render format_test.qmd --to gfm,html
小心指定多种格式,中间不要有任何空格,即将它们键入 gfm,html。
在终端中运行上述命令不需要您在文档中指定 format yaml 选项。因此对于
格式_测试.qmd
---
title: "Untitled"
---
## Quarto
Quarto enables you to weave together content and executable code
into a finished document. To learn more about Quarto
see <https://quarto.org>.
quarto render format_test.qmd --to pdf,html,gfm
会生成HTML、pdf、markdown格式的三个文件。
【讨论】:
knit: rmarkdown::render("format_test.rmd, output_format = "all")。看起来你也应该能够在 Quarto 中做到这一点,但仅仅用 quarto::quarto_render 代替 rmarkdown::render 是行不通的。 @dufei