TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 6 down vote accepted

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.

share|improve this answer
minted and Pygments really do their job well :) – Kit Nov 3 '10 at 23:56

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

share|improve this answer
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 '10 at 12:44
@Seamus: well you can use \lstinputlisting so you don’t need to do any copy&paste acrobatics. That’s not all that roundabout. – Konrad Rudolph Oct 23 '10 at 14:30
Ah I didn't know that – Seamus Oct 23 '10 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.

share|improve this answer
Or from gvim or gedit (probably not available on mac) or many other good text editors. – Caramdir Oct 23 '10 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.

share|improve this answer
AFAIK, gedit doesn't need a plugin to highlight latex. – Kartik Jan 20 '14 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.