jameshunt (.us)

Math on the Web — or — Who Stole My Sigma?

I’ve been meaning to work my way back through Knuth’s Art of Computer Programming, and maybe even Essentials of Programming Languages. I cracked the digital spine on EOPL3 last night, and realized that doing the
exercises was going to require the maths.

Which is no problem, except that I have fallen out of the habit of writing in notebooks. That leaves some digital format, and I immediately thought of my blog! That of course brought up the question at hand: how to display mathematical formulae with beauty and clarity, using only HTML?

$$∑↙{i=0}↖n i={n(n+1)}/2$$

Easy, right?

I’m using a small library called jQMath, that acts like a live, in-browser source filter. It converts tagged regions of text (surrounded by $$) into stylized HTML like the Sigma summation above.

A few things to note:

  1. You must have good Unicode support in your authoring tools
  2. The setup instructions are a little preachy
  3. You really really need good Unicode support…

$$(\table \cos θ, – \sin θ; \sin θ, \cos θ)$$

I ended up rewriting John Gruber’s markdown tool (the one that you can get
from the Ubuntu repos) so that it handled UTF-8 input and produced proper
UTF-8 output. Otherwise, you can’t do much beyond simple ASCII variables:


That works without Unicode, but not much else does. And what’s the point of
having a kick-ass formula renderer if you can’t use the really cool math


As for the setup, all you really have to do is the following:

  1. Link the jqmath.css stylesheet in <HEAD>
  2. Include the jqmath.js and jquery.js libraries somewhere.

Happy Hacking!