For a lot of languages, [lgrind][1] gives nice results, but it is n longer maintained and a bit long in the tooth. The [listings][2] package is a bit more modern. [1]: http://www.ctan.org/pkg/lgrind [2]: http://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings