Inserting Source Code and LaTeX in WordPress

A friend of mine asked me the other day how ‘pretty printed’ source code can be inserted into wordpress posts. Here’s how:

If you have a self-hosted wordpress server, get the plugin ‘SyntaxHighlighter Evolved’. Defaults work fine. If you have a wordpress.com account, the plugin is already. For LaTeX, you need the ‘WP-Latex’ plugin. After that, you can insert the source code using the syntax

[ sourcecode language="lang" ]
 ... code here (there is no space after the [ in the lines above and below).
[ / sourcecode]

You can get a list of supported languages here. Latex code can be inserted using the syntax:

$ latex 2^x $

Again, no space after the $ in the above code. There you go!

2 Comments

  1. day by day wordpress is getting invincible.

  2. recluze

    September 27, 2010 at 2:44 pm

    It’s actually kind of an old trick. I just posted it now.

Leave a Reply

Your email address will not be published.

*

© 2017 recluze

Theme by Anders NorénUp ↑