😎 Give your xaringan slides some style
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

92 lines
3.1KB

  1. <!-- Set link to theme-settings, template-variables, theme functions -->
  2. ```{r include=FALSE}
  3. if (!exists("IS_README")) IS_README <- FALSE
  4. ```
  5. First, add the `xaringan-themer.css` file to the YAML header of your xaringan slides.
  6. ```yaml
  7. output:
  8. xaringan::moon_reader:
  9. css: xaringan-themer.css
  10. ```
  11. Then, in a hidden chunk just after the knitr setup chunk, load **xaringanthemer** and try one of the [theme functions][theme-functions].
  12. ````markdown
  13. ```{r xaringan-themer, include = FALSE}`r ""`
  14. library(xaringanthemer)
  15. style_mono_light(
  16. base_color = "#1c5253",
  17. header_font_google = google_font("Josefin Sans"),
  18. text_font_google = google_font("Montserrat", "300", "300i"),
  19. code_font_google = google_font("Droid Mono")
  20. )
  21. ```
  22. ````
  23. <img src="https://raw.githubusercontent.com/gadenbuie/xaringanthemer/assets/example_mono_light_1c5253.png" alt="Example title and normal slides using a green xaringanthemer theme" data-external="1" />
  24. ### Matching ggplot Themes
  25. [showtext]: https://github.com/yixuan/showtext
  26. **xaringanthemer** even provides a [ggplot2] theme
  27. with `theme_xaringan()`
  28. that uses the colors and fonts from your slide theme.
  29. Built on the [showtext] package,
  30. and designed to work seamlessly with [Google Fonts](https://fonts.google.com).
  31. Color and fill scales are also provided
  32. for matching sequential color scales based on
  33. the primary color used in your slides.
  34. See `?scale_xaringan` for more details.
  35. ```{r xaringanthemer-ggplot-setup, include=FALSE, eval=IS_README}
  36. style_mono_light(
  37. base_color = "#1c5253",
  38. header_font_google = google_font("Josefin Sans"),
  39. text_font_google = google_font("Montserrat", "300", "300i"),
  40. code_font_google = google_font("Droid Mono"),
  41. outfile = NULL
  42. )
  43. ```
  44. ```{r theme_xaringan_demo, echo=TRUE, warning=FALSE, fig.width=13, fig.height=5.5, eval=IS_README}
  45. library(ggplot2)
  46. ggplot(diamonds) +
  47. aes(cut, fill = cut) +
  48. geom_bar(show.legend = FALSE) +
  49. labs(
  50. x = "Cut",
  51. y = "Count",
  52. title = "A Fancy diamonds Plot"
  53. ) +
  54. theme_xaringan(background_color = "#FFFFFF") +
  55. scale_xaringan_fill_discrete()
  56. ```
  57. ```{r link-to-plot-image, echo=FALSE, eval=!IS_README, results='asis'}
  58. if (identical(Sys.getenv("IN_PKGDOWN"), "true")) {
  59. cat("![](../reference/figures/index-theme_xaringan_demo-1.png)")
  60. } else {
  61. cat('<img src="../man/figures/index-theme_xaringan_demo-1.png" data-external="1" />')
  62. }
  63. ```
  64. ### Tab Completion
  65. **xaringanthemer** is <kbd>Tab</kbd> friendly -- [use autocomplete to explore][theme-settings] the [template variables][template-variables] that you can adjust in each of the themes!
  66. <img src="https://raw.githubusercontent.com/gadenbuie/xaringanthemer/assets/example-rstudio-completion.gif" alt="Demonstration of argument auto-completion with RStudio" data-external="1" />
  67. ### R Markdown Template in RStudio
  68. You can also skip the above and just create a *Ninja Themed Presentation* from the New R Markdown Document menu in RStudio.
  69. <center>
  70. <img src="https://raw.githubusercontent.com/gadenbuie/xaringanthemer/assets/rmarkdown-template-screenshot.png" alt="The 'New R Markdown Document' menu in RStudio" data-external="1" />
  71. </center>