Created
February 15, 2012 14:12
-
-
Save lucas-clemente/1835987 to your computer and use it in GitHub Desktop.
Latex wrapper for bibtex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
# Save to pdflatex to ~/bin/pdflatex | |
if ARGV.length == 0 | |
puts "Usage: texify <file.tex> <tex options>" | |
exit 1 | |
end | |
file = ARGV.select{|v| v =~ /.*\.tex/}[0] | |
latex = "/usr/texbin/pdflatex #{ARGV * ' '}" | |
if file | |
bibtex = "bibtex #{file[0..-4]}aux" | |
cite_file = file + '.cites' | |
contents = File.open(file) {|f| f.read} | |
begin | |
old_data = File.open(cite_file) {|f| f.read} | |
rescue | |
old_data = '' | |
end | |
new_data = contents.scan(/\\cite\{[^\}]*\}/).join("\n") | |
if (new_data != old_data) | |
File.open(cite_file, 'w') {|f| f.write(new_data)} | |
system(latex) and system(bibtex) and system(latex) | |
end | |
end | |
system(latex) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment