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?

5 Answers 5


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.

  • 1
    minted and Pygments really do their job well :)
    – Kit
    Nov 3, 2010 at 23:56

How about typesetting the source using the listings package and then printing the resultant pdf?

  • 1
    This seems a little roundabout: put the whole source inside a listings environment in another tex file and compile that. Surely there's an easier way to just print the plaintext, suitably coloured...
    – Seamus
    Oct 23, 2010 at 12:44
  • 6
    @Seamus: well you can use \lstinputlisting so 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
    – Seamus
    Oct 23, 2010 at 14:45

Emacs with auctex.

M-x ps-print-buffer-with-faces

Actually it will work without auctex too, but that would be silly.

  • 2
    Or from gvim or gedit (probably not available on mac) or many other good text editors.
    – Caramdir
    Oct 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.

  • AFAIK, gedit doesn't need a plugin to highlight latex.
    – Kartik
    Jan 20, 2014 at 16:00

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .