【问题标题】:Is there a way to inform the configuration file in bookdown YAML in another directory in rmarkdown?有没有办法在 rmarkdown 的另一个目录中通知 bookdown YAML 中的配置文件?
【发布时间】:2021-02-10 02:33:26
【问题描述】:

R Markdown 中,我们可以将csscslbibliograph 作为外部文件通知。

如果我想使用configuration file,我需要将其保存在与.Rmd 相同的目录中,正如https://bookdown.org/yihui/bookdown/usage.html 中所述,我的答案中提供了一个示例:How to set the language in a html document via r markdown html

但是,我可以将_bookdown.yml 文件保存在我的.Rmd 文件的另一个目录中,并以includes 或其他方式通知它吗?

【问题讨论】:

    标签: r yaml r-markdown bookdown


    【解决方案1】:

    我认为这是不可能的,因为在 render_book 内部我们有:

    config = load_config()  # configurations in _bookdown.yml
    

    其中load_config 使用的是. 目录。

    load_config = function() {
      if (length(opts$get('config')) == 0 && file.exists('_bookdown.yml')) {
        # store the book config
        opts$set(config = rmarkdown:::yaml_load_file('_bookdown.yml'))
      }
    

    来源:https://github.com/rstudio/bookdown

    【讨论】:

    • 我知道bookdown的目的是写books。但是,我计划它写许多报告。如果我能告知一条路径,那就太好了...谢谢@polkas
    • stackoverflow.com/questions/39885363/… 看看这个,尤其是 pandoc_args
    • Tks。但似乎无法将这些信息从_bookdown.yml 传递给YAML
    • 是的,pandoc_args 在 _bookdown.yml 的情况下没有帮助,我在答案中写了原因。在其他情况下可能会对未来有所帮助,这就是我将其发送给您的原因。
    • 您希望 YAML 文件能够从 Rmd 外部包含在页面顶部?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-23
    • 2022-11-10
    • 2019-09-14
    • 1970-01-01
    • 2010-10-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多