From 20912b654bd125c0c33ba78f04d4001e3d1a059d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat, 26 Mar 2011 00:14:28 +0000 Subject: [PATCH] * 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 --- pkgs/misc/tex/nix/default.nix | 2 +- pkgs/misc/tex/nix/find-includes.pl | 1 + pkgs/misc/tex/nix/run-latex.sh | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkgs/misc/tex/nix/default.nix b/pkgs/misc/tex/nix/default.nix index ec09318979f5..f5a34fb67a2c 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 6441f18855b7..41675e939f60 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 58c7cac302f0..6c18721eed6b 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