It’s common to compile our documents a couple of times to ensure, amongst other things, correct cross-referencing and indices. Sometimes, we also rely on a
Makefile in order to make things easier. Now enters
rubber, a powerful tool to help us on our building adventures.
Our first example
According to the
rubber “is a wrapper for LaTeX and companion programs. Its purpose is, given a LaTeX source to process, to compile it enough times to resolve all references, possibly running satellite programs such as BibTeX, makeindex, Metapost, etc. to produce appropriate data files.”
All the major Linux distros have
rubber in their repositories. A simple
yum install rubber does the job for me. Let’s see an example, with
We should now run
pdflatex again. Hm let’s run it again three more times just to be sure (I know I do). Or we could go with
rubber --pdf mydoc . Done. Of course, don’t mention Macbeth.
There we go!
makeindex as many times as need. The
rubber to run the PDF tools instead the DVI ones. Do you think the current folder is messy, full of temporary files? Go with
rubber --clean mydoc and voilà, now you’ll have only the resulting PDF file and your
tex source file.
If you want to get rid of all generated files, except of course the sources, just add the
--clean --pdf flags:
rubber is smart enough to check if the files are updated:
High hopes part II
Yes, there goes another rubber tree plant… again.
Time for more advanced stuff with
I had the opportunity of answering a nice question on TeX.sx about
rubber. It makes use of directives, the hidden gems.
A directive is a comment in the form of
% rubber: cmd args
which adds information for
rubber. It’s very simple. Let’s say I want to use a custom
mystyle.ist style for my index. A quick look into the
rubber manual gives me the following entry:
index.style <style>: specifies the index style to be used. It’s important to note that each of these directives may be used with an optional first argument of the form
(foo,bar,quux)in order to specify that the directive only applies to the indexes named
quux. By default, directives are applied to all indices.
Now, I just need to add a line to
Well, it didn’t work.
Why? I was wondering what happened. Then the manual tells me why:
- When using the package
index, the directives must of course be prefixed by
index., and the optional first argument is not accepted.
Since I’m using
makeidx, a quick fix
does the trick.
There are several directives for you to play with. Have fun!
Mac users, don’t worry!
Of course, there’s an app for that… I mean,
rubber can be used with Mac too! Go to the official
rubber repository and download the current compressed file, e.g,
rubber-1.1.tar.gz. Extract it to a folder and use
sudo make install.
Update: XeLaTeX, where are you?
rubber offers no XeLaTeX support out of the box. But there a way to fix this.
Wouter Bolsterlee provided an elegant solution. Go here, download the attached
xelatex.py file and copy it to
rules/latex directory. In my Fedora system, the full path is
/usr/lib/python2.7/site-packages/rubber/rules/latex. Now, just run
rubber --module xelatex mydoc
and XeLaTeX is recognized! I’m pretty sure a similar
lualatex.py file might be used for LuaLaTeX.
rubber has a lot more features than the ones I described in these examples. Take a look on the manual by running
man rubber and
info rubber for a complete reference. This tool is certainly a great addition to our TeX utility belt.