Math typesetting system for Wordpress
June 3rd, 2008 | by Sol |I’ve been wanting for some time to incorporate mathematical equations into my blog posts. What I’ve done up to now is to use this nice web site that Brent from Math Less Traveled pointed me to. You enter a LaTeX expression and the web-site creates an image which you then copy over to your web server and reference from your blog post. This system works great if you only need a small number of images. As an example, I used it to typeset the problem in Monday Math Madness #7.
But, I wanted to be able to easily intersperse Math into a blog post, like this:

Or this:

Or this:

Or this:

One day I received an email from Ron Fredericks letting me know that he had created a Math typesetting plugin for Wordpress. And, it didn’t require me to do something impossible, like trying to get LaTeX installed on my hosted server. This very useful plug-in is described in Ron’s blog. Here’s a link to it.
The plugin is based on powerful but lightweight Php Math Publisher, a nice system for typesetting Math. My hosted Linux server was able to dish up Math symbols just fine. The only problem I had getting Ron’s plugin to work was that I have so many plugins and one of them conflicted with Ron’s. But, I was able to determine which the conflicting plugin was and Ron modified his code to resolve the conflict and all is good.
The Php Math publisher syntax is described here. When you’re using Ron’s wpmathpub plugin, you put special tags into your blog text to invoke the plugin. The tags are [ pmath] to start Math notation, and [ /pmath] to end it. Note that you don’t put spaces in the tags; I’m doing that here to keep them from getting interpreted.
So, to render
you type:
[ pmath size=12] e^{pi i} + 1 = 0 [ /pmath] without the spaces after the left bracket.
Read Ron’s blog post to get started. Scroll down to the “Download Plugin” and you’ll find a bunch of helpful links.
So, if you’re a Math blogger and you use Wordpress, you no longer have an excuse for not including Math symbols in your blog posts. And, please help spread the word.
Great stuff, Ron! Thank you.
If you enjoyed this post, make sure you subscribe to my RSS feed!
20 Responses to “Math typesetting system for Wordpress”
By Mgccl on Jun 3, 2008 | Reply
Or… you can hotlink(steal) wordpress.com’s latex images, which is far more superior than phpmathpublisher.
I only wrote a plugin for Drupal and I have never relased it, but I’m sure it’s easy to get one down for wordpress. and it has been done.
http://www.mikexstudios.com/archives/2007/02/18/parasitelatex-wordpress-latex-plugin/
but was taken down because Matt don’t like this kind of hotlinking.
By n0n4m3 on Jun 3, 2008 | Reply
Hi,
some time ago I created a site ( http://www.pastemath.com ) that would allow people to exchange math formulas easily when having conversations on instant messaging clients like IRC.
From this work was born a plugin for MSN ( http://gallery.live.com/liveitemdetail.aspx?li=fc6c54f3-fa61-42ca-8fd2-6bae407f1de3&l=6 ) that allows two people to exchange equations in real-time in a conversation.
In both you’ll have to use latex to enter the expression but there are some buttons with most common expressions to help those who are not familiar with the syntax. Both of these projects are based on mimetex ( http://www.forkosh.com/mimetex.html ).
Keep up with this great blog!
By Ron Fredericks on Jun 5, 2008 | Reply
Hi Sol:
Thank you for the great write-up on wpmathpub math publisher plugin.
The plugin allows your readers to discuss math with math equations too. Here is an example - just use the same tags in a comment as you used above in your post:
[ pmath size=14 ] e^{pi i} + 1 = 0 [ /pmath ]
Where the white space within the [ pmath ] tag itself should be removed, as shown here:
Best regards,
Ron
By Jonathan on Jun 5, 2008 | Reply
But I already use latex in wordpress? And in comments, too. What’s the difference?
By Sol on Jun 5, 2008 | Reply
Jonathan,
I assume whoever is hosting your blog has latex installed. My ISP doesn’t.
By Jonathan on Jun 12, 2008 | Reply
Great site, I’m going to have a look around and come back soon.
By Zac on Jun 19, 2008 | Reply
Hi Sol
Thanks for the heads up on this Wordpress plugin. I’ll try it out when I get a chance. No wait, I’ll try it out right here in your comments. Wish me luck.
My hosting company also didn’t want to install LaTex on the server just for me.
I tried jsMath and here was the result: jsMath in Wordpress blogs.
By Zac on Jun 19, 2008 | Reply
Yikes, the integral sign didn’t work. I’ll try again.
int_0^{pi /2} {(x^2 } + sin x)dx = 2.29
]
BTW, jsMath can do LaTex in comments, but it is troublesome. I like this WP Math Pub much better already.
By Zac on Jun 19, 2008 | Reply
I won’t embarrass myself again…
A suggestion:
The WP plugin that lets users preview their comments would be a great asset here!
By jan on Jun 23, 2008 | Reply
I always wondered how sites like http://www.zadania.info is created (they have tons of mathematical formulas). Now I have an idea.
By Dave S on Jun 28, 2008 | Reply
I think that having LaTex installed is a better idea as it is an industrial standard.
Most leading math forums is already using Latex.
By Sol on Jun 28, 2008 | Reply
Dave,
If whoever is hosting your blag has LaTex or is willing to install it then, sure it’s better.
By Ron Fredericks on Aug 4, 2008 | Reply
Reply to Zac’s comments June 19, 2008…
Hi Zac:
You bring up some good points:
1) How do you do integral math with my plugin?
2) How can you test your phpmathpublisher math syntax before embedding in a comment [that in turn is proably not editable]?
Both questions are easily solved from the documenation at phpmathpublisher web site:
1) all syntax for phpmathpublisher is described and displayed here:
http://www.xm1math.net/phpmathpublisher/doc/help.html
2) a wysiwyg editor for phpmathpublisher equations can be found here:
http://www.xm1math.net/phpmathpublisher/examples/online_demo.php?size=14
Therefore:
I come up with the following fix to Zac’s equation:
or
[pmath]int{0}{pi /2} {(x^2 } + sin x)dx = 2.29
By Ron Fredericks on Aug 4, 2008 | Reply
OK: try again …
The syntax:
int{0}{pi /2} {(x^2 } + sin x)dx = 2.29[/pmath ]
The equation:
[pmath]int{0}{pi /2} {(x^2 } + sin x)dx = 2.29
By Ron Fredericks on Aug 4, 2008 | Reply
Hum…
Let’s try one more time…
[/pmath]
By zac on Aug 6, 2008 | Reply
Thanks for your input, Ron.
The issue that you found (as I did) is that Wordpress has the habit of chewing code. Your second link is very useful - but only if WP chooses not to mangle some of the tags.
My suggestion about the WP preview comments plugin was actually addressed to Sol - it’s a WP user issue, not a WPMathPub issue.
By Sol on Aug 6, 2008 | Reply
Zac,
I’ll install the WP preview comments plugin.
By Sol on Aug 6, 2008 | Reply
Zac,
I’ve installed the plugin but the preview of the comment is not rendering this equation:

Hmmm….
By Zac on Aug 7, 2008 | Reply
Hi Sol. As you can see in the trackback, I had a go myself and the comment preview was just fine.
Just an observation which may be relevant… The first time I came to this page yesterday, the 3rd example above (the 3×3 system of equations) did not render - I just saw the code. I refreshed the page and all was good. I wonder if something similar happened to you with the preview?