How best to include programming source code in LaTeX documents?

As the original developer of minted, that’s of course what I recommend.

It uses Pygments to produce beautifully coloured code, e.g.:

On the other hand, I realize that installing minted isn’t trivial, and it relies on an external program. Simpler, more efficient (very noticeable for a large number of code fragments!) and already installed on most systems – but also less versatile than minted – is the package listings. (Furthermore, listings has a nice feature to break over-long lines automatically and indent them correctly. minted can’t do this.)


Use package listings. But there are other options see: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=codelist.