😎 Give your xaringan slides some style
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

153 lines
4.0KB

  1. **xaringanthemer** includes a number of functions that provide
  2. themed **xaringan** styles.
  3. All of the styling functions start with the `style_` prefix.
  4. The goal of each style function is to
  5. quickly set up a coordinated color palette for your slides
  6. based on one or two starter colors.
  7. Styles based on one color start with `style_mono_`
  8. and styles based on two colors start with `style_duo_`.
  9. How the starter colors are used is described
  10. in the final portion of the style function name.
  11. For example, `style_mono_accent()` uses a single color as an accent color.
  12. Note that the colors used below are for demonstration only,
  13. the point of the `style_` functions is for you to choose your own color palette!
  14. If your color palette uses more than two colors,
  15. you can add additional colors with the `colors` argument.
  16. See the [Colors](#colors) section for more information.
  17. ### Monotone
  18. ```{r include=FALSE}
  19. IS_README <- exists("IS_README") && IS_README
  20. include_graphic <- function(img_path) {
  21. glue::glue(
  22. '<img src="https://raw.githubusercontent.com/gadenbuie/',
  23. 'xaringanthemer/assets/{img_path}" data-external="1" />'
  24. )
  25. }
  26. ```
  27. Use these functions to automatically create a consistent color palette for your slides, based around a single color.
  28. #### `style_mono_light()`
  29. A light theme based around a single color.
  30. ```{r style_mono_light}
  31. demo_function_call <- function(f, n_params = 1) {
  32. cat(sep = "",
  33. "```r\n",
  34. paste(substitute(f)), "(",
  35. if (n_params > 0) paste(collapse = ", ",
  36. sapply(1:n_params, function(i) {
  37. paste0(names(formals(f))[i], ' = "', formals(f)[[i]], '"')})),
  38. ")\n```"
  39. )
  40. }
  41. demo_function_call(style_mono_light, 1)
  42. ```
  43. `r include_graphic("example_mono_light.png")`
  44. #### `style_mono_dark()`
  45. A dark theme based around a single color.
  46. ```{r style_mono_dark}
  47. demo_function_call(style_mono_dark, 1)
  48. ```
  49. `r include_graphic("example_mono_dark.png")`
  50. #### `style_mono_accent()`
  51. The default xaringan theme with a single color used for color accents on select elements (headers, bold text, etc.).
  52. ```{r style_mono_accent}
  53. demo_function_call(style_mono_accent, 1)
  54. ```
  55. `r include_graphic("example_mono_accent.png")`
  56. #### `style_mono_accent_inverse()`
  57. An "inverted" default xaringan theme with a single color used for color accents on select elements (headers, bold text, etc.).
  58. ```{r style_mono_accent_inverse}
  59. demo_function_call(style_mono_accent_inverse, 1)
  60. ```
  61. `r include_graphic("example_mono_accent_inverse.png")`
  62. ### Duotone
  63. These themes build from two (ideally) complementary colors.
  64. #### `style_duo()`
  65. A two-colored theme based on a primary and secondary color.
  66. ```{r style_duo}
  67. demo_function_call(style_duo, 2)
  68. ```
  69. `r include_graphic("example_duo.png")`
  70. #### `style_duo_accent()`
  71. The default Xaringan theme with two accent colors.
  72. ```{r style_duo_accent}
  73. demo_function_call(style_duo_accent, 2)
  74. ```
  75. `r include_graphic("example_duo_accent.png")`
  76. #### `style_duo_accent_inverse()`
  77. An "inverted" default Xaringan theme with two accent colors.
  78. ```{r style_duo_accent_inverse}
  79. demo_function_call(style_duo_accent_inverse, 2)
  80. ```
  81. `r include_graphic("example_duo_accent_inverse.png")`
  82. ### Solarized
  83. There are also two themes based around the [solarized color palette](https://ethanschoonover.com/solarized/), `style_solarized_light()` and `style_solarized_dark()`.
  84. For both themes, it is advisted to change the syntax highlighting theme to `solarized-light` or `solarized-dark` (looks great paired or constrasted).
  85. #### `style_solarized_light()`
  86. ```{r style_solarized_light}
  87. demo_function_call(style_solarized_light, 0)
  88. ```
  89. `r include_graphic("example_solarized_light.png")`
  90. #### `style_solarized_dark()`
  91. ```{r style_solarized_dark}
  92. demo_function_call(style_solarized_dark, 0)
  93. ```
  94. `r include_graphic("example_solarized_dark.png")`
  95. To do this, your YAML header should look more-or-less like this:
  96. ```yaml
  97. output:
  98. xaringan::moon_reader:
  99. css: ["xaringan-themer.css"]
  100. nature:
  101. highlightStyle: solarized-dark
  102. highlightLines: true
  103. countIncrementalSlides: false
  104. ```