up vote 5 down vote favorite
share [g+] share [fb]

I am planning to write a technical article which will contain text, figures, pseudocode (algorithm) and actual code snippets. My main concern is the Code snippet part and I want really want good syntax highlighting.

I would prefer the output to be PDF format, not HTML.

I am comfortable with LaTeX. I've heard about Sphinx, Pygments too.

Which tool would you prefer?

Pygments seems to be a really nice tool to me and it has syntax highlighting that i need. I tried some code online. But I don't know if Pygments can be combined with LaTeX. If possible, then I would definitely use it, since I am comfortable with LaTeX.

link|improve this question
2  
This question (and especially the answer(s)) is sufficiently useful to programmers that I oppose closing it. – Carl Smotricz Dec 15 '09 at 6:41
For completeness (rather than because I think that this move was ill done) see meta.stackoverflow.com/questions/12918/… and meta.stackoverflow.com/questions/7135/… – dmckee Dec 15 '09 at 21:48
feedback

migrated from stackoverflow.com Dec 15 '09 at 14:00

This question came from our site for professional and enthusiast programmers.

3 Answers

I would go with Sphinx, which can use Pygments if installed for syntax highlighting. As you probably know, Sphinx generates Latex and HTML, and both have hyperlinks that are nice to have. Sphinx also gives you a lot of freedom by templating—so you can choose your Latex and HTML outputs exactly the way you want.

I have started using it for a textbook I'm writing, and I find it very capable of doing cool things. If you have figures, you can use matplotlib to create them, and their Sphinx extension to automatically generate the figures and put them in your document. Have a look at matplotlib documentation for more.

If you want to go with Latex, and want to make good-looking drawings, I would suggest pgf/Tikz (see examples), and/or sketch 3D (a nice write-up on sketch 3D).

link|improve this answer
feedback

OpenOffice or Word?

link|improve this answer
can you do syntax coloring with those ? – Stefano Borini Dec 15 '09 at 9:45
absolutely! Use CTRL-F to find the keywords you want to highlight, then click on "Format | Font | Color "... – Carl Smotricz Dec 15 '09 at 12:24
Alas, within most corporate environments, no one would even consider letting you write documentation in anything other than Word :( – Carl Smotricz Dec 15 '09 at 12:25
I find that hard to believe - what sort of company would actually use word for technical use! – Rich Bradshaw Dec 15 '09 at 14:07
Rich - I'd have to agree with Carl. Word is an accessible tool that is already on most desktop PCs. People are familiar with it, whether it's "the best" or not. – ralford Dec 15 '09 at 14:21
feedback

Have you looked at listings.sty? It supports a rather inclusive set of languages, and is actively maintained.

The manual discusses many alternatives for syntax highlighting in latex.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown