BEST PRACTICES: Displaying mathematical formulas in WordPress using LaTeX
by Viewmark
Recently, we were asked to look into the best ways of displaying mathematical symbols and formulas in a WordPress blog posting. The author was having trouble generating all the necessary elements for their post using the available functionality in WordPress so they ask us to look into the options and provided us with an article formatted as a Microsoft Word document.
At first, we tried to use the Microsoft Word document. We started with a simple cut and paste from Word to WordPress. This has always been unpredictable and this time around was certainly no exception. Converting the file to a standard text file worked better, but we lost the special characters and formatting in the process.
Next, we tried saving the Word file as HTML, but then we were presented with the challenge of sifting through an enormous amount of extraneous code and files for input into WordPress. This was frustrating because our formulas were converted to a series of files and images that didn’t display as they did in Word.
A simple search on the phrase “displaying mathematical formulas using HTML” will give you all the links needed to get the background on this topic. At some point, you’ll find that TeX is semantically superior to HTML and that LaTeX is widely used in the scientific community for blog postings similar to ours.
Installing LaTeX in WordPress was not easy. There are a lot of steps, the files are big and it takes time. It’s also important to have the latest version of WordPress running since we ran into issues moving our installation from our development environment to our client’s production server without synchronizing our WordPress versions.
In our WordPress post there were various symbols that could be addressed with character entity reference (i.e. the Greek small letter mu (μ) has a character reference of (ampersand-mu-semicolon) in HTML 4.0). Several parameters were subscript and superscript, but it was simple to nest the character entity references in the HTML tags as needed, but for the more complex equations we needed to enhance basic HTML functionality with LaTeX.
Here’s one of the equations from the blog post:

Here’s the TeX code for the equation in the post:
$latex \displaystyle S_q = \sqrt{\frac{1}{MN} \sum_{k=0}^{M-1} \sum_{l=0}^{N-1} [z(x_k,y_l)-\mu]^2} $
Here’s a link to the final post:
http://nano.tm.agilent.com/blog/2008/02/04/rms-roughness-the-measurement-that-may-sometimes-be-skewed/
For us, LaTeX worked great. It is ideal for WordPress authors that deal with mathematical formulas and don’t want to be bothered with the tedious tasks associated with generating HTML and images to support their postings.
