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)

.PHONY: clean

all: $(patsubst %.tex,%.pdf,$(SRC))

%.pdf: %.tex
	@rubber $(OPTS) $<

	@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]: [latexmk]: [rubber]: [requires]: [entry]: [either]: