Typesetting an algorithm

A very fundamental topic in computer science is the concept of an algorithm. That's a set of operations performed step by step. The purpose can be calculations or data processing, for example, sorting.

Algorithms can be visualized by a flow chart, which we did in Chapter 9, Creating Graphics. In this recipe, we will print an algorithm using pseudocode with syntax highlighting. Our example will show the calculation for a point in the Mandelbrot set.

How to do it...

We will use the algorithmicx package. For a better explanation, we split the work into many small steps. As with all examples, you can download the complete code from http://latex-cookbook.net, so you don't need to type it. At the end, you will see an image with ...

Get LaTeX Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.