Book Image

LaTeX Cookbook

By : Stefan Kottwitz
Book Image

LaTeX Cookbook

By: Stefan Kottwitz

Overview of this book

LaTeX is a high-quality typesetting software and is very popular, especially among scientists. Its programming language gives you full control over every aspect of your documents, no matter how complex they are. LaTeX's huge amount of customizable templates and supporting packages cover most aspects of writing with embedded typographic expertise. With this book you will learn to leverage the capabilities of the latest document classes and explore the functionalities of the newest packages. The book starts with examples of common document types. It provides you with samples for tuning text design, using fonts, embedding images, and creating legible tables. Common document parts such as the bibliography, glossary, and index are covered, with LaTeX's modern approach.You will learn how to create excellent graphics directly within LaTeX, including diagrams and plots quickly and easily. Finally, you will discover how to use the new engines XeTeX and LuaTeX for advanced programming and calculating with LaTeX. The example-driven approach of this book is sure to increase your productivity.
Table of Contents (19 chapters)
LaTeX Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 the output. You can switch to the output image and back to the how-to, to see how we build the algorithm layout step by step. Here it goes:

  1. As usual, start with a document class:

    \documentclass{article}
  2. Load packages you intend to use. In this case, we...