首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用R/bookdown呈现tufte_html_book()时出错

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

Stack Overflow用户
提问于 2017-10-08 07:57:43
回答 1查看 937关注 0票数 2

我正在尝试用R/bookdown构建一本书,在使用tufte_html_book或html_book生成html版本时,我面临着一个问题:

代码语言:javascript
复制
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.Rmd01-Chap1.Rmd02-Chap2.Rmd03-Chap3.Rmd。我喜欢保持清楚,所以index.Rmd只包含YAML头,加上一些R代码,但没有标题,这可能是导致错误的原因。是否有办法使下载的html输出类似于gitbook或pdf输出?

下面是一个可复制的小例子:

Index.Rmd:

代码语言:javascript
复制
---
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}

图书馆(Tufte)

在tufte版本更改时使缓存失效

Knitr::opts_chunk$set(整洁=假,cache.extra =

packageVersion(‘tufte’)

选项(htmltools.dir.version= FALSE)

代码语言:javascript
复制

01-Chap1.Rmd

代码语言:javascript
复制
# 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**.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-09 09:58:53

我在回答我自己的问题。

gitbook和(tufte_)html_book在行为上的区别在于split_by参数,即gitbook中的split_by="chapter"和(tufte_)html_book中的split_by="section"。将split_by: chapter添加到bookdown::tufte_html_book: yaml部分,可以在不出错的情况下构建bookdown::tufte_html_book:

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46628788

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档