使用R/bookdown呈现tufte_html_book()时出错

使用R/bookdown呈现tufte_html_book()时出错,r,bookdown,tufte,R,Bookdown,Tufte,我正在尝试使用R/bookdown构建一本书,但在使用tufte\u html\u book或html\u book生成html版本时遇到了一个问题: Error in split_chapters(output, page_builder, number_sections, split_by, : The document must start with a first (#) or second level (##) heading 该书在gitbook或tufte_book2输出

我正在尝试使用R/bookdown构建一本书,但在使用tufte\u html\u book或html\u book生成html版本时遇到了一个问题:

Error in split_chapters(output, page_builder, number_sections, split_by,  : 
  The document must start with a first (#) or second level (##) heading
该书在gitbook或tufte_book2输出中正确生成。 该文档有四个文件
index.Rmd
01-Chap1.Rmd
02-Chap2.Rmd
03-Chap3.Rmd
。我喜欢把事情弄清楚,所以
index.Rmd
只包含YAML标题,加上一些R代码,但没有标题,这可能就是产生错误的原因。有没有办法使bookdown的html输出与gitbook或pdf输出的行为类似

以下是一个可重复的小示例:

指数.Rmd:

---
title: "Tufte Handout"
subtitle: "An implementation in R Markdown"
author: "JJ Allaire and Yihui Xie"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
output:
  bookdown::tufte_html_book:
    toc: yes
bookdown::tufte_book2:
    toc: yes
---

```{r setup1, include=FALSE}
library(tufte)
# invalidate cache when the tufte version changes
knitr::opts_chunk$set(tidy = FALSE, cache.extra = 
packageVersion('tufte'))
options(htmltools.dir.version = FALSE)
```
01-Chap1.Rmd

# Introduction

The Tufte handout style is a style that Edward Tufte uses in his books and handouts. Tufte's style is known for its extensive use of sidenotes, tight integration of graphics with text, and well-set typography. This style has been implemented in LaTeX and HTML/CSS^[See Github repositories [tufte-latex](https://github.com/tufte-latex/tufte-latex) and [tufte-css](https://github.com/edwardtufte/tufte-css)], respectively. We have ported both implementations into the [**tufte** package](https://github.com/rstudio/tufte). If you want LaTeX/PDF output, you may use the `tufte_handout` format for handouts, and `tufte_book` for books. 
For HTML output, use `tufte_html`. These formats can be either specified in the YAML metadata at the beginning of an R Markdown document (see an example below), or passed to the `rmarkdown::render()` function. See @R-rmarkdown more information about **rmarkdown**.

我在回答我自己的问题


gitbook和(tufte_uu)html_u书之间的行为差异在于split_uby参数,即gitbook中的
split_uby=“chapter”
,以及(tufte_u)html_u书中的
split_uby=“section”
。将
split\u by:chapter
添加到
bookdown::tufte\u html\u book:
yaml部分可以无误地构建html。

您应该给出一个可复制的示例。也许您可以只留下
index.Rmd
01-Chap1.Rmd
,并尽可能减少它们的内容,同时生成相同的示例。然后粘贴两个文件的代码。是否可以使用此方法生成tufte pdf书籍?是的。只需将
bookdown::tufte_book2
保存在yaml中即可。