aliquote.org

Syntax highlighting in Latex

December 26, 2010

I just discovered the minted $\LaTeX$ package to highlight source code. Perfect! I never liked the listings package.

Minted has been developed by Konrad Rudolph. It relies on Pygments which is easily installed using, e.g.:

$ sudo easy_install Pygments
$ cat > 1.py
import numpy
print numpy.__version__
^D
$ pygmentize -f html -O full -o 1.html 1.py

Here is a short example of rendering R and Python code:

The source file is here: test_minted.tex. To compile, just run:

$ xelatex -shell-escape test_minted.tex

What I like is:

I seem to remember having tried the highlight program, but I cannot find any trace of it on my old computer.

See Also

» Switching to Biblatex » Upgrading Context