是否可以将R tufte包中的tufte_html
文档拆分为每个章节一个文件?我想写整本书。通过Bookdown,我可以将章节组织在自己的文件中,这些章节在pdf输出中开始新的页面,但是对于html输出,它只是一个文件。
这是我尝试过的不起作用。
index.Rmd
---
title: "Probability and Statistics<br />"
author: "Bob Carpenter"
date: "2018"
output:
tufte::tufte_html
---
```{r setup, include=FALSE}
bookdown::tufte_html_book(split_by = "chapter")
```
# A Chapter
Blah blah blah.
# Another Chapter
Blah blah blah.
```
_bookdown.yml
rmd_files: [
"index.Rmd",
"another_file.Rmd"
]
another_file.Rmd
# Yet another chapter
Foo bar baz.
$ R
> library(bookdown)
> render_book("index.Rmd")
这将产生单个html文档作为输出,而不是每章一个文件。我还尝试用bookdown::tufte_html_book(split_by = "chapter")
替换split_by调用。
这是我的sessionInfo()
> sessionInfo() R version 3.5.0 (2018-04-23) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.13.6 Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] bookdown_0.7 loaded via a namespace (and not attached): [1] Rcpp_0.12.18 tufte_0.4 digest_0.6.15 rprojroot_1.3-2 [5] backports_1.1.2 magrittr_1.5 evaluate_0.10.1 stringi_1.2.2 [9] rstudioapi_0.7 rmarkdown_1.10 tools_3.5.0 stringr_1.3.1 [13] xfun_0.1 yaml_2.2.0 compiler_3.5.0 htmltools_0.3.6 [17] knitr_1.20
答案 0 :(得分:2)
我不太了解您在setup
的{{1}}块中要做什么,但这不是在R Markdown中指定输出格式的正确方法。这是工作示例:
index.Rmd :
index.Rmd
另一个文件。Rmd:
---
title: "Probability and Statistics<br />"
author: "Bob Carpenter"
date: "2018"
output:
bookdown::tufte_html_book:
split_by: chapter
---
# A Chapter
Blah blah blah.
# Another Chapter
Blah blah blah.
渲染书籍:
# Yet another chapter
Foo bar baz.