Department of Engineering

IT Services

Installing LaTeX Packages

Finding packages should be easy - just do a WWW search or search/browse a CTAN site. Packages tend to be well documented nowadays - see the dirtree page for example. If you have a latex facility on your own machine, it may have come with installation/update options. On CUED's central system you'll have to install packages in your own file space. LaTeX looks in many places for files, the current directory first. Typing

kpsewhich --show-path=tex

will give you a fair idea of where it looks. This list of directories searched can be added to using the TEXINPUTS environmental variable. If you type

   echo $TEXINPUTS

on a Unix system you'll see if/how it's been set for you. Typing

  export TEXINPUTS=~/tex//:

before using latex will make latex search in your ~/tex/ directory before looking at system files. Note that in this context

  • '//' means 'search subdirectories recursively'.
  • if you miss out the first or final ':' only your files will be searched

Some packages are just single "*.sty" files. You can just install the file in the same folder as the latex file that uses it. If you want to want to install it for more general use, create a folder called ~/texmf/tex/latex/ and put it there ("~" is short-hand in Unix for your home folder).

Some packages comprise multiple files that should be installed in a folder of their own. The installation instructions are provided with the package. Here's an example of how to download and install a typical package (dirtree) on CUED's central system, creating any necessary folders.

mkdir -p ~/texmf/tex/latex/dirtree
cd ~/texmf/tex/latex/dirtree
latex dirtree.ins

The wget command copies files from the WWW. The "*.ins" file of a LaTeX distribution can be LaTeX'd to extract the package code and documentation from the supplied "*.dtx" file.