Geek stuff, resources, Tutorials

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!

Advertisements

2 thoughts on “Inserting Source Code and LaTeX in WordPress”

Comments are closed.