Prev Up Next
Go backward to Including graphics in LaTeX documents
Go up to LaTeX
Go forward to Slides

LaTeX packages

Since LaTeX is actually a programming language, extensions can be made by users. You may not have the interest, the knowledge, or the time to write sophisticated LaTeX code, but many users have contributed their work to the Comprehensive TeX Archive Network (CTAN), where you can find many packages that perform common tasks. Here are some examples of how to locate, download, install, and use a few of these packages. 

Suppose that you would like a package to assist you in composing examinations. If you go to the CTAN directory /tex-archive/macros/latex/contrib/supported/, then you will see three subdirectories that look promising: exam (a package by Philip Hirschhorn),  examdesign (a package by Jason Alexander), and exams (a package by Hans van der Meer). 

The first of these packages is the most user-friendly. According to its author, the package "attempts to make it easy for even a LaTeX novice to prepare exams." To download this package, go the exam directory and grab the files exam.cls and examdoc.tex. You can likely grab a file with your World-Wide Web browser by holding down the Shift key while you click the left mouse button on the name of the file.

The file exam.cls is a LaTeX class file: a set of macros that LaTeX implements if you start your source file with \documentclass{exam} instead of with \documentclass{article}. The file examdoc.tex is documentation about how to use this new document class. Execute the command latex examdoc (two or three times, until you stop getting messages about running latex again), and then either view the documentation on screen via xdvi examdoc &, or run dvips examdoc and print the documentation via lp examdoc.ps.


Exercise: Typeset a quiz

Make up and typeset a quiz for a calculus class. Use some of the features of the exam document class, as illustrated in the sample quiz.


One of the interesting features of the sample quiz is the fancy formatting of headers and footers. This functionality is available independently of the exam package in a separate package, fancyhdr, written by Piet van Oostrum. To use the fancyhdr package, download the files in the CTAN directory /tex-archive/macros/latex/contrib/supported/fancyhdr/. This package consists of a style file fancyhdr.sty rather than a class file, so you can use it with any document class by putting the command \usepackage{fancyhdr} in the preamble of your LaTeX source file. You can learn how to use the package by reading the documentation.

The exam class in Jason Alexander's examdesign package has some features not present in Philip Hirschhorn's package. For example, Jason Alexander's exam class has special environments for fill-in-the-blank questions, for short-answer questions, for true-false questions, and for multiple-choice questions. It also binds answers to questions so that an examination and a matching answer key can easily be generated from the same source file. It addition, it allows for automated randomizing of the order of the questions, so that you can produce multiple forms of the same exam.

The examdesign package is distributed via a method common to the more elaborate LaTeX packages. The essential files are exam.dtx and exam.ins. If you run the command latex exam.ins, then the class file exam.cls will be created automatically from the file exam.dtx. On the other hand, if you run the command latex exam.dtx, then you will get documentation for the package.

If you are going to experiment with both of these exam packages, then you had better keep them in different directories so that they do not conflict with each other.

How could you have found the exam packages without being told where to look? One way is to browse the LaTeX online catalogue. On the home page of the catalogue, you will find links to mirror sites; selecting the closest site may speed up your access. Click on Alphabetic Index and select the letter E to look for exam packages. Alternatively, if you knew from experience that there are packages located in the CTAN directory /tex-archive/macros/latex/contrib/supported, then you could point your World-Wide Web browser at ftp://tug2.cs.umb.edu/tex-archive/macros/latex/contrib/supported/ and browse. Another method would be to open a terminal window, execute the command ftp tug2.cs.umb.edu, login as "anonymous," and execute the command quote site index exam.cls to determine the location of the file exam.cls.


Exercise: Typesetting URLs

Locate and download Donald Arseneau's  package  url.sty. Use it to typeset a paragraph that describes your five favorite URLs.



Exercise: Watermarks

It is sometimes useful to put a background image on each page of a document. For example, you might mark preliminary versions of a memorandum with the word DRAFT in large letters. This is easy to do if you are using a PostScript printer.

Locate and download Juergen Vollmer's  draftcopy package, and install it by executing the command latex draftcopy.ins in a terminal window. Use the package to typeset a document in the style of the online example.



Exercise: Fanciful paragraph shapes

Grab the opening paragraphs of Alice's Adventures in Wonderland off the World-Wide Web, download Donald Arseneau's shapepar.sty from CTAN, and use that package together with fancyhdr.sty to reproduce the typesetting in the online example. Notice that the shapepar package was written for the now obsolete LaTeX version 2.09, so the documentation has references to the defunct command \documentstyle, which you should replace with \documentclass.



Exercise: Wrapping text around graphics

Another section shows how to insert graphics in a LaTeX document by using the standard graphics package. Several packages are available to flow text around included graphics: wrapfig.sty, floatflt.sty, and picins.sty. The package recommended by Piet van Oostrum is picins.sty.

Locate and download the picins package. (On a Unix system, you may need to delete a spurious ^Z at the end of the file picins.sty.) Then use the package to reproduce the typesetting in  the online example.



logoThe Math 696 course pages were last modified January 15, 1998.
These pages are copyright © 1995-1997 by Harold P. Boas. All rights reserved.

Prev Up Next