## Writing mathematics in emails

By fredw on Wednesday, November 14 2012, 20:35 - Permalink

People writing mathematics in emails, like researchers in mathematics or physics, have probably encountered this difficulty to properly format complex mathematical formulas. The most common technique is just to write text with LaTeX-like or ASCIIMathML-like syntax and hope that the recipient will just understand the expressions. Obviously, this is not really convenient to write and read, some errors may happen and result in misunderstandings between the sender and the recipient. There are other classical issues like how to write the math (special syntax? math panel? handwriting recognition?), accessibility, rendering quality etc Of course, these issues are well-known and expected to be addressed by MathML. Since HTML is a common format for email and MathML is now part of HTML5, this is clearly a good candidate to solve the problem of mathematics in emails.

The idea to use MathML in emails is not new and was already suggested in a screenshot from the Mozilla MathML Project more than 10 years ago. Thunderbird has been able to render MathML in newsfeeds for a long time, provided that the author served his content as XHTML. I may also mention Amaya, which added support for sending a document by email in 2007, although I have never figured out how to configure it to send emails. Two years ago, I tried without success to fix a bug to display XHTML attachment inline and which could be a partial solution to the problem. Finally, one year ago Bob Mathews (from Design Science) asked me about the status of MathML in Thunderbird, and I could unfortunately not give him a better answer than what is in the present paragraph. But I hoped that MathML in HTML5 will change the situation.

Indeed, while I was working on some MathML-in-clipboard patches, I realized that it is now possible to paste MathML inside an email. After further discussions with Bob Mathews, Paul Topping & David Carlisle, I've been able to do more testing. The situation is the following:

- Thunderbird can send emails containing MathML and render them correctly.
- Apple Mail (used in Mac OS X and iOS) can receive emails containing MathML and should render them correctly since MathML is enabled in Apple's products.
- Microsoft Outlook does not render MathML in emails. However the rendering is based on Microsoft Word which has MathML support. Basically, Thunderbird sends MathML in HTML5 and Word displays MathML after an XSLT conversion into Microsoft's own OMML format. Hence Microsoft might be able to do something not too complicated to make the whole stuff work.
- Web Mail Clients like Gmail or Zimbra seem to filter the MathML in emails and so do not render it correctly. If this filter is removed, they can certainly let the browser do the rendering job or use MathJax to do so.

Now let's consider a basic example about how to send MathML in emails, using
Thunderbird. One of the issue is that Gecko's editor has really been designed
with only HTML-editing features in mind and if you start editing MathML formulas you are
going to get some invalid markup messages or other troubles. And of course
Thunderbird does not have any math panel or other WYSIWYG tools to write
mathematics. However it might not be too difficult to write an add-on to add
MathML editing features in Thunderbird like BlueGriffon's
add-on or Firemath (these add-on
might even be installed without too much trouble in Thunderbird). Or one can of
course use one of the existing
tools to generate MathML and just paste the code in Thunderbird. Here I'm
going to use the `itex2MML`

filter. So first write your mail in a
separate text file:

mail.txt Hi Matthew, I just read your email about the behavior of the factorial function and harmonic series for large values of $n$. If you denote by $\gamma \approx 0.5772156649$ the Euler's number, by $e \approx 2.7182818284$ the Euler's constant then you have the well-known Stirling's approximation: $$n! = \sqrt{2 \pi n} {\left( \frac{n}{e} \right)}^n \left( 1 + O \left( \frac{1}{n} \right) \right)$$ where of course I use the classical constant $\pi \approx 3.1415926535$. We also have the following asymptotic expansion: $$\sum_{k=1}^n \frac{1}{k} = \ln(n) + \gamma + O \left( \frac{1}{n} \right)$$ I hope that this answers your question.

then call `itex2MML`

to replace the LaTeX code by
`<math>`

elements:

cat mail.txt | itex2MML > mail.html

Write a new mail in Thunderbird and use the menu "Insert ; HTML" . David
Carlisle told me that you have to be sure that the "send as HTML" is enabled if
it does not show up. Then just copy the `mail.html`

source into the
window:

Once you click the insert button, the MathML should be automatically rendered in Thunderbird:

When your email is ready, just send it as usual! Here is how it appears on an iPod:

Let's just hope that other mail clients will support MathML in emails!

## Comments

Please, please, keep me in the loop on this! I am working on my prototype XML editor still, and one of the top three use cases I have in mind is mathematics (and SVG) in a Thunderbird-like application.

@Alex Vincent: Sure. Currently, I'm trying to implement the MathML clipboard features, which would allow your editor and other applications to better transfer MathML formulas. In the future I would also like the MathML team to work on improving the editor. But I see you already looked at this in the past and so you probably know that's it's going to be a lot of work...

BTW, for those who wonder: you can also send/receive mails containing SVG in Thunderbird and the SVG is displayed correctly in Apple mail.

I'm amused that Thunderbird's spellchecker highlights π. It should probably ignore text inside MathML.

Does this blog accept MathML in comments? ;)

@Jesse: I guess you are right, that's probably another issue to address regarding MathML in Gecko's editor... No, MathML and more generally HTML5 is not allowed in visitor's comments, mostly because I'm too lazy to install a html filter and moreover I believe nobody is really willing to write MathML by hand :-) So I only parse LaTeX commands via MathJax.

Latest Updates:

~~Opera's built-in mail client can send and receive MathML.~~update: what about Opera Blink? does it still have a built-in mail client?Outlook for Mac uses WebKit, so unless it does extra filtering, it should send and receive MathML too.

Is copy & paste the biggest win to getting MathML into email, or would it be better to have a MathML editor that worked across all Gecko applications?

@Minh: Thank you for the information. That would be great if someone could test and confirm.

@Neil: There are many tools that already support transferring MathML and a clipboard specification is included in the MathML REC, so I think it is a very good idea if Gecko implements it. Typical example would be to use the Windows Math Input Panel to handwrite and directly insert equations in Gecko's editor or to copy a formula on Wikipedia and paste it into a Computer Algebra System for further processing. The possibility to rely on MathML authoring tools to copy and paste MathML in Thunderbird is only one of the aspect. Of course, I agree with you that ideally the editor should be improved to handle MathML (and SVG) better. Although Amaya is sometimes buggy, it does that quite well for example. That's definitely something I would like the MathML team to do and I have a couple of ideas, but that's going to be a lot of work especially if we want something more than just an input box for LaTeX. And as you know Thunderbird, Seamonkey or MathML are currently really community-driven projects, so the development of new features is not always going as fast as we could wish.

Microsoft Outlook has supported math in email since 2007. I use it quite frequently. It doesn't work with MathML, though, and it would be nice to do so. Very interesting blog post.

We at Design Science worked hard to get the MathML Clipboard spec out there. Unfortunately, it is hard to know which applications support it as it is mostly an under-the-covers thing that doesn't make it into feature lists. The same could be said for MathML support in general.

Because our MathType equation editor produces MathML (and LaTeX), we have compiled a list of applications it works with and many support MathML: http://www.dessci.com/en/products/M...

Ok... Give me a few days and I'll have something for you. A real math formula editor for Thunderbird based on ASCIIToMathML.js ?-) Stay tuned.

Hop : http://is.gd/I5KSpV !!

/* enjoy */

Sending and receiving MathML in Opera's built-in mail client works fine as well. Editing is pretty similar to Thunderbird, there's an insert HTML dialog, and if you have HTML mail rendering disabled the result can look a bit confusing...

@Erik: that's cool, thanks for the info! MathML code is often generated and contains e.g. LaTeX source as <semantics> annotation, that could be used in the text-only version of the mail. One could even rely on David Carlisle's MathML to ASCII art XSLT stylesheet or something similar to provide a readable fallback to text-only mail clients.

There a couple of other possiblities:

1. thunderbird + latexit extension.

this generates HTML mail + math in png

format.

the other possibilities are specific to (X)emacs+gnus.

1. HTML+math in png as latexit but implemented differently.

2. UTF8 formulas like ∫ less general than 1 but could be read by

most email readers

3 Using special fonts, this solution can be only displayed by (x)emacs