Can {thematic} be used for `bookdown::bs4_book()`?

Hi everyone,

I just watched the rstudio::global(2021) video on thematic and bslib and was curious if {thematic} also works with {bookdown}, specifically bs4_book(). As far as I understood, {thematic} needs themes created with {bslib}, which can be used with bs4_book().

But when I use the following _output.yml:

bookdown::bs4_book:
  theme: 
    bootswatch: cyborg
  split_bib: no
  df_print: kable

and the setup code chunk (in index.Rmd)

```{r setup, include = FALSE}
thematic::thematic_rmd()
```

then any plots created by, e.g. ggplot, do not match the bootstrap theme. Am I missing any code, or does {thematic} not yet work with {bookdown}?

Thanks,

Stephan

I have never tried to do that.

If it is not working, it is either that thematic_rmd() doesn't support bookdown project or that with bookdown project, it needs a special workflow.

Do you get an error during the rendering ?

I would be great that you open a feature request thematic (and we'll move to bookdown if needed) so this is tracked somewhere, and that it could be in the open to get some feedback on this.

Thank you !

Ok, I created a better reprex. Here, the bookdown consists of a single index.Rmd file:

--- 
title: "A Minimal Book Example"
author: "John Doe"
date: "`r Sys.Date()`"
description: "A simple bookdown using {thematic}"
site: bookdown::bookdown_site
documentclass: book
output:
  bookdown::bs4_book:
    theme:
      bootswatch: cyborg
---

# About

```{r setup, include = FALSE}
thematic::thematic_rmd()
```

Here a plot:

```{r}
plot(pressure)
```

The output looks like this:

And yes, there are actually warnings that I have missed before:

Warning messages:
1: thematic was unable to resolve `bg='auto'`. Try providing an actual color (or `NA`) to the `bg` argument of `thematic_on()`. By the way, 'auto' is only officially supported in `shiny::renderPlot()`, some rmarkdown scenarios (specifically, `html_document()` with `theme!=NULL`), in RStudio, or if `auto_config_set()` is used. 
2: thematic was unable to resolve `fg='auto'`. Try providing an actual color (or `NA`) to the `fg` argument of `thematic_on()`. By the way, 'auto' is only officially supported in `shiny::renderPlot()`, some rmarkdown scenarios (specifically, `html_document()` with `theme!=NULL`), in RStudio, or if `auto_config_set()` is used. 
3: thematic was unable to resolve `accent='auto'`. Try providing an actual color (or `NA`) to the `accent` argument of `thematic_on()`. By the way, 'auto' is only officially supported in `shiny::renderPlot()`, some rmarkdown scenarios (specifically, `html_document()` with `theme!=NULL`), in RStudio, or if `auto_config_set()` is used. 

I have opened a feature request.

Thanks!

Edit: Added missing line of code.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.