#!/bin/sh # by Nick (with some input from Davide) - v. 3.6 - Dec 2023 # usage: latexcontinuo [options] file.tex # keeps upgraded the file.pdf # just save from your $EDITOR and the thing compiles by itself # -h : print this help case $# in 0) head -6 $0 1>&2 exit 1 esac dvioptions="-z -Ppdf -G0" pdfoption="y" pdflatexoptions="-halt-on-error -file-line-error -synctex=1" sleeptime=2 # waiting time after successful compilation sleeperror=6 # waiting longer in case compilation fails with some error for i in $* do case $i in -h) head $0; exit;; *) name=$i esac done # -l) dvioptions=$dvioptions" -t landscape";; # -p) pdfoption="n";; name=`basename $name .tex` dirn=`dirname $name` f="$dirn/$name.tex" log_file="$dirn/$name.log" pdf_file="$dirn/$name.pdf" #unwanted="$dirn/$name.nav" # will keep these file(s) empty run_latex () { pdflatex $pdflatexoptions "$f" < /dev/null returnvalue=$? # cp /dev/null $unwanted if grep "Rerun to get cross-references right" "$log_file" > /dev/null then run_latex fi return $returnvalue } if (test -n $f) then echo " LaTex source: $f target: $pdf_file" iter=0 while test $iter -le 10000 # latexcontinuo stops after a while... do sync # may be useful when working on a NFS if test `ls -t $f $log_file | head -1` = $f ; then if(run_latex) then sleep $sleeptime else sleep $sleeperror fi iter=0 else sleep $sleeptime # the latency time in seconds fi iter=`expr $iter + 1` done else echo "file $f not found" fi