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.

link|improve this question

Thank you for your answers! – Masi Jul 27 '09 at 23:40
feedback

2 Answers

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...

http://code.google.com/p/google-code-prettify/

I use this plug-in on my website: http://rsolberg.com/ViewBlog/2

StackOverflow also uses it!

link|improve this answer
feedback

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.

link|improve this answer
1  
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
feedback

Your Answer

 
or
required, but never shown

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