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.

Warning: count(): Parameter must be an array or an object that implements Countable in /customers/5/e/0/torsten-schoen.de/httpd.www/wp-includes/class-wp-comment-query.php on line 399

One thought on “Howto Write a Thesis using LaTeX: Algorithms

  1. Pingback: sHowto write a thesis using LaTeX, Part 3: Tips and Tricks | Torsten SchönTorsten Schön

Leave a Reply

Your email address will not be published. Required fields are marked *