😎 Give your xaringan slides some style
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

94 rindas
3.2KB

  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, warning=FALSE}`r ""`
  14. library(xaringanthemer)
  15. style_mono_accent(
  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("Fira Mono")
  20. )
  21. ```
  22. ````
  23. <img src="https://raw.githubusercontent.com/gadenbuie/xaringanthemer/assets/example_mono_accent_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. More details and examples can be found in `vignette("ggplot2-themes")`.
  36. ```{r xaringanthemer-ggplot-setup, include=FALSE, eval=IS_README}
  37. style_mono_accent(
  38. base_color = "#1c5253",
  39. header_font_google = google_font("Josefin Sans"),
  40. text_font_google = google_font("Montserrat", "300", "300i"),
  41. code_font_google = google_font("Fira Mono"),
  42. outfile = NULL
  43. )
  44. ```
  45. ```{r theme_xaringan_demo, echo=TRUE, warning=FALSE, fig.width=13, fig.height=5.5, eval=IS_README}
  46. library(ggplot2)
  47. ggplot(diamonds) +
  48. aes(cut, fill = cut) +
  49. geom_bar(show.legend = FALSE) +
  50. labs(
  51. x = "Cut",
  52. y = "Count",
  53. title = "A Fancy diamonds Plot"
  54. ) +
  55. theme_xaringan(background_color = "#FFFFFF") +
  56. scale_xaringan_fill_discrete()
  57. ```
  58. ```{r link-to-plot-image, echo=FALSE, eval=!IS_README, results='asis'}
  59. if (identical(Sys.getenv("IN_PKGDOWN"), "true")) {
  60. cat("![](../reference/figures/index-theme_xaringan_demo-1.png)")
  61. } else {
  62. cat('<img src="../man/figures/index-theme_xaringan_demo-1.png" data-external="1" />')
  63. }
  64. ```
  65. ### Tab Completion
  66. **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!
  67. <img src="https://raw.githubusercontent.com/gadenbuie/xaringanthemer/assets/example-rstudio-completion.gif" alt="Demonstration of argument auto-completion with RStudio" data-external="1" />
  68. ### R Markdown Template in RStudio
  69. You can also skip the above and just create a *Ninja Themed Presentation* from the New R Markdown Document menu in RStudio.
  70. <center>
  71. <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" />
  72. </center>