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

150 lines
3.9KB

  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 you 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("![](https://raw.githubusercontent.com/gadenbuie/xaringanthemer/assets/{img_path})")
  22. }
  23. ```
  24. Use these functions to automatically create a consistent color palette for your slides, based around a single color.
  25. #### `style_mono_light()`
  26. A light theme based around a single color.
  27. ```{r style_mono_light}
  28. demo_function_call <- function(f, n_params = 1) {
  29. cat(sep = "",
  30. "```r\n",
  31. paste(substitute(f)), "(",
  32. if (n_params > 0) paste(collapse = ", ",
  33. sapply(1:n_params, function(i) {
  34. paste0(names(formals(f))[i], ' = "', formals(f)[[i]], '"')})),
  35. ")\n```"
  36. )
  37. }
  38. demo_function_call(style_mono_light, 1)
  39. ```
  40. `r include_graphic("example_mono_light.png")`
  41. #### `style_mono_dark()`
  42. A dark theme based around a single color.
  43. ```{r style_mono_dark}
  44. demo_function_call(style_mono_dark, 1)
  45. ```
  46. `r include_graphic("example_mono_dark.png")`
  47. #### `style_mono_accent()`
  48. The default xaringan theme with a single color used for color accents on select elements (headers, bold text, etc.).
  49. ```{r style_mono_accent}
  50. demo_function_call(style_mono_accent, 1)
  51. ```
  52. `r include_graphic("example_mono_accent.png")`
  53. #### `style_mono_accent_inverse()`
  54. An "inverted" default xaringan theme with a single color used for color accents on select elements (headers, bold text, etc.).
  55. ```{r style_mono_accent_inverse}
  56. demo_function_call(style_mono_accent_inverse, 1)
  57. ```
  58. `r include_graphic("example_mono_accent_inverse.png")`
  59. ### Duotone
  60. These themes build from two (ideally) complementary colors.
  61. #### `style_duo()`
  62. A two-colored theme based on a primary and secondary color.
  63. ```{r style_duo}
  64. demo_function_call(style_duo, 2)
  65. ```
  66. `r include_graphic("example_duo.png")`
  67. #### `style_duo_accent()`
  68. The default Xaringan theme with two accent colors.
  69. ```{r style_duo_accent}
  70. demo_function_call(style_duo_accent, 2)
  71. ```
  72. `r include_graphic("example_duo_accent.png")`
  73. #### `style_duo_accent_inverse()`
  74. An "inverted" default Xaringan theme with two accent colors.
  75. ```{r style_duo_accent_inverse}
  76. demo_function_call(style_duo_accent_inverse, 2)
  77. ```
  78. `r include_graphic("example_duo_accent_inverse.png")`
  79. ### Solarized
  80. There are also two themes based around the [solarized color palette](http://ethanschoonover.com/solarized), `style_solarized_light()` and `style_solarized_dark()`.
  81. For both themes, it is advisted to change the syntax highlighting theme to `solarized-light` or `solarized-dark` (looks great paired or constrasted).
  82. #### `style_solarized_light()`
  83. ```{r style_solarized_light}
  84. demo_function_call(style_solarized_light, 0)
  85. ```
  86. `r include_graphic("example_solarized_light.png")`
  87. #### `style_solarized_dark()`
  88. ```{r style_solarized_dark}
  89. demo_function_call(style_solarized_dark, 0)
  90. ```
  91. `r include_graphic("example_solarized_dark.png")`
  92. To do this, your YAML header should look more-or-less like this:
  93. ```yaml
  94. output:
  95. xaringan::moon_reader:
  96. css: ["xaringan-themer.css"]
  97. nature:
  98. highlightStyle: solarized-dark
  99. highlightLines: true
  100. countIncrementalSlides: false
  101. ```