Skip to content

Instantly share code, notes, and snippets.

@Meroje
Created January 19, 2012 08:41
Show Gist options
  • Save Meroje/1638806 to your computer and use it in GitHub Desktop.
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
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
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