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

148 lines
4.4KB

  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. <!-- This vignette was automatically created from README.Rmd
  10. Please consider removing installation instructions, badges, and
  11. any other README-specific material.
  12. You can include short independent documents in README.Rmd using
  13. the following chunk argument syntax:
  14. child='vignettes/rmdhunks/example1.Rmd'
  15. https://yihui.name/knitr/demo/child/
  16. or read-in chunks stored in an independent R script using knitr::read_chunk()
  17. https://yihui.name/knitr/demo/externalization/ -->
  18. <!-- README.md is generated from README.Rmd. Please edit that file -->
  19. ```{r setup, include = FALSE}
  20. knitr::opts_chunk$set(
  21. collapse = TRUE,
  22. results = "asis",
  23. echo = FALSE,
  24. comment = "#>",
  25. fig.path = "man/figures/README-",
  26. out.width = "100%"
  27. )
  28. library(xaringanthemer)
  29. ```
  30. [xaringan]: https://github.com/yihui/xaringan
  31. [remarkjs]: https://github.com/gnab/remark
  32. ```{r toc, results='asis', echo=FALSE, message=FALSE, eval=FALSE}
  33. devtools::source_gist("c83e078bf8c81b035e32c3fc0cf04ee8", filename = 'render_toc.R')
  34. x <- render_toc("README.Rmd", toc_depth = 3)
  35. gsub(" -", "-", sub("^-.+?\n", "", x))
  36. ```
  37. Jump to:
  38. [Quick Intro](#quick-intro),
  39. [Themes](#themes),
  40. [Theme Settings](#theme-settings),
  41. [Adding Custom CSS](#adding-custom-css),
  42. [Fonts](#fonts)
  43. ## Quick Intro
  44. [theme-functions]: #themes
  45. [theme-settings]: #theme-settings
  46. [template-variables]: template-variables.html
  47. ```{r child="rmdchunks/_quick-intro.Rmd"}
  48. ```
  49. ## Themes
  50. ```{r child="rmdchunks/_themes.Rmd"}
  51. ```
  52. ## Theme Settings
  53. The theme functions listed above are just wrappers around the central function of this package, `write_xaringan_theme()`.
  54. If you want to start from the default **xaringan** theme and make a few modifications, start there.
  55. 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.
  56. To override the default value of any theme functions, set the appropriate argument in the theme function.
  57. A table of all template variables is included in [`vignette("template-variables", "xaringanthemer")`](template-variables.html).
  58. As an example, try loading `xaringanthemer`, type out `duo_theme(` and then press <kbd>Tab</kbd> to see all of the theme options.
  59. 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.
  60. Here are some of the `text_` theme options:
  61. ```{r, results='asis', echo=FALSE}
  62. source(here::here("R/theme_settings.R"))
  63. tvv <- template_variables$variable
  64. cat(paste0("- `", tvv[grepl("^text_", tvv)][1:5], "`"), sep = "\n")
  65. cat("- *and more ...*")
  66. ```
  67. And here are the title slide theme options:
  68. ```{r results='asis', echo=FALSE}
  69. cat(paste0("- `", tvv[grepl("^title_slide_", tvv)], "`"), sep = "\n")
  70. ```
  71. ## Adding Custom CSS
  72. You can also add custom CSS classes using the `extra_css` argument in the theme functions.
  73. This argument takes a named list of CSS definitions each containing a named list of CSS property-value pairs.
  74. ```r
  75. extra_css <- list(
  76. ".red" = list(color = "red"),
  77. ".small" = list("font-size" = "90%"),
  78. ".full-width" = list(
  79. display = "flex",
  80. width = "100%",
  81. flex = "1 1 auto"
  82. )
  83. )
  84. ```
  85. If you would rather keep your additional css definitions in a separate file, you can call `write_extra_css()` separately.
  86. Just be sure to include your new CSS file in the list of applied files in your YAML header.
  87. ```r
  88. write_extra_css(css = extra_css, outfile = "custom.css")
  89. ```
  90. ```{r results='asis', echo=FALSE}
  91. extra_css <- list(
  92. ".red" = list(color = "red"),
  93. ".small" = list("font-size" = "90%"),
  94. ".full-width" = list(
  95. display = "flex",
  96. width = "100%",
  97. flex = "1 1 auto"
  98. )
  99. )
  100. cat(
  101. "\n```css",
  102. "/* Extra CSS */",
  103. xaringanthemer:::list2css(extra_css),
  104. "```",
  105. sep = "\n"
  106. )
  107. ```
  108. This is most helpful when wanting to define helper classes to work with the [remark.js][remarkjs] `.class[]` syntax.
  109. Using the above example, we could color text red `.red[like this]` or write `.small[in smaller font size]`.
  110. ## Fonts
  111. [adding-custom-css]: #adding-custom-css
  112. ```{r child="rmdchunks/_fonts.Rmd"}
  113. ```
  114. ```{r child="rmdchunks/_thanks.Rmd"}
  115. ```