Typesetting Algorithms in LaTeX
December 7, 2007
I have found two good options for typesetting algorithms in LaTeX. Both
packages, algorithms and algorithm2e, are
both available on CTAN and both are included in standard LaTeX
distributions. You can find both in the Debian/Ubuntu package texlive-science.
While both are very versatile, algorithms seems to be the most
straightforward to use and the output it produces looks more like
language-agnostic pseudocode. On the other hand algorithm2e is a bit more
complicated but more flexible. By default, its output looks more like real
code. By default, lines end in semicolons and comments look like C or C++
comments. This is, of course, all configurable.
If you are just looking for something easy to use, but a bit more
aesthetically pleasing than itemize or enumerate, you would probably like
algorithms. If you’re looking for something more flexible,
such as the ability to define your own keywords, you might try
algorithm2e.