|
|
6 anos atrás | |
|---|---|---|
| R | 6 anos atrás | |
| inst | 6 anos atrás | |
| man | 6 anos atrás | |
| man-roxygen | 6 anos atrás | |
| pkgdown | 6 anos atrás | |
| tests | 6 anos atrás | |
| vignettes | 6 anos atrás | |
| .Rbuildignore | 6 anos atrás | |
| .gitignore | 6 anos atrás | |
| .travis.yml | 6 anos atrás | |
| DESCRIPTION | 6 anos atrás | |
| LICENSE | 8 anos atrás | |
| LICENSE.md | 8 anos atrás | |
| NAMESPACE | 6 anos atrás | |
| NEWS.md | 6 anos atrás | |
| README.Rmd | 6 anos atrás | |
| README.md | 6 anos atrás | |
| appveyor.yml | 6 anos atrás | |
| index.Rmd | 6 anos atrás | |
| make.R | 6 anos atrás | |
| tic.R | 6 anos atrás | |
| xaringanthemer.Rproj | 8 anos atrás | |
Give your xaringan
slides some style with xaringanthemer within your
slides.Rmd file without (much) CSS.

You can install xaringanthemer from CRAN
or you can install the development version of xaringanthemer from GitHub.
First, add the xaringan-themer.css file to the YAML
header of your xaringan slides.
Then, in a hidden chunk just after the knitr setup chunk, load xaringanthemer and try one of the theme functions.
```{r xaringan-themer, include = FALSE}
library(xaringanthemer)
style_mono_light(
base_color = "#1c5253",
header_font_google = google_font("Josefin Sans"),
text_font_google = google_font("Montserrat", "300", "300i"),
code_font_google = google_font("Droid Mono")
)
```
xaringanthemer is Tab friendly – use autocomplete to explore the template variables that you can adjust in each of the themes!

You can also skip the above and just create a Ninja Themed Presentation from the New R Markdown Document menu in RStudio.

Use these functions to automatically create a consistent color palette for your slides, based around a single color.
style_mono_light()A light theme based around a single color.

style_mono_dark()A dark theme based around a single color.

style_mono_accent()The default xaringan theme with a single color used for color accents on select elements (headers, bold text, etc.).

style_mono_accent_inverse()An “inverted” default xaringan theme with a single color used for color accents on select elements (headers, bold text, etc.).

These themes build from two (ideally) complementary colors.
style_duo()A two-colored theme based on a primary and secondary color.

style_duo_accent()The default Xaringan theme with two accent colors.

style_duo_accent_inverse()An “inverted” default Xaringan theme with two accent colors.

There are also two themes based around the solarized color palette,
style_solarized_light() and
style_solarized_dark(). For both themes, it is advisted to
change the syntax highlighting theme to solarized-light or
solarized-dark (looks great paired or constrasted).
style_solarized_light()
style_solarized_dark()
To do this, your YAML header should look more-or-less like this:
output:
xaringan::moon_reader:
lib_dir: libs
css: ["xaringan-themer.css"]
nature:
highlightStyle: solarized-dark
highlightLines: true
countIncrementalSlides: falseThe theme functions listed above are just wrappers around the central
function of this package, style_xaringan(). If you want to
start from the default xaringan theme and make a few
modifications, start there.
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. To override the default
value of any theme functions, set the appropriate argument in the theme
function. A table of all template variables is included in vignette("template-variables", "xaringanthemer").
As an example, try loading xaringanthemer, type out
duo_theme( and then press Tab to see all of the
theme options.
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.
Here are some of the text_ theme options:
text_colortext_bold_colortext_slide_number_colortext_font_sizetext_slide_number_font_sizeAnd here are the title slide theme options:
title_slide_text_colortitle_slide_background_colortitle_slide_background_imagetitle_slide_background_sizetitle_slide_background_positionYou can also add custom CSS classes using the extra_css
argument in the theme functions. This argument takes a named list of CSS
definitions each containing a named list of CSS property-value
pairs.
extra_css <- list(
".red" = list(color = "red"),
".small" = list("font-size" = "90%"),
".full-width" = list(
display = "flex",
width = "100%",
flex = "1 1 auto"
)
)If you would rather keep your additional css definitions in a
separate file, you can call style_extra_css() separately.
Just be sure to include your new CSS file in the list of applied files
in your YAML header.
/* Extra CSS */
.red {
color: red;
}
.small {
font-size: 90%;
}
.full-width {
display: flex;
width: 100%;
flex: 1 1 auto;
}This is most helpful when wanting to define helper classes to work
with the remark.js
.class[] syntax. Using the above example, we could color
text red .red[like this] or write
.small[in smaller font size].
Yihui picked out great fonts for the default xaringan theme, but sometimes you want something new and interesting.
xaringanthemer makes it easy to use Google Fonts in your presentations (well, as long as you have an internet connection) or to fully specify your font files.
To use Google Fonts, set the
_font_google theme arguments –
text_font_google, header_font_google,
code_font_google — using the google_font()
helper. See ?google_font for more info.
style_mono_light(
header_font_google = google_font("Josefin Slab", "600"),
text_font_google = google_font("Work Sans", "300", "300i"),
code_font_google = google_font("IBM Plex Mono")
)If you set an xxx_font_google theme arguments, then
xxx_font_family, xxx_font_weight and
xxx_font_url are overwritten – where xxx in
{header, text, code}. Of course, you can manually set
header_font_url, etc., and ignore the
header_font_google argument.
For example, suppose you want to use a ligature font for the code
font, such as Fira
Code. Just set code_font_family and
code_font_url!
style_solarized_dark(
code_font_family = "Fira Code",
code_font_url = "https://cdn.rawgit.com/tonsky/FiraCode/1.204/distr/fira_code.css"
)If you need to import additional fonts for use in custom CSS definitions, you can use the
extra_fonts argument to pass a list of URLs or
google_font()s.
style_mono_light(
extra_fonts = list(google_font("Sofia")),
extra_css = list(".title-slide h2" = list("font-family" = "Sofia"))
)xaringanthemer was built by Garrick Aden-Buie (@grrrck).
Big thank you to Yihui Xie, especially for xaringan. Also thanks to Ole Petter Bang for remark.js.
Feel free to file an issue if you find a bug or have a theme suggestion – or better yet, submit a pull request!