<!-- 
.. title: Automated LaTeX
.. slug: automated-latex
.. date: 2014-01-05 18:08:16 UTC+01:00 
.. tags: linux, latex, 
.. link: 
.. description: 
.. type: text 
--> 

We've got several tools which intend to automate the generation of complex documents by LaTeX. Without these tools, the generation of a publication ready for submission would require several compiler passes to resolve all references for building, for example, the index and the bibliography. [This thread](http://tex.stackexchange.com/questions/64/tools-for-automating-document-compilation/26573#26573 "This thread") illustrates the problem and highlights some of the most popular of these tools.

For my modest requirements, I've found that [rubber](https://launchpad.net/rubber/ "rubber") is perhaps the most convenient choice. Rubber seems not to be in active development any more, but does what it should in the most unobtrusive way (and support for XeLaTeX is [easy to add](http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579757 "easy to add")).

For the **command line**, I use a simple makefile:

	TEXFILE = $(wildcard *.tex)
	PDFFILE = $(TEXFILE:.tex=.pdf)
	VIEWER = mupdf

	all: pdf

	pdf: $(PDFFILE)

	%.pdf: %.tex
	    @rubber --pdf $<
	clean:
	    @rubber --clean $(TEXFILE:.tex=)
	tidy:
	    @rubber --clean --pdf $(TEXFILE:.tex=)
	view: pdf
	    $(VIEWER) $(PDFFILE)

	.PHONY: pdf clean tidy all

For **vim**, I use [TeX-PDF](https://github.com/vim-scripts/TeX-PDF "TeX-PDF") (and [LaTeX-Box](https://github.com/vim-scripts/LaTeX-Box "LaTeX-Box") for command completion). TeX-PDF respects my makefile, if one is present, or uses rubber or even plain pdflatex as a fallback.

On my [notebook with ArchBang](chitty-chitty-bang-bang.html "notebook with ArchBang"), however, TeX-PDF opened Gimp for viewing the pdf, which is a wonderfully absurd choice.

To correct that, I defined mupdf as the default application for opening pdf files:

	xdg-mime default mupdf.desktop application/pdf,

but that didn't change a thing.

I finally found out that this behavior was caused by a glitch in the default configuration of ArchBang:

	$ grep DE ~/.xinitrc
	export DE=openbox

Openbox is not one of the possible values of the environment variable DE, and is thus not recognized by xdg-open. One should either substitute 'openbox' by 'xfce', or comment out the entire command.

