Closed mine-cetinkaya-rundel closed 3 years ago
Hi @mine-cetinkaya-rundel thanks for the detailed investigation! The issue is almost certainly the result of xaringanthemer using showtext for the theme_xaringan()
fonts. Because showtext requires the knitr option fig.showtext = TRUE
and that particular option is basically only documented in an issue comment on GitHub (or was when I wrote xaringanthemer), xaringanthemer automatically sets this option on load.
The good news is that there's a work-around: set fig.showtext = FALSE
in the chunk options of the chunk where xaringanthemer is attached to opt out of showtext
features.
```{r xaringan-themer, include = FALSE, fig.showtext = FALSE}
library(xaringanthemer)
style_duo_accent(
primary_color = "blue",
secondary_color = "white",
)
suppressPackageStartupMessages(library(ggplot2))
ggplot(mtcars, aes(x = mpg, y = disp)) +
geom_text(label = "🚗")
Ah, thank you!
Are there any potential side effects of fig.showtext = FALSE
, e.g. if I'm using xaringanthemer to set a font as well?
The side effects only appear when you try to use theme_xaringan()
with ggplot2 when you want theme_xaringan()
to find the fonts used in your xaringanthemer theme. If you have those fonts locally, you can call theme_xaringan(use_showtext = FALSE)
, possibly also using the text_font
and title_font
arguments to choose the correct local font names.
If you're using xaringanthemer for just the CSS file, then there aren't any side effects! (Or you can set eval=FALSE
on the xaringan-themer
chunk after running it once to make the xaringan-themer.css
file.)
That all sounds good, thank you so much!
Maybe worth documenting the option somewhere in addition to this issue in case others run into it? But I'll close the issue here since we have a resolution either way.
I have been observing that when I have emojis in my plots that I make with ggplot2 and include in a xaringan presentation, sometimes when I knit the emojis show up and other times they don't. I believe the culprit might be xaringanthemer as adding/removing the chunk where a theme is defined with xaringanthemer seems to affect the outcome.
Here is my minimal xaringan document