diff --git a/pkgs/misc/tex/nix/find-includes.pl b/pkgs/misc/tex/nix/find-includes.pl index 8b396fef38da..6f3afcdaa040 100644 --- a/pkgs/misc/tex/nix/find-includes.pl +++ b/pkgs/misc/tex/nix/find-includes.pl @@ -27,7 +27,7 @@ while (scalar @workset > 0) { $doneset{$fn} = 1; if (!open FILE, "< $fn") { - print STDERR "(cannot open $fn, ignoring)\n"; +# print STDERR "(cannot open $fn, ignoring)\n"; next; }; diff --git a/pkgs/misc/tex/nix/run-latex.sh b/pkgs/misc/tex/nix/run-latex.sh index b36df234df1c..aa95b432fc1d 100644 --- a/pkgs/misc/tex/nix/run-latex.sh +++ b/pkgs/misc/tex/nix/run-latex.sh @@ -13,7 +13,6 @@ for i in $extraFiles; do done rootName=$(basename $(stripHash "$rootFile"; echo $strippedName)) -echo "root name is $rootName" rootNameBase=$(echo "$rootName" | sed 's/\..*//') @@ -21,22 +20,67 @@ if test -n "$generatePDF"; then latex=pdflatex else latex=latex -fi - -$latex $rootName - -if grep -q '\\citation' $rootNameBase.aux; then - bibtex $rootNameBase fi -$latex $rootName +latexFlags="-file-line-error" +tmpFile=$out/log -makeindex $rootNameBase.idx +showError() { + echo + echo "LATEX ERROR (LAST LOG LINES SHOWN):" + tail -n 20 $tmpFile + exit 1 +} -$latex $rootName +runLaTeX() { +if ! $latex $latexFlags $rootName >$tmpFile 2>&1; then showError; fi +} +echo + +echo "PASS 1..." +runLaTeX +echo + +if grep -q '\\citation' $rootNameBase.aux; then + echo "RUNNING BIBTEX..." + bibtex --terse $rootNameBase + echo +fi + +echo "PASS 2..." +runLaTeX +echo + +if test -f $rootNameBase.idx; then + echo "MAKING INDEX..." + makeindex $rootNameBase.idx + echo +fi + +echo "PASS 3..." +runLaTeX +echo if test -n "$generatePDF"; then cp $rootNameBase.pdf $out else cp $rootNameBase.dvi $out fi + +echo "OVERFULL/UNDERFULL:" +cat $tmpFile | egrep "Overfull|Underfull" || true + +echo +echo "UNDEFINED REFERENCES:" +cat $tmpFile | grep "Reference.*undefined" || true + +echo +echo "UNDEFINED CITATIONS:" +cat $tmpFile | grep "Citation.*undefined" || true + +echo +echo "STATS:" +printf "%5d overfull/underfull h/vboxes\n" $(cat $tmpFile | egrep -c "Overfull|Underfull" || true) +printf "%5d undefined references\n" $(cat $tmpFile | grep -c "Reference.*undefined" || true) +printf "%5d undefined citations\n" $(cat $tmpFile | grep -c "Citation.*undefined" || true) +echo