Skip to content

Instantly share code, notes, and snippets.

@xoebus
Created November 8, 2010 16:29
Show Gist options
  • Save xoebus/667888 to your computer and use it in GitHub Desktop.
Save xoebus/667888 to your computer and use it in GitHub Desktop.
TEX_FILES = FileList["*.tex", "figures/*", "*.bib", "*.cls"]
MAIN = "thesis" # name of main file without .tex suffix
MAIN_TEX = "#{MAIN}.tex"
OUT_PDF = "#{MAIN}.pdf"
file OUT_PDF => TEX_FILES do
%x{pdflatex -interaction=batchmode #{MAIN_TEX} >/dev/null 2>&1}
%x{makeindex #{MAIN} >/dev/null 2>&1}
%x{bibtex #{MAIN} >/dev/null 2>&1}
%x{pdflatex -interaction=batchmode #{MAIN_TEX} >/dev/null 2>&1}
%x{bibtex #{MAIN}.gls >/dev/null 2>&1}
%x{makeindex #{MAIN} >/dev/null 2>&1}
%x{pdflatex -interaction=batchmode #{MAIN_TEX} >/dev/null 2>&1}
%x{makeindex #{MAIN} >/dev/null 2>&1}
%x{bibtex #{MAIN} >/dev/null 2>&1}
%x{bibtex #{MAIN}.gls >/dev/null 2>&1}
%x{pdflatex -interaction=batchmode #{MAIN_TEX} >/dev/null 2>&1}
sh "pdflatex -interaction=batchmode #{MAIN_TEX} >/dev/null"
cp "#{MAIN}.pdf"
end
desc "Removes unnecessery files"
task :clean do
rm FileList["*.aux","*.bak","*.log","*.blg", "*.bbl", "*.toc", "*.out", "*.idx", "*.ilg", "*.ind", "#{THESIS}.pdf", "*.dep", "*.glo", "*.gls"]
end
task :default => [:run]
"Open text editor to edit files"
task :edit do
["$EDITOR", "mate", "vim", "emacs"].find do |editor|
system "#{editor} *tex *bib Rakefile"
end or puts "Unable to find text editor."
end
task :run do
t = Rake::Task[OUT_PDF]
loop do
begin
t.reenable
t.invoke
rescue => e
puts "Error: #{e}, sleeping for 15 seconds."
Kernel.sleep 15
end
Kernel.sleep 1
end
end
desc "Shows Thesis"
task :view => [OUT_PDF] do
["open", "okular", "kpdf", "acroread"].find do |viewer|
system "#{viewer} #{OUT_PDF}"
end or
puts "Unable to find any pdf viewer."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment