Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 would like to know how you can syntax highlighting in a LaTex document for codes.

An example of such document is this guide about a Pyhton library and Page 9.

Perhaps, the document is not built by LaTex. Perhaps, by Markdown and with some addons.

share|improve this question
Thank you for your answers! – Masi Jul 27 '09 at 23:40
up vote 1 down vote accepted

I'm guessing that you can look at Prettify. You might be able to create a custom CSS file for LaTeX and get Prettify set up for it...

I use this plug-in on my website:

StackOverflow also uses it!

share|improve this answer

The listings package is one way to include syntax-highlighted source code listings in a LaTeX document. For other options, see the relevant entry in the TeX FAQ.

share|improve this answer
listings unfortunately has several shortcomings in that it only highlights what it thinks might be nice to highlight instead of having a grammar for the languages. It does weird things on floating point numbers in exponential notation, for example. That being said, I don't know a better replacement, sadly. – Joey Jul 30 '09 at 14:14

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.