ThemedPresentations.Rmd
The docs/
folder of the package includes an
.Rmd
called xaringan_themer.Rmd
that allows
you to create a themed xaringan presentation. The themer uses the
nmfspalette
package to source the colors for text,
background, and footnotes and then the xaringanthemer
package to apply the formatting to slides without having to write
CSS.
The xaringanthemer
package is needed to use this
template code. Custom theme settings can be modified using the
style_xaringan()
function. In general, the arguments to
style_xaringan
follow CSS property naming style
and syntax. You don’t need to know CSS to use it, but it can be helpful.
The style_xaringan()
function generates a .css file called
xaringan_themer.css
that you will need to add into the
First, we will look at the arguments to change colors of text and
backgrounds, which all end in _color
. The following code
changes the background, text, footnote, link, and code highlight color
to match NOAA Fisheries theming.
style_xaringan(
title_slide_background_color = unname(nmfs_cols("darkblue")),
title_slide_text_color = unname(nmfs_cols("supltgray")),
background_color = unname(nmfs_cols("white")),
text_color = unname(nmfs_cols("darkblue")),
header_color = unname(nmfs_cols("darkblue")),
inverse_background_color = unname(nmfs_cols("processblue")),
inverse_text_color = unname(nmfs_cols("supltgray")),
footnote_color = unname(nmfs_cols("darkblue")),
link_color = unname(nmfs_cols("medteal")),
text_slide_number_color = unname(nmfs_cols("lightteal")),
code_highlight_color = unname(nmfs_cols("medteal"))
)
#> Warning: Colors that will be used by `theme_xaringan()` need to be in
#> hexadecimal format: text_color, header_color
To change fonts, we use the arguments ending in
_font_google
. To change the font size, use the arguments
ending _font_size
. We also change the footnote position
using the footnote_position_bottom
argument. You can
provide the font size in em or px units. Font
arguments need to be wrapped in google_font()
or
xaringanthemer_font_default
wrappers. If you plan to use
Google fonts, search for names on the web to find fonts similar to your
choice - searching for “Calibri Google font” yielded their equivalent:
“Carlito”.
style_xaringan(
header_font_google = google_font("Arimo"),
text_font_google = google_font("Carlito", "300", "300i"),
code_font_google = google_font("Source Code Pro"),
footnote_font_size = "0.6em",
footnote_position_bottom = "10px",
text_slide_number_font_size = "0.6em"
)
# Find package directory
images_path <- system.file("static", package = "nmfspalette")
style_xaringan(
background_image = file.path(images_path, "slideswoosh.PNG"),
background_size = "cover",
title_slide_background_image = file.path(images_path, "slideswooshver.png"),
title_slide_background_size = "cover"
)