## Tuesday, 14 December 2010

### Equations online

Do you need to include equations on your webpage or blog? I didn't think so. But at some point, maybe I will. So I started looking at how to accomplish that. It turns out that, like getting the world to agree on climate change targets, it isn't easy. Here are the options I've found. I'm presuming the kind of person looking to put an equation online is the kind of person who's familiar with LaTeX so all these tools will make use of it.

The language of maths on the web is supposed to be MathML but, although it's been around a while, it's generally poorly adopted. MathML is a part of HTML5, the next najor revision of web-formatting as a whole, but that's a work in progress and implementation is variable. MathML code is also very, very ugly. Given that LaTeX was created to make things more compact, MathML looks like a big step backwards. Apparently this makes it versatile. If I need 23 open and close tags to write the quadratic formula, I'm not convinced that this constitutes progress...

Embedded images

One way of putting equations on your webpage is to create images of your equations and host those. At first glance, that isn't that easy, since you'll want a quick way of producing the images from (La)TeX. Fortunately, CodeCogs have created an online equation editor that'll do the image creation for you. Punch in your equation and you'll be given an image in a chosen format. Better still, you can choose "HTML" from the drop down menu at the bottom and it'll give you an HTML snippet that you can copy. This way they host the image for you. For example,

$G_{\mu\nu}+\Lambda g_{\mu\nu}=\frac{8\pi G}{c^4}T_{\mu\nu}$

Note that on some web interfaces, like Blogger, you may have to flip to editing in HTML mode when you paste. Also, I've chosen PNG as the format but it pixelates when scaled. I'm not sure anything else is much better since implementation is iffy. I'd choose SVG (also part of the HTML5 standard) but Internet Explorer is notorious for being the last major browser that doesn't support it. Then again, it's just another reason you shouldn't be using IE anyway.

JavaScript

Another option is to use JavaScript to generate MathML from (La)TeX markup in the page. Dr Douglas R. Woodall created such a script. A newer version exists but I haven't tried it. You can download the script to your own page or link to the version on his site. Either way, you'll need a snippet like

<script type="text/javascript"
src="http://www.maths.nottingham.ac.uk/personal/drw/LaTeXMathML.js">
</script>

inside the "head" block of your HTML file. All very well on your own site but what about a blog? On Blogger/Blogspot, you can do this by clicking "Design" (top right) then "Edit HTML". Place the snippet above after the <head> tag and you're good to go. I'm not sure how you'd do this on other Blog hosting sites. If you know, feel free to add a comment.

You can now include TeX in \$... \$ blocks. For example,

$G_{\mu\nu}+\Lambda g_{\mu\nu}=\frac{8\pi G}{c^4}T_{\mu\nu}$

produces

$G_{\mu\nu}+\Lambda g_{\mu\nu}=\frac{8\pi G}{c^4}T_{\mu\nu}$

As before, you may need to edit in HTML mode or similar. If you want a plain \$sign, mark it up as \\$. This method might be better for inlining stuff. Also, you might not see that properly in Internet Explorer without the MathPlayer plugin. Did I mention that you shouldn't be using IE?

Pure MathML

The final option is to write your equation in MathML. It's a crap option, even if in the future it's meant to be the most universal. The hard part is converting (La)TeX into MathML. One way of doing this is to create a page using the JavaScript above, selecting the equation portion, right-clicking and selecting "View Selection Source". Well, in Firefox 3.6, anyway. Another way, in theory, might be to use the TeX/LaTeX to MathML Online Translator, except that it appears to load for five minutes and then times out when I try to use it. Did I get your hopes up there? I hope so. It got my hopes up too.

Back on track, this is what the MathML produces here on Blogger.

$Gμν+Λgμν=8πGc4Tμν$

If you want to know, this is the markup that I used:

$<mstyle><mrow><msub><mi>G</mi><mrow><mi>μ</mi><mi>ν</mi></mrow></msub></mrow><mo>+</mo><mo>Λ</mo><mrow><msub><mi>g</mi><mrow><mi>μ</mi><mi>ν</mi></mrow></msub></mrow><mo>=</mo><mfrac><mrow><mn>8</mn><mi>π</mi><mi>G</mi></mrow><mrow><mrow><msup><mi>c</mi><mn>4</mn></msup></mrow></mrow></mfrac><mrow><msub><mi>T</mi><mrow><mi>μ</mi><mi>ν</mi></mrow></msub></mrow></mstyle>$

Did I mention that MathML is ugly? Did you believe me? I bet you do now. There's an obvious catch: this doesn't seem to work! (Let me know what browser you're using if the equation is rendered properly.) I don't understand why not. I'm pretty sure the markup is correct. I tried the example source on Wikipedia and that didn't work either. The JavaScript is turning the TeX markup into MathML, which is then rendered. Yet if I just plug in the MathML, Firefox ignores the tags? I presume there's something about the Blogger implementation that's doing this so it might work on other blogging sites. Either way, it's a lot like my PhD inasmuch as it doesn't make sense.

My choice

Really, MathML should be the way. It should platform-independent and keep the page self-contained. Unfortunately, the Internet cares about standards about as much as Douglas Adams cares about deadlines. Wikipedia realised this too, which is why that invented their own markup that generates embedded images. The same (with CodeCogs' gadget) is my choice for now.

## Friday, 10 December 2010

### LibreOffice 3 Release Candidate

You may have noticed I'm a fan of OpenOffice.org. Well, it's slightly-more-open fork, LibreOffice, has put out a release candidate, putting it one step closer to full release.

It installs alongside OpenOffice.org, unlike the betas, so you can safely take for a test-drive. I've done exactly this on my Eee 1000 and was positively underwhelmed. This looks like a quick exercise in rebranding to establish a community and kickstart the project. I could hardly find any difference between LO RC1 and OOo 3.2. I hope real work is coming in the future because my biggest use case, presentations, are almost entirely unchanged from OpenOffice.org 3.2. If anything, the slide transitions seem to be slower..