Use rubber to compile TeX
Compiling TeX documents by hand is tedious1 and with all the output a pain to watch at. For a long time, I used [latex-makefile][] that tries to solve both problems. However, it is a huge beast which broke compilation from time to time.
After looking around a bit, I came to [latexmk][] which almost fit the bill.
The Perl script does what it has to do but [requires][] patching latexmk itself
or a .latexmkrc
file just for compiling XeLaTeX sources.
So, I looked a little further and found [rubber][]. I knew it already from Gedit’s LaTeX plugin but I wasn’t really aware that one could use it as a standalone solution. Anyway, for simple projects calling
$ rubber --pdf doc
compiles doc
with pdfLaTeX, strips out unnecessary debug output and
pre-processes things like the BibTeX bibliography. To compile XeLaTeX sources,
you could [either][] write a rubber module and distribute it with your document,
or simply add
% rubber: set program xelatex
on top of your source file. That’s it.
Now, instead of the huge latex-makefile or a hand-written Makefile, I use this little baby for all my TeX documents:
SRC=$(wildcard *.tex)
OPTS=--pdf
.PHONY: clean
all: $(patsubst %.tex,%.pdf,$(SRC))
%.pdf: %.tex
@rubber $(OPTS) $<
clean:
@rubber --clean $(OPTS) $(SRC)
More information about rubber can be found in an [entry][] of the TeX SE community blog.
pdflatex && bibtex && pdflatex && pdflatex
… seriously?
[latex-makefile]: http://code.google.com/p/latex-makefile/
[latexmk]: http://www.ctan.org/pkg/latexmk/
[rubber]: https://launchpad.net/rubber/
[requires]: http://stackoverflow.com/questions/3124273/compile-xelatex-tex-file-with-latexmk
[entry]: http://tex.blogoverflow.com/2011/12/building-documents-with-rubber/
[either]: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579757