Installing and using LaTeX packages
About packages
LaTeX packages are sets of commands that, when invoked in the preamble of a LaTeX document, extend LaTeX’s functionality or force it to style documents according to special guidelines. The geometry package, for example, allows you to change the margins of a LaTeX document. A good place to find packages is the CTAN (The Comprehensive TeX Archive Network).
Installing (most) packages
1) Download the files and uncompress them if they are zipped.
2) Run LaTeX on the .ins file, either by opening the .ins file in your frontend or via the command line (ex: latex packagename.ins). This creates various files, such as a .cls, .sty, .cfg and .drv files.
2a) Optional: Run LaTeX on the .dtx file to create the manual.
3) Move the folders to somewhere in your LaTeX tree where they can be found by the program. This is the hardest part, because it varies depending on LaTeX distribution.
- For gwTeX on OS X, make the folder “Library/texmf” in your Home directory and put the files there (they can be organized into folders or just dropped into the directory).
- For MikTeX on Windows, put the files in “C:\texmf\tex\latex” again putting them in a subdirectory if desired.
Note: Not all of the files are necessary, usually LaTeX is just looking for the .sty or .cls files. However, this may vary, so it’s a good idea to move all of the files into the appropriate folder.
4) (This step may also be optional, depending on your distribution) Tell LaTeX that you have added the files.
- This is not necessary if you are using gwTeX.
- If you are using MikTeX, this can be done using the MiKTeX Options application, which is available through the Start Menu: Open the application and click the Refresh Now button under the General tab.
Other installation methods
1) The method described above applies to almost all distributions. However, some flavors of LaTeX offer simpler ways to install packages. For example, MiKTeX users can open the MiKTeX Package Manager and select an online repository (such as CTAN) to automatically install/uninstall some packages. i-Installer, the graphical application that installs gwTeX, also offers automatic installation of a limited number of packages. It is still a good idea to know how to do it the long way, since not all packages will be available via these easy package managers.
2) Some packages will come unzipped in the form of a .sty or .cls file, usually with some accompanying documentation. These packages do not need to be processed with LaTeX before they are moved to the appropriate texmf subdirectory.
Using packages
Once a package is installed, it can be invoked in the preamble of a LaTeX document. For example, to use the geometry package to set the margins of a document to one inch, type:
\documentclass{article}
\usepackage[margin=1in]{geometry}
\begin{document}…
The general syntax is “\usepackage[options]{packagename}.” It is important to read the documentation provided with different packages, because they will all have their own options and syntax, which can be complicated compared to the core LaTeX markup language.