Document 358

The LaTeX algorithm package

Version: 3.5x, 4.x, 5.x - Scientific WorkPlace & Scientific Word

The algorithm package defines a floating environment for algorithm descriptions so they don't break over a page boundary. The package enables algorithm numbering.

If you're using a report or book shell, you can produce a list of numbered algorithms for inclusion after the table of contents. The list appears on a separate page, similar to a list of figures or list of tables. You must process your document through LaTeX outside SWP or SW to generate the list. Run LaTeX at least twice.

Options that affect the appearance and numbering of algorithm environments are available through the Options and Packages command on the Typeset menu. The package is designed to be used with the algorithmic package, but it can be used separately. For more information, see the package documentation available through the program's online Help.

How to use the algorithm package

  1. Add the algorithm package to your document.
  2. If it is present, remove the definition of the algorithm newtheorem environment from the document preamble:
    1. From the Typeset menu, choose Preamble.
    2. Delete the definition, which looks something like this:
      \newtheorem{algorithm}[theorem]{Algorithm}
    3. Choose OK.
  3. Place the insertion point where you want the algorithm to begin, and begin the algorithm environment:
    1. Enter an encapsulated TeX field.
    2. In the entry area, type \begin{algorithm} and choose OK.
  4. Type the commands for the entire algorithm.
  5. End the algorithm environment:
    1. Enter an encapsulated TeX field.
    2. Type \end{algorithm}and choose OK.

How to add a list of algorithms to your document

  1. Place the insertion point at the beginning of the body of your document.
  2. Enter an encapsulated TeX field.
  3. Type \listofalgorithms and choose OK.
  4. Save the document.
  5. From outside SWP or SW, typeset compile the document file:
    1. From the SWP or SW submenu on the Windows Programs list, choose the TrueTeX Formatter.
    2. Select the document and choose OK.
      LaTeX generates an .loa file for the document.
  6. Typeset preview the document.

The package is installed in the TCITeX/TeX/LaTeX/contrib/algorithms directory of your program installation.

Last revised 01/19/06

This document was created with Scientific WorkPlace.