Chapter 7 xaringan Presentation
- Get Start: https://slides.yihui.org/xaringan/#1
xaringanpackage- GitHub repo (refer to Wiki page for detailed documentation): https://github.com/yihui/xaringan
- remark.js
It is a slide template based on an HTML5 presentation framework remark.js.
Basically xaringan injected R Markdown (minus Pandoc) into remark.js. The slides are rendered by remark.js in the web browser, and the Markdown source needed by remark.js is generated from R Markdown (knitr).
You write slides in R Markdown, and then use the xaringan package to render the slides.
Features:
Interactive like html notes, but in form of slides, making it equivalent to PowerPoint, which students are more used to.
Support the choice of Google fonts.
Quote Xie, “The best fonts are always the fonts I have never used by myself.” I cannot agree more. 🤣
When you decide to use xaringan, read tutorials HERE.
To create a new xaringan presentation, you simply create a new R Markdown document and use the following YAML header:
---
title: "Presentation Ninja"
subtitle: "with xaringan"
author: "Yihui Xie"
date: "2016/12/12"
output:
xaringan::moon_reader:
css: ["xaringan-themer.css", "custom.css"]
lib_dir: libs
include:
in_header: libs/mathjax.html
nature:
highlightStyle: github
highlightLines: yes
countIncrementalSlides: false
ratio: '16:9'
---
One slide.
---
Another slide.xaringan::moon_reader is the main R Markdown output format in the xaringan package.
See the R help page ?xaringan::moon_reader for all possible configurations.
Configurations:
lib_dir: The directory to save the dependencies (e.g. jquery, bootstrap, etc.) of the slides.This is an argument passed to
rmarkdown::html_document. See the help page?rmarkdown::html_documentfor additional configurations provided byhtml_document.- By default this will be the name of the document with
_filesappended to it. - Here I set it to be
libs.
- By default this will be the name of the document with
includes: Named list of additional content to include within the document (typically created using theincludesfunction).in_header: Vector of file paths to be included in the document header (inside the<head>tag). Note that paths should be in quotation marks.before_body: Vector of file paths to be included immediately after the opening<body>tag.after_body: Vector of file paths h to be included immediately before the closing</body>tag.
Include multiple files by passing a vector of file paths.
includes: in_header: ["libs/mathjax.html", "libs/in_header.html"] after_body: ["theme/example-numbering.html", "libs/after_body.html"]Alternatively, use YAML list indentation with
-for each file:includes: in_header: - libs/mathjax.html - libs/in_header.html after_body: - theme/example-numbering.html - libs/after_body.htmlEach list item is treated as a separate file path.
nature: (Nature transformation) A list of configurations to be passed toremark.create(), e.g.list(ratio = '16:9', navigation = list(click = TRUE)).See Wiki page of
remark.jsfor all possible configurations.