summary refs log tree commit diff
path: root/pkgs/misc/tex
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2005-06-20 15:20:37 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2005-06-20 15:20:37 +0000
commitfe0981babd7943e8c3afcc3b2d38a732d351acff (patch)
tree57fe40d7b4daaefb44f7d9cc9833710e9b88470a /pkgs/misc/tex
parent6ce80304a5597b20e41796405700df058cfe1adb (diff)
downloadnixlib-fe0981babd7943e8c3afcc3b2d38a732d351acff.tar
nixlib-fe0981babd7943e8c3afcc3b2d38a732d351acff.tar.gz
nixlib-fe0981babd7943e8c3afcc3b2d38a732d351acff.tar.bz2
nixlib-fe0981babd7943e8c3afcc3b2d38a732d351acff.tar.lz
nixlib-fe0981babd7943e8c3afcc3b2d38a732d351acff.tar.xz
nixlib-fe0981babd7943e8c3afcc3b2d38a732d351acff.tar.zst
nixlib-fe0981babd7943e8c3afcc3b2d38a732d351acff.zip
* Scan for BibTeX files included by \bibliography.
* Automatically run BibTeX when necessary (i.e., when there are
  \citations in the aux file).

svn path=/nixpkgs/trunk/; revision=3222
Diffstat (limited to 'pkgs/misc/tex')
-rw-r--r--pkgs/misc/tex/nix/copy-includes.pl2
-rw-r--r--pkgs/misc/tex/nix/default.nix3
-rw-r--r--pkgs/misc/tex/nix/find-includes.pl8
-rw-r--r--pkgs/misc/tex/nix/run-latex.sh4
4 files changed, 12 insertions, 5 deletions
diff --git a/pkgs/misc/tex/nix/copy-includes.pl b/pkgs/misc/tex/nix/copy-includes.pl
index 57ae2d4a33d2..26a9ab916022 100644
--- a/pkgs/misc/tex/nix/copy-includes.pl
+++ b/pkgs/misc/tex/nix/copy-includes.pl
@@ -15,8 +15,6 @@ for (my $n = 0; $n < @ARGV; $n += 2) {
     my $fullPath = $ARGV[$n];
     my $relPath = $ARGV[$n + 1];
 
-    print "$fullPath <- $relPath\n";
-
     createDirs $relPath;
         
     symlink $fullPath, $relPath or die "cannot create symlink `$relPath'";
diff --git a/pkgs/misc/tex/nix/default.nix b/pkgs/misc/tex/nix/default.nix
index 73ef5e523eb4..d371014e1ff0 100644
--- a/pkgs/misc/tex/nix/default.nix
+++ b/pkgs/misc/tex/nix/default.nix
@@ -33,6 +33,9 @@ rec {
       args = [ ./find-includes.pl ];
 
       rootFile = toString rootFile; # !!! hacky
+
+      # Forces rebuilds.
+      hack = __currentTime;
     };
     
 }
\ No newline at end of file
diff --git a/pkgs/misc/tex/nix/find-includes.pl b/pkgs/misc/tex/nix/find-includes.pl
index 5be9259507d9..633f90843703 100644
--- a/pkgs/misc/tex/nix/find-includes.pl
+++ b/pkgs/misc/tex/nix/find-includes.pl
@@ -50,7 +50,13 @@ while (scalar @workset > 0) {
 	    my $fn2 = $2;
             die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";
 	    push @workset, $path . "/" . $fn2 . ".cls";
-	}
+	} elsif (/\\bibliography\{(.*)\}/) {
+            foreach my $bib (split /,/, $1) {
+                $bib =~ s/^\s+//; # remove leading / trailing whitespace
+                $bib =~ s/\s+$//;
+                push @workset, $path . "/" . $bib . ".bib";
+            }
+        }
         # !!! also support \usepackage
     }
     
diff --git a/pkgs/misc/tex/nix/run-latex.sh b/pkgs/misc/tex/nix/run-latex.sh
index 72fc8234bd0c..07db6e9c42aa 100644
--- a/pkgs/misc/tex/nix/run-latex.sh
+++ b/pkgs/misc/tex/nix/run-latex.sh
@@ -25,9 +25,9 @@ fi
 
 $latex $rootName
 
-if grep -q '\\bibitem' $rootNameBase.bbl; then
+if grep -q '\\citation' $rootNameBase.aux; then
     bibtex $rootNameBase
-fi    
+fi
 
 $latex $rootName