Created
January 19, 2012 08:41
-
-
Save Meroje/1638806 to your computer and use it in GitHub Desktop.
Autocompile tex files with latexmk, simply run 'watchr latex.rb'. Works very well with Dropbox
This file contains hidden or 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
watch ('./(.*).tex') { compile } | |
def execute(cmd) | |
puts(cmd) | |
`#{cmd}` | |
end | |
def compile | |
run 'make all' | |
end | |
def run(command) | |
system('clear') | |
result = execute command | |
puts result | |
end | |
@interrupted = false | |
# Ctrl-C | |
Signal.trap 'INT' do | |
if @interrupted then | |
@wants_to_quit = true | |
abort("\n") | |
else | |
puts "Interrupt a second time to quit" | |
@interrupted = true | |
Kernel.sleep 1.5 | |
# raise Interrupt, nil # let the run loop catch it | |
compile | |
end | |
end | |
compile |
This file contains hidden or 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
TEXFILES := $(shell find . -name "*.tex") | |
PDFFILES := $(patsubst %.tex,%.pdf,$(TEXFILES)) | |
all: $(PDFFILES) clean | |
%.pdf: %.tex | |
@latexmk -pdf $< | |
clean: | |
@rm -f *.aux | |
@rm -f *.maf | |
@rm -f *.mtc | |
@rm -f *.mtc0 | |
@rm -f *.log | |
@rm -f *.fdb_latexmk | |
@rm -f *.ilg | |
@rm -f *.out | |
@rm -f *.ind | |
@rm -f *.toc | |
@rm -f *.idx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment