r - 如何在 bookdown::gitbook 中使用自定义 pandoc HTML 模板

标签 r r-markdown pandoc bookdown

我想为 bookdown 项目编写一个自定义模板。来自 documentation在 bookdown 包中,我读到可以用自定义模板替换默认模板,例如 my_custom_template.html,方法是将 template: "my_custom_template.html" 包含在YAML header 如

bookdown::gitbook:
  template: my_custom_template.html

这样做会产生以下错误:

Error in rmarkdown::html_document(..., extra_dependencies = c(extra_dependencies,  : 
  formal argument "template" matched by multiple actual arguments
Calls: <Anonymous> ... do.call -> <Anonymous> -> html_document2 -> <Anonymous>
Execution halted
Error in eval(expr, envir, enclos) : 
  Failed to compile the book to bookdown::gitbook

在我看来,默认模板是硬编码的,因此不能轻易覆盖。

还有其他方法来包含自定义模板吗?

最佳答案

更新:自 bookdown v0.8 以来,这已成为可能(感谢 PR #570)。


这是不可能的,它是这样记录的:在所用函数的文档中 (?bookdown::gitbook) template 被排除在以下列表之外要传递给 rmarkdown::html_document() 的可用参数,以及 toctheme。您链接到的页面中也提到了这一点:

There are a few arguments of html_document() that have been hard-coded in gitbook() and you cannot change them: toc = TRUE (there must be a table of contents), theme = NULL (not using any Bootstrap themes), and template (there exists an internal GitBook template).

关于r - 如何在 bookdown::gitbook 中使用自定义 pandoc HTML 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52316862/

相关文章:

将 R 代码转换为 C 代码

r - 如何提取特定字符串后的所有内容?

r - 是否可以在没有 kableExtra 的情况下使用 kable 更改列宽?

latex - pandoc 没有正确转换 latex 风格的引文

linux - 用于 Linux Suse 的 Pandoc

latex - 减少 rmarkdown beamer 演示中代码块和代码输出之间的空间

r - 向量列表的所有可能组合

r - 以编程方式向数据框添加新变量

r - 如何使用 Microsoft R Open 3.3.2 获得 rmarkdown 1.2

jquery - 如何放大 Rmarkdown 演示文稿中的绘图