How can I use the new bs4() theme in bookdown?
Asked Answered
G

1

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
Geriatrician answered 10/11, 2020 at 23:42 Comment(3)
By installating the development version from the github repo.: github.com/rstudio/bookdownSidonnie
Did you install the R4DS package that contains the code for the book format? you can install it by devtools::install_github("hadley/r4ds")Ki
@DirkEddelbuettel That did it, thanks!Geriatrician
G
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"
Geriatrician answered 11/11, 2020 at 4:31 Comment(2)
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.Hess
I think that the following line is enough, devtools::install_github('rstudio/bookdown@bs4-book-encoding', force = TRUE)Deplete

© 2022 - 2024 — McMap. All rights reserved.