Howto Write a Thesis using LaTeX: Algorithms

People writing their thesis, paper or any other report with LaTeX tend to have some connection to programming. Thus, it is not uncommon to include some algorithms in the document. I prefer using the algorithmic package for providing source code. To include the package, add the following lines to the preamble in file Thesis.tex.

\usepackage{algorithm}
\usepackage{algorithmic}

Inserting an algorithm is then pretty straight forward, you only need to know the algorithmic specific commands, for a description, see for example http://en.wikibooks.org/wiki/LaTeX/Algorithms.

\begin{algorithm}[ht]
\caption{See how easy it is to provide algorithms}
\label{myFirstAlgorithm}
\begin{algorithmic}
\REQUIRE $a$
\STATE $b = 0$
\STATE $x \leftarrow 1:10$
\FORALL{x}
	\STATE $b = b+a$
\ENDFOR
\RETURN $b$
\end{algorithmic}
\end{algorithm}

Algorithms can be referenced like an image, by calling:

??

If you like to include a list of algorithms at the end of your thesis, simply write

\listofalgorithms

at the position you want the list to appear.