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:

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.


Navigation tree for section Computer Support