From 705c93e61f0b8e433011a588e3da8a658ea9b931 Mon Sep 17 00:00:00 2001 From: Luca Venturini Date: Fri, 15 Jan 2016 11:01:53 +0100 Subject: [PATCH] Add --latex option --- git-latexdiff | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/git-latexdiff b/git-latexdiff index 408ec0b..505b0af 100755 --- a/git-latexdiff +++ b/git-latexdiff @@ -73,6 +73,7 @@ Options: --help this help message --main name of the main LaTeX file --no-view don't display the resulting PDF file + --latex run latex instead of pdflatex --bibtex, -b run bibtex as well as latex (pdflatex,bibtex,pdflatex,pdflatex) --biber run BibLaTex-Biber as well as latex @@ -175,6 +176,8 @@ latexpand=() workingdir=() bbl=0 latexdiff_flatten=0 +latex=0 + while test $# -ne 0; do case "$1" in @@ -229,6 +232,9 @@ while test $# -ne 0; do "-b"|"--bibtex") bibtex=1 ;; + "--latex") + latex=1 + ;; "--biber") biber=1 ;; @@ -361,6 +367,12 @@ if test $flatten = 1 && flatten=0 fi +if test $latex = 1; then + LATEX_EXEC=latex +else + LATEX_EXEC=pdflatex +fi + ## end option parsing ## check_knitr () { @@ -506,7 +518,7 @@ if test "$flatten" = 1; then verbose "Attempting to regenerate missing new/$maindir$mainbase.bbl" ( cd new/"$maindir" - log_cmd pdflatex0.log pdflatex $latexopt "$mainbase" || compile_error=1 + log_cmd pdflatex0.log $LATEX_EXEC $latexopt "$mainbase" || compile_error=1 log_cmd bibtex0.log bibtex "$mainbase" || compile_error=1 ) if [ "$compile_error" = 1 ]; then @@ -564,15 +576,15 @@ else else latexopt="$latexopt -interaction=errorstopmode" fi - log_cmd pdflatex1.log pdflatex $latexopt "$mainbase" || compile_error=1 + log_cmd pdflatex1.log $LATEX_EXEC $latexopt "$mainbase" || compile_error=1 if test "$bibtex" = 1 ; then log_cmd bibtex.log bibtex "$mainbase" || compile_error=1 fi if test "$biber" = 1 ; then log_cmd biber.log biber "$mainbase" || compile_error=1 fi - log_cmd pdflatex2.log pdflatex $latexopt "$mainbase" || compile_error=1 - log_cmd pdflatex3.log pdflatex $latexopt "$mainbase" || compile_error=1 + log_cmd pdflatex2.log $LATEX_EXEC $latexopt "$mainbase" || compile_error=1 + log_cmd pdflatex3.log $LATEX_EXEC $latexopt "$mainbase" || compile_error=1 fi verbose_done @@ -582,6 +594,11 @@ if [ "$compile_error" = 1 ] && [ "$ignorelatexerrors" = 1 ]; then compile_error=0 fi +if test $latex = 1; then + dvips "$mainbase".dvi + ps2pdf "$mainbase".ps +fi + pdffile="$mainbase".pdf if test ! -r "$pdffile" ; then echo "No PDF file generated."