Posts tagged ‘LaTeX’

2011-02-13

Installing LaTeX packages in your home directory

I was recently in a position where I wanted to use a LaTeX package, but it was not installed on the computer system I was working on. The computer system was at my workplace, at Umeå University. I had a conversation with the systems administrator and he told me that updating the entire TeX distribution would require a lot of work, but that I could place the package in the current directory, with my document, and it would hopefully compile.

I hoped so too. But of course, this being the real world, such luck is rare with computers. So I decided to dive into how I might install a LaTeX package locally, in my home folder. I finally managed to find a solution, and I will detail this below.

This “how-to” will not cover how to create a package, or even how to download ready-made packages or whatever. I had the package that I required installed on my computer at home, so I just copied and pasted that over to the work computer. This tutorial will only cover how to make LaTeX look for packages elsewhere than the default package path.

LaTeX automatically looks to see if there are any package installations in $HOME/texmf/. That search path is the default value of the environment variable TEXMFHOME. This is very nice and handy; what this means is we can use “$HOME/texmf” as a folder to chuck packages into. However, I prefer to have files that I never really intend to open in hidden folders (folders whose name starts with “.” (dot)). So the next step I took was to create a folder where I can put packages, in my home directory (“$HOME”).

> mkdir $HOME/.texmf

After that, I went and added a command to my .bashrc file that will change the value of the TEXMFHOME variable to be that of the newly created folder. This way, LaTeX will search for packages in that folder instead. The following lines were added to the .bashrc file.

# LaTeX stuff
export TEXMFHOME=$HOME/.texmf

I usually use pdflatex to compile my LaTeX documents, so if you use some other program, the environment variable you need to change might be different. I compile my LaTeX documents on the command line, so if you use another system, you might have to find another way to export your environment variable, or even use the specific application settings in your editor, if your editor supports compiling LaTeX documents.

Advertisements