Skip to content

Instantly share code, notes, and snippets.

@uebayasi
Last active May 3, 2019 13:18
Show Gist options
  • Save uebayasi/198f8b82796bb750cc910712eefa7d78 to your computer and use it in GitHub Desktop.
Save uebayasi/198f8b82796bb750cc910712eefa7d78 to your computer and use it in GitHub Desktop.
rmd2pdf - Convert RMD to PDF reproducibly
#!/bin/sh
#
# rmd2pdf.sh - Convert RMD to PDF reproducibly
#
# Requirements: lualatex (TeXlive)
#
set -e
rmd=$1
tmp=$(mktemp XXXXXX)
cat <<END >$tmp
library('rmarkdown')
rmarkdown::render("$rmd")
END
cat <<END >_output.yaml
pdf_document:
toc: true
toc_depth: 2
number_sections: true
latex_engine: lualatex
pandoc_args:
- --variable
- documentclass=ltjsarticle
END
env \
SOURCE_DATE_EPOCH=0 \
FORCE_SOURCE_DATE=1 \
Rscript $tmp
rm -f $tmp _output.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment