### Installing a new package

The first step in installing a new package for your LaTeX system is usually to find where it is and then to get it, usually from CTAN. However MiKTeX, since version 2.1, offers a simpler procedure than that described here, for packages it knows about.

Ordinarily, you should download the whole distribution directory; the only occasion when this is not necessary is when you are getting something from one of the (La)TeX contributed "misc" directories on CTAN; these directories contain collections of single files, which are supposedly complete in themselves.

A small package <smallpack> might be just a single `.sty` file (typically smallpack.sty) with the usage instructions either included as comments in the file or in a seperate user manual or README file. More often a package <pack> will come as a pair of files, pack.ins and pack.dtx, written to be used with the LaTeX doc system. The package code must be extracted from these files. If there is a README file as part of the package distribution, read it!

In the doc system, the user manual and documented package code is in the `.dtx` file, and the `.ins` file contains LaTeX instructions on what code should be extracted from the `.dtx` file. To unpack a doc package <pack>, do the following:

- Run latex on pack.ins. This will generate one or more files (normally a pack.sty file but there may be others depending on the particular package).
- Run latex on pack.dtx as a start to getting the user manual and possibly a commented version of the package code.
- Run latex again on pack.dtx, which should resolve any references and generate a Table of Contents if it was called for.
- LaTeX may have said "`No file pack.ind`"; this is the source for the command index; if you want the index, process the raw material with:
  `makeindex -s gind.ist pack`
  and run LaTeX again.
- Print and read pack.dvi

Sometimes a user manual is supplied seperately from the .dtx file. Process this after doing the above, just in case the user manual uses the package it is describing.

Almost the final stage of the installation is to put the package file(s) 'where LaTeX can find them'. Where the magic place is, and how you put the files there depends on your particular LaTeX system and how it is set up (see the TeX directory structure standard for general principles, where to put files for specific advice).

The final stage is to tell LaTeX that there is a new file, or files, that it should be able to go and find. Most free LaTeX systems maintain a database of the names and locations of latex-related files to enable faster searching. In these systems the database must be updated, using the script or program provided with the distribution for this purpose.

teTeX
  Run:
  `texhash`
web2c
  On a current web2c distribution, `texhash` ought to work; if it doesn't, run `mktexlsr`
fpTeX
  Click `Start`-> `Programs`-> `Texlive`-> `Maintenance`-> `Rebuild ls-R filenames databases`, or open a "command" window and run `texhash`
MiKTeX
  On a MikTeX distribution earlier than v2.0, click `Start`-> `Programs`-> `MikTeX`-> `Maintenance`-> `Refresh filename database`

  or get a DOS window and run:
  `initexmf --update-fndb`

  On a MikTeX distribution v2.0 or later, do:
  `Start`-> `Programs`-> `MikTeX 2`-> `MikTeX Options`, and press the `Refresh now` button (`Update filename database` in earlier versions of MiKTeX).

Remember that a `\usepackage{pack}` command must be put in the preamble of each document in which you want to use the pack package.

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=instpackages