Friday, 24 February 2012

Building a local LaTeX tree

If, like me, your sysadmins have you suffering the burden of an archaic OS then, like me, you may also keep a beady eye out for ways of circumnavigating the virtual obstruction. If a by-product is that you suffer old LaTeX packages, there's actually an easy way of installing your own, up-to-date versions. Basically, you can build a local LaTeX package tree, which is searched before the default location. Below, I describe how to do this in Linux. This worked perfectly for me so I can't offer any help if it goes wrong or if you're using another OS. Fortunately this is widely covered on the web so Googling something like "local texmf tree" should net you something useful. There's a lot of information in the LaTeX Wikibook.

In your home folder, create the folder texmf/tex/latex/. Installing a given package boils down to copying the style file and any associated things into a new subfolder in ~/texmf/tex/latex/. After each new package is installed, go back to your home folder and run texhash. Don't worry if it tells you about not being able to access the base folders. (On my system, they involve something like /usr/share/texmf.)

Installing packages comes in three basic flavours. Some packages, like quotchap, are just a single style file.  If you have the relevant .sty file to hand, you can copy that into a new subfolder, run texhash and then start using it. More complicated packages, like microtype, require that you download the .dtx and .ins files and run

latex microtype.ins

to create the package files, which must then be copied into the relevant subfolder in the local texmf tree. Finally, packages that contain a large number of smaller units, like oberdiek, offer an archive that just needs to be extracted into texmf.

I usually found that the README files gave me the necessary information to copy things to the right place. Failing that, you can usually infer the right location from the folder on the CTAN servers.

There are two caveats I'll mention. First, expect some dependencies to crop up when updating very old packages. For example, when I tried my local installation of microtype, I ended up having to update everything in the package under oberdiek. Second, the status of packages that are listed under tex/generic is unclear. I found I had to copy them to subfolders in tex/latex for them to be detected and work properly. (I believe this is because they need to be accessible to pure TeX too.)

Problems? Improvements? Extra tips? Found this useful? Let me know in the comments.

No comments:

Post a Comment