😎 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.

136 lines
3.8KB

  1. ---
  2. title: "Xaringan CSS Theme Generator"
  3. output: rmarkdown::html_vignette
  4. vignette: >
  5. %\VignetteIndexEntry{Overview of xaringanthemer}
  6. %\VignetteEngine{knitr::rmarkdown}
  7. %\VignetteEncoding{UTF-8}
  8. ---
  9. ```{r setup, include = FALSE}
  10. knitr::opts_chunk$set(
  11. collapse = TRUE,
  12. results = "asis",
  13. echo = FALSE,
  14. comment = "#>",
  15. fig.path = "man/figures/README-",
  16. out.width = "100%"
  17. )
  18. library(xaringanthemer)
  19. ```
  20. [xaringan]: https://github.com/yihui/xaringan
  21. [remarkjs]: https://github.com/gnab/remark
  22. ```{r toc, results='asis', echo=FALSE, message=FALSE, eval=FALSE}
  23. devtools::source_gist("c83e078bf8c81b035e32c3fc0cf04ee8", filename = 'render_toc.R')
  24. x <- render_toc("README.Rmd", toc_depth = 3)
  25. gsub(" -", "-", sub("^-.+?\n", "", x))
  26. ```
  27. Jump to:
  28. [Quick Intro](#quick-intro),
  29. [Themes](#themes),
  30. [Theme Settings](#theme-settings),
  31. [Adding Custom CSS](#adding-custom-css),
  32. [Fonts](#fonts)
  33. ## Quick Intro
  34. [theme-functions]: #themes
  35. [theme-settings]: #theme-settings
  36. [template-variables]: template-variables.html
  37. ```{r child="../man/fragments/_quick-intro.Rmd"}
  38. ```
  39. ## Themes
  40. ```{r child="../man/fragments/_themes.Rmd"}
  41. ```
  42. ## Theme Settings
  43. The theme functions listed above are just wrappers around the central function of this package, `style_xaringan()`.
  44. If you want to start from the default **xaringan** theme and make a few modifications, start there.
  45. All of the theme template variables are repeated in each of the theme functions (instead of relying on `...`) so that you can use autocompletion to find and change the defaults for any theme function.
  46. To override the default value of any theme functions, set the appropriate argument in the theme function.
  47. A table of all template variables is included in [`vignette("template-variables", "xaringanthemer")`](template-variables.html).
  48. As an example, try loading `xaringanthemer`, type out `style_duo_theme(` and then press <kbd>Tab</kbd> to see all of the theme options.
  49. All of the theme options are named so that you first think of the element you want to change, then the property of that element.
  50. Here are some of the `text_` theme options:
  51. ```{r, results='asis', echo=FALSE}
  52. tvv <- xaringanthemer:::template_variables$variable
  53. cat(paste0("- `", tvv[grepl("^text_", tvv)][1:5], "`"), sep = "\n")
  54. cat("- *and more ...*")
  55. ```
  56. And here are the title slide theme options:
  57. ```{r results='asis', echo=FALSE}
  58. cat(paste0("- `", tvv[grepl("^title_slide_", tvv)], "`"), sep = "\n")
  59. ```
  60. ## Fonts
  61. [adding-custom-css]: #adding-custom-css
  62. ```{r child="../man/fragments/_fonts.Rmd"}
  63. ```
  64. ## Colors
  65. ```{r child="../man/fragments/_colors.Rmd"}
  66. ```
  67. ## Adding Custom CSS
  68. You can also add custom CSS classes using the `extra_css` argument in the theme functions.
  69. This argument takes a named list of CSS definitions each containing a named list of CSS property-value pairs.
  70. ```r
  71. extra_css <- list(
  72. ".small" = list("font-size" = "90%"),
  73. ".full-width" = list(
  74. display = "flex",
  75. width = "100%",
  76. flex = "1 1 auto"
  77. )
  78. )
  79. ```
  80. If you would rather keep your additional css definitions in a separate file, you can call `style_extra_css()` separately.
  81. Just be sure to include your new CSS file in the list of applied files in your YAML header.
  82. ```r
  83. style_extra_css(css = extra_css, outfile = "custom.css")
  84. ```
  85. ```{r results='asis', echo=FALSE}
  86. extra_css <- list(
  87. ".small" = list("font-size" = "90%"),
  88. ".full-width" = list(
  89. display = "flex",
  90. width = "100%",
  91. flex = "1 1 auto"
  92. )
  93. )
  94. cat(
  95. "\n```css",
  96. "/* Extra CSS */",
  97. xaringanthemer:::list2css(extra_css),
  98. "```",
  99. sep = "\n"
  100. )
  101. ```
  102. This is most helpful when wanting to define helper classes to work with the [remark.js][remarkjs] `.class[]` syntax.
  103. Using the above example, we could add slide text `.small[in smaller font size]`.
  104. ```{r child="../man/fragments/_thanks.Rmd"}
  105. ```