skip to content
 

Installing a LaTeX Package or Style for Your Own Use

You can download LaTeX packages and style files into any subdirectory of your home directory. We recommend that packages are installed into a subdirectory of ~/texmf/tex so that LaTeX can find them automatically.

If the packages/styles you want are likely to be useful for other people please contact help@maths.cam.ac.uk so the packages can be considered for central installation.

Open a terminal and create these directories in your home directory:

mkdir -p ${HOME}/texmf/dist ${HOME}/texmf/tex/latex

You can get packages from web addresses such as:

http://www.tex.ac.uk/tex-archive/
http://www.ctan.org/pub/tex-archive/

Let us choose an example of a package, vita, for creating CVs. It can be found at

ftp://cam.ctan.org/tex-archive/macros/latex/contrib/vita.zip

To install this package

cd ${HOME}/texmf/dist
wget ftp://cam.ctan.org/tex-archive/macros/latex/contrib/vita.zip
cd $HOME/texmf/tex/latex/
unzip $HOME/texmf/dist/vita.zip

By default our TeX installation looks in texmf/tex so you should now be able to use the new package with no further problems. If you have problems, or want to tell TeX to look for packages somewhere other than ~/texmf/tex, read on!

Telling LaTeX to look elsewhere - not normally needed

If you need TeX/LaTeX to look in places other than the system directories and $HOME/texmf/tex you will need to set the environment variable TEXINPUTS. Suppose we want to put our extra packages in $HOME/texpackages

This is done by running, if you use bash :

export TEXINPUTS=".:$HOME/texpackages//::"

This tells tex and latex to look for class/style files in the paths separated by ":". First it will look in the same directory as the file being compiled (.); then into ~/texpackages and their subdirectories (this is set by using double slashes at the end '//'), finally it will look into the central tex repository (::). You can put this line in your ~/.bashrc file so you have the environment set every time you open a terminal. If you use csh or variants, the syntax changes to

setenv TEXINPUTS ".:$HOME/texpackages//::"

again, you can add this to your .cshrc or .tcshrc. Some of the packages you are installing might require other variables to be setup. Examples are BSTINPUTS, BIBINPUTS for bibtex packages, TEXFONTS, TEXPSHEADERS, DVIPSHEADERS for dvips and so on. The syntax is similar as to the one for TEXINPUTS. Remember to always add at the end the "::" for having the default added.

Debugging

To see the actual search path that latex (pdflatex, dvips, etc.) are using to search for a particular type of file, at a command prompt type e.g.:

kpsewhich --show-path .pfa | less

To see how a class file is found by latex:

kpsewhich -debug -1 article.cls 2>&1 | less