【问题标题】:How do I knit to two formats simulateously with Quarto?如何使用 Quarto 同时编织成两种格式?
【发布时间】:2023-01-31 18:11:12
【问题描述】:

是否可以通过在 YAML 标头中指定来一次从 Quarto/R Markdown 文档创建多种输出格式?

我的猜测没有奏效:

---
title: Stacked Area chart with Annotations
format: 
  - html
  - gfm
---

【问题讨论】:

    标签: r-markdown quarto


    【解决方案1】:

    试试这种方式(假设文件名是格式_测试.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格式的三个文件。

    【讨论】:

    • 在 R Markdown you can publish to multiple formats 中,在 yaml 标头中包含与此类似的代码,例如knit: rmarkdown::render("format_test.rmd, output_format = "all")。看起来你也应该能够在 Quarto 中做到这一点,但仅仅用 quarto::quarto_render 代替 rmarkdown::render 是行不通的。 @dufei
    • Quarto 没有这样的针织钩 @EmmanuelTeitelbaum
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-09
    • 2020-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-30
    相关资源
    最近更新 更多