Installing TeX/LaTeX packages inside your account

Note: The words “LaTeX package”, “LaTeX macro file”, “LaTeX style file”, and “LaTeX file” all mean the same thing and you treat them the same way, as explained below.

Options

To make use of other people's TeX/LaTeX macros, you have four options:

  • Manually copy and paste the relevant TeX/LaTeX code into your own source files. (This makes sense for one or two individual short macros, but does not make sense for an entire file of macros, or even a collection of macro files — often called a macro package.)
  • Place the macro file(s) in the same directory as your source file. (This may be the way to go, but could lead to clutter in your account.)
  • Ask the computer support staff to install the macro package system-wide. (This makes sense when the package will have wide appeal in the department. If that is the case, we'll schedule the package for addition as part of our next system update, which we perform once or twice a year.)
  • Place the macro file(s) in a special inputs directory inside your account, and tell TeX/LaTeX to look for it there — this approach is described in more detail below. (This is usually the best way to go about things: you avoid clutter, you'll get immediate access to the package, and you remain in control.)

How to use a special inputs directory

Whenever your TeX source code contains \input blablabla.tex or your LaTeX source code contains \include{blablabla.tex}, the computer first searches for the referenced file in your TeX/LaTeX Input Path. To see the current value of that path, issue the command kpsepath tex. Now you have two choices: add a new directory to the path (giving you the freedom to name it as you wish), or use a directory already mentioned in your path.

How to add a new directory to the path

Take this approach if you're particular about how things are named inside your account. This approach gives you complete control. The environment variables TEXINPUTS determines the path. Inside your .bashrc you should add a line similar to

declare -x TEXINPUTS=.:$HOME/TeX/inputs:$HOME/TeX/funpackage:
The order matters: due to the dot, the computer will first search the current directory (i.e., wherever your TeX/LaTeX source file is); then it searches in the subdirectory TeX/inputs inside your account (but it won't go searching through any tree below there); then it searches TeX/funpackage; finally, due to the colon at the end, it will search all the usual places it would have searched if you hadn't declared TEXINPUTS at all.

Having done the above, use mkdir to create the relevant subdirectories, and put your input files there. For example, with the declaration shown above, you would now

cd
mkdir TeX
mkdir TeX/inputs
mkdir TeX/funpackage
and you might then put some macro files inside TeX/inputs, while putting all the files that are part of funpackage inside TeX/funpackage.

Use an existing path directory

This is the alternate approach. TeX/LaTeX will run ever-so-slightly faster, and you don't have to worry about custom environment variables. Use kpsepath tex to examine your current path. It will probably include !!$HOME/texmf/tex///, where $HOME is something like /u3/accountname. The // at the end says to search the entire subtree under there, and the !! at the start says to use a special index file to speed up the search. (You must issue a separate command to build that index file — see below.)

First create the relevant subdirectories:

cd
mkdir texmf
mkdir texmf/tex
Inside texmf/tex, you could create further subdirectories for each TeX/LaTeX package you wish to use. However, those files won't be found until you give the following command:
texhash
This command says, “Yo, I changed my local TeX tree, so please rebuild all the index files for the tree.” Every time you add files to the texmf/tex tree, you'll have to run texhash again.

Department of Mathematics
The University of Arizona
617 N. Santa Rita Ave.
P.O. Box 210089
Tucson, AZ 85721-0089 USA
Voice: (520)621-6892
Fax: (520)621-8322

http://math.arizona.edu
Maintainer: webmaster@math.arizona.edu
Validate: XHTML, CSS

© Copyright 2003-10 Arizona Board of Regents
All rights reserved.