Build xaringan slides to multiple output formats:
Some output types depend on intermediate outputs. Here is a diagram of the build hierarchy:
You can build all of the examples below from here
All build_*()
functions use the input
and output_file
arguments.
The input
argument is required and can be a full or local path to the input file.
The output_file
argument is optional. If provided, it can be a full or local path to the output file, and it must end in an appropriate extension (e.g. slides.gif
for build_gif()
). If it is not provided, the output file name will be determined based on the input
argument.
Input can be a Rmd file, html file, or url:
build_pdf("slides.Rmd")
build_pdf("slides.html")
build_pdf("https://jhelvy.github.io/xaringanBuilder/reference/figures/slides.html")
Note: Building the PDF requires a local installation of Google Chrome
Input can be a Rmd file, html file, pdf file, or url:
build_gif("slides.Rmd")
build_gif("slides.html")
build_gif("slides.pdf")
build_gif("https://jhelvy.github.io/xaringanBuilder/reference/figures/slides.html")
Example:
Creates a pptx file where each slide contains a png image of each xaringan slide. While you won’t be able to edit the xaringan content from Powerpoint, you can at least annotate it.
(See the slidex package by @datalorax to do the opposite: pptx –> xaringan!)
Input can be a Rmd file, html file, pdf file, or url:
Build png image(s) of some or all slides. Use the slides
argument to determine which slides to include (defaults to 1
, returning just the first slide) .
Input can be a Rmd file, html file, pdf file, or url:
# By default, creates a png of only the first slide:
build_png("slides.Rmd")
build_png("slides.html")
build_png("slides.pdf")
build_png("https://jhelvy.github.io/xaringanBuilder/reference/figures/slides.html")
# Build zip file of multiple or all slides
build_png("slides.pdf", slides = c(1, 3, 5))
build_png("slides.pdf", slides = "all")
Example:
Use build_all()
to build all output types from a Rmd file:
Use the include
or exclude
arguments to control which output types to include or exclude:
“Complex” slides are slides that contain panelsets or other html widgets / advanced features that might not render well as a pdf. To render these on each slide, set complex_slides = TRUE
.
If you want to build a new slide for each increment on incremental slides, set partial_slides = TRUE
.
These options are available as options in any of the functions that depend on building the pdf:
Note: These options require the chromote and pdftools packages.
Building the PDF requires a local installation of Chrome. If you don’t have Chrome installed, you can use other browsers based on Chromium, such as Chromium itself, Edge, Vivaldi, Brave, or Opera. In this case, you will need to set the path to the browser you want to use for the pagedown package as well as the chromote package if you use the complex_slides = TRUE
or partial_slides = TRUE
arguments.
After installing the packages, you can set the paths like this:
If you are unable to install Chrome (e.g. on a computing cluster), the recommended workflow is to build intermediate output formats and use an alternative method for building the PDF.
For example, to build a pptx from a Rmd file without Chrome, you could:
build_html("slides.Rmd")
build_pptx("slides.pdf")
If you use this package in a publication, I would greatly appreciate it if you cited it. You can get the citation information by typing citation("xaringanBuilder")
into R:
To cite xaringanBuilder in publications use:
John Paul Helveston (2021). xaringanBuilder: Functions for building xaringan slides to different outputs.
A BibTeX entry for LaTeX users is
@Manual{, title = {xaringanBuilder: Functions for building xaringan slides to different outputs.}, author = {John Paul Helveston}, year = {2021}, note = {R package version 0.0.6}, url = {https://jhelvy.github.io/xaringanBuilder/}, }