Skip to content

Instantly share code, notes, and snippets.

@FavioVazquez
Forked from btbytes/.gitignore
Last active August 29, 2015 14:17
Show Gist options
  • Save FavioVazquez/12741fd02567e67ef505 to your computer and use it in GitHub Desktop.
Save FavioVazquez/12741fd02567e67ef505 to your computer and use it in GitHub Desktop.
Great gist to make pdf of your slidify presentations. This is a fork of a fork from Ramnath Vaidyanathan. Is important that you copy the makefile exactly as it is in here. If that does't work, instead of copying the spaces, make tabs.
*.md
*.html
*.pdf
libraries

Creating PDF versions of slidify presentations

This gist consists of a makefile and a script that can automate the creation of PDFs from Slidify generated HTML slides. The script assumes that the makefile and the script makepdf.js are in the same directory as the Rmd file. The makepdf.js script uses casperjs, a very useful utility to automate tasks that require browser interaction. You may follow the installation instructions on the casperjs website, to make sure that you have all the dependencies correctly installed before trying this out.

Installing dependencies

To install the R packages:

# install devtools if you haven't already
# install.packages('devtools')
pkgs <- c("slidify", "slidifyLibraries", "rCharts")
install_github(pkgs, 'ramnathv', ref = 'dev')

To install casperjs 1.1 (as casperjs 1.0.x does not work with phantomjs versions >= 1.9.0) [on a mac with brew]:

brew install casperjs --devel
---
title :
subtitle :
author :
job :
framework : io2012 # {io2012, html5slides, shower, dzslides, ...}
highlighter : highlight.js # {highlight.js, prettify, highlight}
hitheme : tomorrow #
widgets : [] # {mathjax, quiz, bootstrap}
mode : selfcontained # {standalone, draft}
---
## Read-And-Delete
1. Edit YAML front matter
2. Write using R Markdown
3. Use an empty line followed by three dashes to separate slides!
--- .class #id
## Slide 2
DELAY = 1000
RMD_FILE = $(wildcard *.Rmd)
HTML_FILE = $(patsubst %.Rmd, %.html, $(RMD_FILE))
PDF_FILE = $(patsubst %.Rmd, %.pdf, $(RMD_FILE))
pdf: $(PDF_FILE)
html: $(HTML_FILE)
all: $(PDF_FILE) $(HTML_FILE)
%.pdf: %.html
casperjs makepdf.js $< $@ $(DELAY)
%.html: %.Rmd
cd $(dir $<) && Rscript -e "slidify::slidify('index.Rmd')" && cd ..
clean:
rm -rf libraries
rm -r $(PDF_FILE)
rm -r $(HTML_FILE)
.PHONY: clean
var casper = require('casper').create({viewportSize:{width:1500,height:1000}});
var args = casper.cli.args;
var imgfile = (args[1] || Math.random().toString(36).slice(2))
casper.start(args[0], function() {
this.wait(args[2], function(){
this.captureSelector(imgfile, "slides");
});
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment