The minted package provides automatic syntax highlighting for source code listings. It uses the excellent pygments highlighter, which provides very high quality highlighting for a wide range of languages.
This example also shows how you can use minted to typeset LaTeX math embedded in your source code.
Permission is granted to copy, distribute, and/or modify this document
under the terms of the Creative Commons Attribution-NonCommercial 3.0
Unported License, which is available at
Allen Downey (minor changes by David Topham and Suporn Chenhansa)