tufte_html 格式可以拆分成 bookdown/rmarkdown 中的章节吗?

Can tufte_html format be split into chapters in bookdown/rmarkdown?

是否可以将 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  

我不太明白您在 index.Rmdsetup 块中尝试做什么,但这不是在 R Markdown 中指定输出格式的正确方法。这是工作示例:

index.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.

another_file.Rmd:

# Yet another chapter

Foo bar baz.

渲染这本书:

bookdown::render_book('index.Rmd')