LaTeX on WordPress-Hosted Blogs

by

If WordPress is hosting your blog, it’s very easy. For instance, if I type:


The sum of the first $latex n$ integers, 
$latex \sum_{i < n} i = \frac{n(n+1)}{2}$.

what you see is:


The sum of the first n integers, \sum_{i < n} i = \frac{n(n+1)}{2}.


Let me take a second to say

w00t!

and

yatta!

How’s it Work?

It somehow (i.e. no doc on what exacty it does) preprocesses the blog post, and replaces the LaTeX with links to PNG images, such as:

http://s2.wordpress.com/latex.php?latex=n&bg=ffffff&fg=000000&s=0

If you click on the link, you get a PNG image of the letter “n” as set in LaTeX math mode.

More Details

The WordPress Support Page also explains how to change font size and foreground/background colors (you can see the parameters coded into the URL above). It also points out that you can use the usual math packages, amsmath, amsfonts, and amssymb.

Oversearch

Why couldn’t I find this earlier? I thought I needed a plugin, so I searched for [wordpress plugin latex] and then started trying to figure out how to install plugins on WordPress-hosted sites.

Doh!

Escapes All the Way Down

So now the question arises of how I managed to show you this text on the blog, given that WordPress automatically replaces the text


$latex n$

with the relevant LaTeX output?

I know two ways to do this, discovering both of which involved guessing at how the WordPress LaTeX plugin does substitution. You can use a dummy span element, which isn’t rendered as anything in most styles:


<span>$</span>latex n$

or with unicode escapes:


&#x24;latex n$

In general, “&#xNNNN” is the way to include unicode character with code point 0xNNNN (the “NNNN” is a four-digit or two-digit hex number). I wind up spending lots of time looking at unicode.org’s code point charts.

6 Responses to “LaTeX on WordPress-Hosted Blogs”

  1. John Says:

    Most blogs that use embedded LaTeX don’t format correctly in an RSS reader, at least not on the first attempt. But your post looks just fine in Google Reader. Maybe the escape issues you mention are why most people get it wrong.

  2. lingpipe Says:

    Good point — I should’ve tried that myself. I never subscribed to my own blog!

    If you look at the source of the output, it’s just image links. For instance, the first $n$ is just:

    http://s2.wordpress.com/latex.php?latex=n&bg=ffffff&fg=000000&s=0

    If you click on it, you get a PNG image.

    I only needed to escape to show you what the input looked like. I didn’t escape the actual use of LaTeX.

  3. Manos Says:

    WP Latex offers functionality to write LaTEX from your own WordPress installation, either using Automaticc’s servers (the URL given above), or your local LaTEX installation.

  4. lingpipe Says:

    Terence Tao had a bug collection drive which the developers seem to have read and fixed (see the note before the comments). Lots of good general advice for hacking formulas that won’t otherwise display.

  5. Carroll B. Merriman Says:

    Ran across your blog on Google. Interesting perspective. Don’t leave it there. When can we expect more?

  6. matrus Says:

    Nice one. It explains why WordPress is the best websites managing platform, but on the other hand this latex functionality does not support extra packages, which are very usefull in posting advanced equations.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s