Last active
August 29, 2015 14:08
-
-
Save air-drummer/18a7899cfce85398fc3f to your computer and use it in GitHub Desktop.
latexmk engine + knitr (Mac OS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#There isn't a built-in engine for knitr, but it's easy to make one. | |
#The engine itself is just a shell script. Here's my belt-and-braces version that believes you are on a unix machine | |
#but doubts that your paths are set up properly: | |
#!/bin/bash | |
export PATH=$PATH:/usr/texbin:/usr/local/bin | |
if (Rscript -e "library(knitr); knit('$1')") then | |
latexmk -pdf "${1%.*}" | |
fi | |
#In brief, this tries to run the R code in double quotes on the first argument ($1) which is the name of the .Rnw file. | |
#If this succeeds then the transformation from latex+R to pure latex must have been successful, so we can call latexmk on the | |
#resulting file. latexmk runs latex, then biber, then latex, then latex again, then... until all the citations are cited, | |
#the contents are tabled, and all the cross references are happy again. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment