I want to print an example source file so that I can study it. How do I print it with syntax highlighting? I'm currently using TeXShop in MacTeX; apparently it doesn't have this ability. What program do you recommend to do this?
You could try including the code inside another document using the minted package -- I don't think the listings package does colored syntax highlighting by default, but minted does.
How about typesetting the source using the
listings package and then printing the resultant pdf?
1This seems a little roundabout: put the whole source inside a
listingsenvironment in another tex file and compile that. Surely there's an easier way to just print the plaintext, suitably coloured...– SeamusOct 23, 2010 at 12:44
6@Seamus: well you can use
\lstinputlistingso you don’t need to do any copy&paste acrobatics. That’s not all that roundabout. Oct 23, 2010 at 14:30
Ah I didn't know that– SeamusOct 23, 2010 at 14:45
Emacs with auctex.
Actually it will work without auctex too, but that would be silly.
2Or from gvim or gedit (probably not available on mac) or many other good text editors.– CaramdirOct 23, 2010 at 16:09
gedit with the latex plugin. gedit with latex plugin and embedded terminal I prefer over all of the latex IDEs. Highlight printing should be default.
Try the Highlight Code Converter Produces highlighted code for a ton of languages, plus you can always write your own syntax file if the language you want isn't include. Free (under GPL3), available for most flavors of Linux, Windows, and Mac. Outputs in HTML, XHTML, TeX, LaTeX, RTF, XML, and SVG. Colors are easily customized.