diff --git a/slides/build.sh b/slides/build.sh index f54e3b6497b4fca2ade085934f0402163d4d73cc..f385873a97b7587ef6a6a76efb49061dac02979b 100644 --- a/slides/build.sh +++ b/slides/build.sh @@ -1,18 +1,47 @@ +#----------------------------------------------------------------------- + if [ "$1" = "-h" ]; then echo 'Usage:' echo ' $1: filename without extension, e.g. `slides`.' + echo ' if $1 is -h, then shows this message.' + echo ' if $1 is --all, then compiles all Rnw files.' echo ' $2: {0, 1}, remove LaTeX auxiliary files (.log, .aux, ...).' -else - FILENAME=$1 - echo "\nConverting Rnw to tex.\n" - knit $FILENAME.Rnw - echo "\nConverting tex to PDF.\n" - pdflatex $FILENAME.tex + exit 0 +fi + +#----------------------------------------------------------------------- + +if [ "$1" = "--all" ]; then + RNWFILES=$(ls *.Rnw) + echo $RNWFILES + for RNW in $RNWFILES; do + FILE="${RNW%.*}" + echo $FILE + Rscript -e "require(knitr); knit(\"$RNW\")" + pdflatex $FILE + pdflatex $FILE + pdflatex $FILE + rubber --clean $FILE + done + exit 0 fi +#----------------------------------------------------------------------- + +RNW=$1 +FILE="${RNW%.*}" +echo "\nConverting Rnw to tex.\n" +knit $RNW +echo "\nConverting tex to PDF.\n" +pdflatex $FILE + if [ "$#" -eq 2 ]; then if [ "$2" -eq 1 ]; then echo "\nDeleting LaTeX auxiliary files.\n" - rubber --clean $FILENAME + rubber --clean $FILE fi fi + +exit 0 + +#-----------------------------------------------------------------------