Installing TeTeX latex packages

February 28th, 2005 ~ Posted in: General, Programming

Installing LaTeX packages under MikTeX, the windows distro I use, is painless: you just select them in a gui; consequently, I have all the available packages installed. On the other hand, you have to manually install LaTeX packages when you’re using TeTeX, the major *Nix TeX distribution. Since I barely know enough LaTeX as it is, without getting into the specifics of how kpathsea works, I’ve never installed any packages under TeTeX, even the ones that I really feel are necessary. Today, my laziness triumphed and I forced myself to learn how to install packages: I was working on my algebra homework, and was dreading typsetting polynomial long divison, when I realized that there is a package (polynom) which will handle it for you: you call it like (\polylongdivision{\frac{1}{2}x^2 + 2x}{x+1}} ) and it typesets the long division process for you! Hmm, hours of messing with spacing in tables, or learning how to install packages?

So here’s how to install latex packages, as gleaned (i.e. plagiarized) from the UK TeX FAQ:

  1. dl the package files into a temporary directory: they usually come as a single .sty file or a twosome of .dtx and .ins files. If the package came as a .sty file, skip to placing the files
  2. 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).
  3. Run latex on pack.dtx as a start to getting the user manual and possibly a commented version of the package code.
  4. Run latex again on pack.dtx, which should resolve any references and generate a Table of Contents if it was called for.
  5. 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.
  6. Print and read pack.dvi
  7. placing the files:

    Where precisely you put files that you have downloaded does depend on what TeX distribution you have. However, assuming that you have one of the modern TDS-compliant distributions (such as teTeX, fpTeX or mikTeX) there are some general rules that you can follow:

    (1) Always install new files in a local texmf tree. The root directory will be named something like:

    teTeX: /usr/share/texmf-local/ or /usr/local/share/texmf/
    fpTeX: c:\fptex\texmf.local\
    mikTeX: c:\localtexmf\

    (In fact, a teTeX system can be asked to tell you what its local root is; on a Unix system, the command to use is:

    kpsewhich -expand-var \$TEXMFLOCAL

    the output being the actual path.)

    Let’s write $TEXMF for this root, whatever it is for your system.

    (2) In your local texmf tree, imitate the directory structure in your main tree. Here’s some examples of where files of given extensions should go:

    .sty, .cls or .fd: $TEXMF/tex/latex/<package>/
    .dvi, .ps or .pdf: $TEXMF/doc/latex/<package>/
    .mf: $TEXMF/fonts/source/<supplier>/<font>/
    .tfm: $TEXMF/fonts/tfm/<supplier>/<font>/
    .vf: $TEXMF/fonts/vf/<supplier>/<font>/
    .afm: $TEXMF/fonts/afm/<supplier>/<font>/
    .pfb: $TEXMF/fonts/type1/<supplier>/<font>/
    .ttf: $TEXMF/fonts/truetype/<supplier>/<font>/

    Where of course >package>, >font> and >supplier> depend upon what’s appropriate for the individual file. Note, however, that >font> may stand for a single font or an entire family: for example, files for all of Knuth’s Computer Modern font family are to be found in …/public/cm, with various prefixes as appropriate.

3 Responses to “Installing TeTeX latex packages”

  • 1. Esteban
    December 16th, 2005 at 3:47 pm

    You may also need to rebuild de texmf tree (to tell LaTeX where to find the newly installed package). MiKTeX does this automatically, but if you install manually you have to rebuild it. In teTeX, just run texhash after placing the files.

  • 2. Alex
    December 16th, 2005 at 10:02 pm

    Thanks for pointing that out, Esteban. Since I didn’t have to do that, I guess that’s probably something that needs to be done for every TeX package, but LaTeX packages handle that automagically?

  • 3. Gasso Wilson Mwaluse
    January 2nd, 2007 at 7:40 pm

    I have downloaded all the required tar files and when it comes to configuration it does not configure complaining about C and C++ compilers not working even when I am quite sure the compilers are perfect.

    Gasso

This entry was posted on Monday, February 28th, 2005 at 7:43 pm and is filed under General, Programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply