Wednesday, January 19, 2011

Using LaTeX from Blogger

So, you've just moved to Blogger and you want to blog with properly typeset equations? That seems like a requirement for some sorts of blogs (possibly not possessing an astoundingly large audience).

Unfortunately, a web search only revealed no ready-made solutions. The most promising option was a Greasemonkey script from Wolverinex021. But, it used a web service to interpret
\LaTeX which is no longer supported. The second most promising option was the wonderful site CodeCogs. CodeCogs has many ways to render \LaTeX, a page on Blogger integration, and two JavaScript scripts to automatically render snippets in the page. There is only one problem with their suggested approach. Most readers use an RSS aggregator to follow feeds, and the JavaScript will be bypassed. But CodeCogs does have a CGI renderer just like the one used by the Greasemonkey script.

All that is needed then is to combine the two options. My trivial contribution to Blogger equation typesetting is this Greasemonkey script.2

The following has changed since the original script:
  • Use CodeCogs for rendering.
  • Use CodeCogs to render the icon in the Blogger editor.
  • Some formatting changes for readability.
  • Support for unrendering. This was a useful missing feature.
  • Added alt text for typeset equations.
Install it as you would any other Greasemonkey script. To install in Chrome, you can save the file and then drag it onto the browser window. In the Blogger rich editor for creating new posts or editing existing posts, there will be two new buttons labelled
\LaTeX and {\rm un}\LaTeX. They do what they say. \LaTeX equations should be included between double dollar signs, not single dollar signs or \(\) or \[\]. And the script will fail miserably if the equations contain double quotes.

Typeset away...


\int_0^1 x^2 dx = \frac{1}{3}

1 I believe this is his blog.
2 In Blogger settings, choose the "old" editor.