15

How can I use the bs4 theme in bookdown, such as the one used for the R4DS book

In the _output.yaml I see the following code, but it doesn't work with my project.

bookdown::bs4_book:
  theme:
    primary: "#637238"
  repo: https://github.com/hadley/r4ds
  includes:
    in_header: [ga_script.html]

and I get this error when I attempt to build the book

Error: 'bs4_book' is not an exported object from 'namespace:bookdown'
Execution halted
max
  • 4,141
  • 5
  • 26
  • 55

1 Answers1

15

I got it to work by doing the following:

Run the following

remotes::install_github("rstudio/bslib")
install.packages("downlit")
remotes::install_github("rstudio/bookdown")

Change the _output.yaml to the following:

bookdown::bs4_book:
  theme:
    primary: "#637238"
max
  • 4,141
  • 5
  • 26
  • 55
  • 4
    `bookdown` for building the document, `bslib` for the `bookdown::bs4_book` itself and `downlit` because of `Error: Must install the following packages to use bs4_book() * downlit`. – Trusky Nov 21 '20 at 19:12
  • 1
    I think that the following line is enough, `devtools::install_github('rstudio/bookdown@bs4-book-encoding', force = TRUE)` – R.Andres Castaneda Jan 06 '21 at 21:30