summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2011-03-26 00:14:28 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2011-03-26 00:14:28 +0000
commit20912b654bd125c0c33ba78f04d4001e3d1a059d (patch)
tree84eb506871d0999999238fa9ff3ab92c668bda05
parentaf5952eb0b75956b92dfd21df1660a1a84c4c81a (diff)
downloadnixpkgs-20912b654bd125c0c33ba78f04d4001e3d1a059d.tar
nixpkgs-20912b654bd125c0c33ba78f04d4001e3d1a059d.tar.gz
nixpkgs-20912b654bd125c0c33ba78f04d4001e3d1a059d.tar.bz2
nixpkgs-20912b654bd125c0c33ba78f04d4001e3d1a059d.tar.lz
nixpkgs-20912b654bd125c0c33ba78f04d4001e3d1a059d.tar.xz
nixpkgs-20912b654bd125c0c33ba78f04d4001e3d1a059d.tar.zst
nixpkgs-20912b654bd125c0c33ba78f04d4001e3d1a059d.zip
* runLaTeX: detect the existence of a pre-generated .bbl file and use
  it.  Useful if you're supposed to stick a \balancecolumns in the
  middle of the file.

svn path=/nixpkgs/trunk/; revision=26522
-rw-r--r--pkgs/misc/tex/nix/default.nix2
-rw-r--r--pkgs/misc/tex/nix/find-includes.pl1
-rw-r--r--pkgs/misc/tex/nix/run-latex.sh12
3 files changed, 10 insertions, 5 deletions
diff --git a/pkgs/misc/tex/nix/default.nix b/pkgs/misc/tex/nix/default.nix
index ec09318979f..f5a34fb67a2 100644
--- a/pkgs/misc/tex/nix/default.nix
+++ b/pkgs/misc/tex/nix/default.nix
@@ -53,7 +53,7 @@ rec {
           # The type denotes the kind of dependency, which determines
           # what extensions we use to look for it.
           deps = import (pkgs.runCommand "latex-includes"
-            { src = key; }
+            { rootFile = baseNameOf (toString rootFile); src = key; }
             "${pkgs.perl}/bin/perl ${./find-includes.pl}");
 
           # Look for the dependencies of `key', trying various
diff --git a/pkgs/misc/tex/nix/find-includes.pl b/pkgs/misc/tex/nix/find-includes.pl
index 6441f18855b..41675e939f6 100644
--- a/pkgs/misc/tex/nix/find-includes.pl
+++ b/pkgs/misc/tex/nix/find-includes.pl
@@ -45,6 +45,7 @@ while (<FILE>) {
             $bib =~ s/^\s+//; # remove leading / trailing whitespace
             $bib =~ s/\s+$//;
             addName "misc", "$bib.bib";
+            addName "misc", (basename($ENV{"rootFile"}, ".tex", ".ltx") . ".bbl");
         }
     } elsif (/\\includegraphics(\[.*\])?\{(.*)\}/) {
         my $fn2 = $2;
diff --git a/pkgs/misc/tex/nix/run-latex.sh b/pkgs/misc/tex/nix/run-latex.sh
index 58c7cac302f..6c18721eed6 100644
--- a/pkgs/misc/tex/nix/run-latex.sh
+++ b/pkgs/misc/tex/nix/run-latex.sh
@@ -68,11 +68,15 @@ for auxFile in $(find . -name "*.aux"); do
     # Run bibtex to process all bibliographies.  There may be several
     # when we're using the multibib package.
     if grep -q '\\citation' $auxFile; then
-        echo "RUNNING BIBTEX ON $auxFile..."
         auxBase=$(basename $auxFile .aux)
-        bibtex --terse $auxBase
-        cp $auxBase.bbl $out
-        runNeeded=1
+        if [ -e $auxBase.bbl ]; then
+            echo "SKIPPING BIBTEX ON $auxFile!"
+        else
+            echo "RUNNING BIBTEX ON $auxFile..."
+            bibtex --terse $auxBase
+            cp $auxBase.bbl $out
+            runNeeded=1
+        fi
         echo
     fi