Created
August 8, 2008 17:02
-
-
Save qoobaa/4585 to your computer and use it in GitHub Desktop.
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
# LaTeX and Dia compilation script 0.2.1 | |
# author: Jakub Kuźma <[email protected]> | |
require 'rake/clean' | |
task :default => [:pdf, :acroread] | |
SRC = FileList['*.tex'] | |
IMG = FileList['*.dia'] | |
BIB = FileList['*.bib'] | |
CLEAN.include(%w(pdf eps).collect { |e| IMG.ext(e) }, | |
%w(log aux out toc nav snm).collect { |e| SRC.ext(e) }, | |
%w(bbl blg).collect { |e| BIB.ext(e) }) | |
CLOBBER.include(%w(pdf dvi ps).collect { |e| SRC.ext(e) }) | |
def pdflatex(source) | |
sh "pdflatex -interaction=batchmode #{source}" | |
end | |
rule '.pdf' => '.eps' do |t| | |
sh "epstopdf -outfile=#{t.name} #{t.source}" | |
end | |
rule '.eps' => '.dia' do |t| | |
sh "dia -e #{t.name} #{t.source}" | |
end | |
rule '.pdf' => '.tex' do |t| | |
IMG.ext('pdf').each { |task| Rake::Task[task].invoke } | |
unless BIB.empty? | |
pdflatex(t.source) | |
rm_rf(t.name) | |
sh "bibtex #{t.source[0, t.source.size - 4]}" | |
end | |
2.times { pdflatex(t.source) } | |
end | |
desc "Compile LaTeX and Dia files to PDF format." | |
task :pdf => SRC.ext('pdf') | |
desc "Compile only Dia files to PDF format." | |
task :dia => IMG.ext('pdf') | |
desc "Show compiled source in Adobe Acrobat Reader." | |
task :acroread do | |
sh "acroread #{SRC.ext('pdf')}" | |
end | |
desc "Show compiled source in Evince." | |
task :evince do | |
sh "evince #{SRC.ext('pdf')}" | |
end | |
desc "Show compiled source in KPDF." | |
task :kpdf do | |
sh "kpdf #{SRC.ext('pdf')}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment