Yao Yu
Yao Yu

Reputation: 31

Bookdown preview_chapter() not working with knit button

I'm currently helping a professor build a data science book for his course, Gov 50, at Harvard. The issue we're having while working with the bookdown package is that we cannot seem to build individual chapters with the knit button and preview the chapter automatically in a new window.

The error we get is:

Error in files2[[format]] : 
  attempt to select less than one element in get1index
Calls: <Anonymous> ... render_book -> setdiff -> as.vector -> source_files
Execution halted

So instead, we are forced to use the preview_chapter() function and then manually go through every html file for the book to find the chapter we want to preview. This ends up being time consuming and makes the process difficult for our individual chapter writers. Does anyone know what might be causing the issue?

Our _output.yml file seems to be setup correctly:

bookdown::tufte_html_book:
  df_print: default
  css: style.css
  split_by: "section"
  config:
    toc:
      collapse: subsection
      scroll_highlight: true

Upvotes: 1

Views: 213

Answers (1)

Yao Yu
Yao Yu

Reputation: 31

It seems that this error is caused by specifying the order of Rmd files to build. The chapters can be previewed if I comment out this in my _bookdown.yml:

rmd_files: 
#  html: ["index.Rmd", ..., "references.Rmd"]

Upvotes: 2

Related Questions