moon_reader: An R Markdown output format for remark.js slides

Description Usage Arguments Details Note References Examples

View source: R/render.R


This output format produces an HTML file that contains the Markdown source (knitted from R Markdown) and JavaScript code to render slides. tsukuyomi() is an alias of moon_reader().


moon_reader(css = c("default", "default-fonts"),
  self_contained = FALSE, seal = TRUE, yolo = FALSE,
  chakra = "",
  nature = list(), ...)




A vector of CSS file paths. Two default CSS files (‘default.css’ and ‘default-fonts.css’) are provided in this package, which was borrowed from If the character vector css contains a value that does not end with .css, it is supposed to be a built-in CSS file in this package, e.g., for css = c('default', 'extra.css')), it means default.css in this package and a user-provided extra.css. To find out all built-in CSS files, use xaringan:::list_css().


Whether to produce a self-contained HTML file.


Whether to generate a title slide automatically using the YAML metadata of the R Markdown document (if FALSE, you should write the title slide by yourself).


Whether to insert the Mustache Karl (TM) randomly in the slides. TRUE means insert his picture on one slide, and if you want him to be on multiple slides, set yolo to a positive integer or a percentage (e.g. 0.3 means 30% of your slides will be the Mustache Karl). Alternatively, yolo can also be a list of the form list(times = n, img = path): n is the number of times to show an image, and path is the path to an image (by default, it is Karl).


A path to the remark.js library (can be either local or remote).


(Nature transformation) A list of configurations to be passed to remark.create(), e.g. list(ratio = '16:9', navigation = list(click = TRUE)); see Besides the options provided by remark.js, you can also set autoplay to a number (the number of milliseconds) so the slides will be played every autoplay milliseconds. You can also set countdown to a number (the number of milliseconds) to include a countdown timer on each slide. If using autoplay, you can optionally set countdown to TRUE to include a countdown equal to autoplay. To alter the set of classes applied to the title slide, you can optionally set titleSlideClass to a vector of classes; the default is c("center", "middle", "inverse").


For tsukuyomi(), arguments passed to moon_reader(); for moon_reader(), arguments passed to rmarkdown::html_document().


Tsukuyomi is a genjutsu to trap the target in an illusion on eye contact.

If you are unfamiliar with CSS, please see the xaringan wiki on Github providing CSS slide modification examples.


Do not stare at Karl's picture for too long after you turn on the yolo mode. I believe he has Sharingan.

Local images that you inserted via the Markdown syntax ![](path/to/image) will not be embedded into the HTML file when self_contained = TRUE (only CSS, JavaScript, and R plot files will be embedded). You may also download remark.js (via summon_remark()) and use a local copy instead of the default chakra argument when self_contained = TRUE, because it may be time-consuming for Pandoc to download remark.js each time you compile your slides.

Each page has its own countdown timer (when the option countdown is set in nature), and the timer is (re)initialized whenever you navigate to a new page. If you need a global timer, you can use the presenter's mode (press P).



# rmarkdown::render('foo.Rmd', 'xaringan::moon_reader')

Example output

xaringan documentation built on Oct. 31, 2019, 1:05 a.m.