summary refs log tree commit diff
path: root/pkgs/tools/typesetting
diff options
context:
space:
mode:
authoriko <ilyakooo0@gmail.com>2020-11-27 20:32:29 +0300
committerGitHub <noreply@github.com>2020-11-27 12:32:29 -0500
commiteb7d36720048f6df6f830ab61f143f823b43e073 (patch)
treed3bf7d323d69a9ca97a9887cc851fd05ace29915 /pkgs/tools/typesetting
parentf5edf8aedb9468ee01f849b407b79c6e953b836d (diff)
downloadnixpkgs-eb7d36720048f6df6f830ab61f143f823b43e073.tar
nixpkgs-eb7d36720048f6df6f830ab61f143f823b43e073.tar.gz
nixpkgs-eb7d36720048f6df6f830ab61f143f823b43e073.tar.bz2
nixpkgs-eb7d36720048f6df6f830ab61f143f823b43e073.tar.lz
nixpkgs-eb7d36720048f6df6f830ab61f143f823b43e073.tar.xz
nixpkgs-eb7d36720048f6df6f830ab61f143f823b43e073.tar.zst
nixpkgs-eb7d36720048f6df6f830ab61f143f823b43e073.zip
runLaTeX: rerun at least twice + refactor (#104185)
Building a simple LaTeX document without bibTeX with a table of contents yielded a document with an empty table of contents since LaTeX was only run once
Diffstat (limited to 'pkgs/tools/typesetting')
-rw-r--r--pkgs/tools/typesetting/tex/nix/run-latex.sh25
1 files changed, 11 insertions, 14 deletions
diff --git a/pkgs/tools/typesetting/tex/nix/run-latex.sh b/pkgs/tools/typesetting/tex/nix/run-latex.sh
index 7a5767f9c06..3f8a16580ea 100644
--- a/pkgs/tools/typesetting/tex/nix/run-latex.sh
+++ b/pkgs/tools/typesetting/tex/nix/run-latex.sh
@@ -41,7 +41,11 @@ showError() {
     exit 1
 }
 
+pass=0
+
 runLaTeX() {
+    ((pass=pass+1))
+    echo "PASS $pass..."
     if ! $latex $latexFlags $rootName >$tmpFile 2>&1; then showError; fi
     runNeeded=
     if fgrep -q \
@@ -51,6 +55,7 @@ runLaTeX() {
         "$tmpFile"; then
         runNeeded=1
     fi
+    echo
 }
 
 echo
@@ -61,10 +66,7 @@ if test -n "$copySources"; then
 fi
 
 
-echo "PASS 1..."
 runLaTeX
-echo
-
 
 for auxFile in $(find . -name "*.aux"); do
     # Run bibtex to process all bibliographies.  There may be several
@@ -89,11 +91,8 @@ for auxFile in $(find . -name "*.aux"); do
     fi
 done
 
-
 if test "$runNeeded"; then
-    echo "PASS 2..."
     runLaTeX
-    echo
 fi
 
 
@@ -105,20 +104,18 @@ if test -f $rootNameBase.idx; then
     makeindex $makeindexFlags $rootNameBase.idx
     runNeeded=1
     echo
-fi    
-
+fi
 
-if test "$runNeeded"; then
-    echo "PASS 3..."
+# We check that pass is less than 2 to catch situations where the document is
+# simple enough (no bibtex, etc.) so that it would otherwise require only one
+# pass but also contains a ToC.
+# In essence this check ensures that we do at least two passes on all documents.
+if test "$runNeeded" = 1 -o "$pass" -lt 2 ; then
     runLaTeX
-    echo
 fi
 
-
 if test "$runNeeded"; then
-    echo "PASS 4..."
     runLaTeX
-    echo
 fi