Skip to content

Instantly share code, notes, and snippets.

@tomravalde
Last active August 29, 2015 14:14
Show Gist options
  • Save tomravalde/461c8fb704982faa8796 to your computer and use it in GitHub Desktop.
Save tomravalde/461c8fb704982faa8796 to your computer and use it in GitHub Desktop.
A shell script to build a PDF (containing version control details) from an R-markdown file, outputting a word count
sh vc # Create the version control data
Rscript knit.R # Knit the file (details below)
if [ `hostname` = "cv-tr608-01" ] # Determine which computer is being used
then
pandoc --latex-engine=xelatex --template=/home/tr608/.pandoc/templates/tom.xelatex --natbib --bibliography=/home/tr608/ImpCol/PhD/my-refs.bib -o paper.tex paper.md # Generate *.tex filer using templates and bibioligraphic data
else
pandoc --latex-engine=xelatex --template=default.latex --include-in-header=custom-local.sty --natbib -o paper.tex paper.md
fi
xelatex paper # Build PDF from *.tex source
bibtex paper
xelatex paper
xelatex paper
texcount -sub=section -html paper.tex > count.html # Word count, with section breakdown, displayed in firefox web browser
firefox count.html
if [[ `uname` == 'Darwin' ]]; # open PDF
then
open -a Preview paper.pdf
else
acroread paper.pdf
fi
# To knit the *.Rmd source into *.tex, put the following in knit.R
## library(knitr)
## knit('paper.Rmd')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment