Wild About Math! Making Math fun and accessible

3Jun/0824

Math typesetting system for WordPress

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:
[pmath size=14]e=sum{infty}{n=0}{1/{n!}}[/pmath]
Or this:
[pmath size=12]S(f)(t)=a_{0}+sum{n=1}{+infty}{a_{n} cos(n omega t)+b_{n} sin(n omega t)}[/pmath]
Or this:
[pmath size=10]delim{lbrace}{matrix{3}{1}{{3x-5y+z=0} {sqrt{2}x-7y+8z=0} {x-8y+9z=0}}}{ }[/pmath]
Or this:
[pmath]delim{|}{{1/N} sum{n=1}{N}{gamma(u_n)} - 1/{2 pi} int{0}{2 pi}{gamma(t) dt}}{|} < = epsilon/3[/pmath] 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 [pmath size=12] e^{pi i} + 1 = 0 [/pmath] 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.

Filed under: Reviews Leave a comment
Comments (24) Trackbacks (1)
  1. 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.

  2. 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!

  3. 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:

    [pmath size=14]e^{pi i} + 1 = 0[/pmath]

    Best regards,

    Ron

  4. But I already use latex in wordpress? And in comments, too. What’s the difference?

  5. Jonathan,

    I assume whoever is hosting your blog has latex installed. My ISP doesn’t.

  6. Great site, I’m going to have a look around and come back soon.

  7. 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.

    [pmath size=16]\int_0^{\pi /2} {(x^2 } + \sin x)dx = 2.29[/pmath]

    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.

  8. Yikes, the integral sign didn’t work. I’ll try again.

    [pmath size=16]\[
    \int_0^{\pi /2} {(x^2 } + \sin x)dx = 2.29
    \]
    [/pmath]

    BTW, jsMath can do LaTex in comments, but it is troublesome. I like this WP Math Pub much better already.

  9. I won’t embarrass myself again…

    A suggestion:
    The WP plugin that lets users preview their comments would be a great asset here!

  10. I always wondered how sites like http://www.zadania.info is created (they have tons of mathematical formulas). Now I have an idea.

  11. I think that having LaTex installed is a better idea as it is an industrial standard.

    Most leading math forums is already using Latex.

  12. Dave,

    If whoever is hosting your blag has LaTex or is willing to install it then, sure it’s better.

  13. 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:

    [pmath ]int{0}{pi /2} {(x^2 } + sin x)dx = 2.29[/pmath ]

    or

    [pmath]int{0}{pi /2} {(x^2 } + sin x)dx = 2.29[/pmath]

  14. OK: try again …

    The syntax:
    [pmath ]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[/pmath]

  15. Hum…

    Let’s try one more time…

    [/pmath][pmath]int{0}{pi /2} {(x^2 } + sin x)dx = 2.29[/pmath]

  16. 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.

  17. Zac,

    I’ll install the WP preview comments plugin.

  18. Zac,

    I’ve installed the plugin but the preview of the comment is not rendering this equation:
    [pmath size=14] e^{pi i} + 1 = 0 [/pmath]

    Hmmm….

  19. 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?

  20. Great! Let me try here…

    [pmath] a^2-b^2=(a+b)(a-b) [/pmath]

  21. I use the equation editor gadget form sitmo. It generates links to images (using an webbased editor)

    http://www.sitmo.com/gg/latex/latex2png.2.php?z=100&eq=\int_{0}^{pi%20%2F2}%20{%28x^2%20}%20%2B%20\sin%20x%29dx%20%3D%202.29

  22. Thank you for this link. I will have to check it out. I’m still shocked there’s not a tool bar, even as simple as a Microsoft Word Equation Editor, available to use for mathematical symbols, expressions and equations within WordPress. While I can understand the code used in creating mathematical statements, I find it too cumbersome to write in this fashion. Since my information is for math teachers, I have resorted to creating documents with mathematics in Word and creating a pdf to post. I understand this is somewhat “frowned upon” but I do what I need to do to get information across in an understandable fashion.

  23. On my site (http://obliczone.pl) I use mathjax, see http://www.mathjax.org/ for all informations and “how to use” tutorial. It is efficient and very simple, and moreover you can use it on all types of CMS (WordPress, Joomla etc.).


Leave a comment