LaTeX/Packages/Installing Extra Packages

From Wikibooks, open books for an open world
Jump to: navigation, search

Most LaTeX installations come with a large set of pre-installed style packages, but many more are available on the net. The main place to look for style packages on the Internet is CTAN ( http://www.ctan.org/ ). Once you have identified a package you need and haven't already got (or you have got it and need to update it), use the indexes on any CTAN server to find the package you need and the directory where it can be downloaded from.

If on a debian system, there is an alternative way of installing packages, through synaptics package manager.

[edit] Downloading packages

What you need to look for is always two files, one ending in .dtx and the other in .ins. The first is a DOCTeX file, which combines the package program and its documentation in a single file. The second is the installation routine (much smaller). You must always download both files. If the two files are not there, it means one of two things:

  • Either the package is part of a much larger bundle which you shouldn't normally update unless you change version of LaTeX;
  • or it's one of a few rare or unusual packages still supplied as a single .sty file intended for the now obsolete LaTeX 2.09

Download both files to a temporary directory. There will often be a readme.txt with a brief description of the package. You should of course read this file first.

[edit] Installing a package

There are four steps to installing a LaTeX package:

1. Extract the files Run LaTeX on the .ins file. That is, open the file in your editor and process it as if it were a LaTeX document (which it is), or if you prefer, type latex followed by the .ins filename in a command window in your temporary directory. This will extract all the files needed from the .dtx file (which is why you must have both of them present in the temporary directory). Note down or print the names of the files created if there are a lot of them (read the log file if you want to see their names again).

2. Create the documentation Run LaTeX on the .dtx file. You might need to run it twice or more, to get the cross-references right (just like any other LaTeX document). This will create a .dvi file of documentation explaining what the package is for and how to use it. If you prefer to create PDF then run pdfLaTeX instead. If you created a .idx as well, it means that the document contains an index, too. If you want the index to be created properly, follow the steps in the indexing section. Sometimes you will see that a .glo (glossary) file has been produced. Run the following command instead:

makeindex -s gglo.ist -o name.gls name.glo

3. Install the files While the documentation is printing, move or copy the files created in step 1 from your temporary directory to the right place[s] in your TeX local installation directory tree - always your 'local' directory tree, a) to prevent your new package accidentally overwriting files in the main TeX directories; and b) to avoid your newly-installed files being overwritten when you next update your version of TeX. The "right place" sometimes causes confusion, especially if your TeX installation is old or does not conform to the TeX Directory Structure. For a TDS-conformant system, this is either a) for LaTeX packages, a suitably-named subdirectory of texmf-local/tex/latex/; or b) a suitably-named sub-directory of texmf-local/ for files like BIBTeX styles which are not just for LaTeX but can be used in other TeX systems. "Suitably-named" means sensible and meaningful (and probably short). For a package like paralist, for example, I'd call the directory paralist. Often there is just a .sty file to move but in the case of complex packages there may be more, and they may belong in different locations. For example, new BibTeX packages or font packages will typically have several files to install. This is why it is a good idea to create a sub-directory for the package rather than dump the files into misc along with other unrelated stuff. If there are configuration or other files, read the documentation to find out if there is a special or preferred location to move them to.

For example: MiKTeX 2.7 or later (in Windows environment), you will find the directory to be in Program Files/MiKTeX 2.7 (the exact name of folder varies with the version of MiKTeX installed). According to the table you'll find lower on this page, move the files into appropriate folders of the MiKTeX file directory (create new folders in directories, if needed).


Where to put files from packages
Type Directory (under texmf-local/) Description
.cls tex/latex/base Document class file
.sty tex/latex/packagename Style file: the normal package content
.bst bibtex/bst/packagename BibTeX style
.mf fonts/source/public/typeface METAFONT outline
.fd tex/latex/mfnfss Font Definition files for METAFONT fonts
.fd tex/latex/psnfss Font Definition files for PostScript Type 1 fonts
.pfb /fonts/type1/foundry/typeface PostScript Type 1 outline
.afm /fonts/afm/foundry/typeface Adobe Font Metrics for Type 1 fonts
.tfm /fonts/tfm/foundry/typeface TeX Font Metrics for METAFONT and Type 1 fonts
.vf /fonts/vf/foundry/typeface TeX virtual fonts
.dvi /doc package documentation
.pdf /doc package documentation
others tex/latex/packagename other types of file unless instructed otherwise

4. Update your index Finally, run your TeX indexer program to update the package database. This program comes with every modern version of TeX and is variously called depending on the LaTeX distribution you use (Read the documentation that came with your installation to find out which it is):

  • teTeX, TeX Live, fpTeX: texhash
  • web2c: mktexlsr
  • MikTeX: initexmf --update-fndb (or use the GUI)
  • MiKTeX 2.7 or later versions, installed on Widows XP or later versions of Windows: Start -> All Programs -> MikTex -> Settings. In Settings menu choose the first tab and click on Refresh FNDB-button (MikTex will then check the Program Files directory and update the list of File Name DataBase). After that just verify by clicking 'OK'.
This last step is utterly essential, otherwise nothing will work.

The reason this process has not been automated widely is that there are still thousands of installations which do not conform to the TDS, such as old shared Unix systems and some Microsoft Windows systems, so there is no way for an installation program to guess where to put the files: you have to know this. There are also systems where the owner, user, or installer has chosen not to follow the recommended TDS directory structure, or is unable to do so for political or security reasons (such as a shared system where she cannot write to a protected directory). The reason for having the texmf-local directory (called texmf.local on some systems) is to provide a place for local modifications or personal updates, especially if you are a user on a shared or managed system (Unix, Linux, VMS, Windows NT/2000/XP, etc.) where you may not have write-access to the main TeX installation directory tree. You can also have a personal texmf subdirectory in your own login directory. Your installation must be configured to look in these directories first, however, so that any updates to standard packages will be found there before the superseded copies in the main texmf tree. All modern TeX installations should do this anyway, but if not, you can edit texmf/web2c/texmf.cnf yourself.


  Index  
Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export