# Blog de Frédéric

## Tag - latex

Wednesday, November 14 2012

## Writing mathematics in emails

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 [itex] 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!

Thursday, September 13 2012

## Master Thesis, LaTeXML and Quantum Groups (part 1)

I wanted to wait for my oral defense before blogging about my master thesis and how I manage to publish Web and paper versions of it. However, I finally met my supervisor today and the oral defense is only likely to take place next Wednesday. I do not want to delay too much this blog post and thus decided to publish it today...

This year, I have taken the following approach to write my master thesis: from LaTeX input files, I used XeLaTeX to generate a pdf document and LaTeXML to generate HTML+MathML Web pages. I had to handle some small differences via separate configuration files. However in general, these two tools are compatible and accept more or less the same LaTeX input. I did not really have to make graphics: I only used the amscd package to draw simple commutative diagrams and did not try to draw schemas for representations of quantum groups. Hence I did not get the opportunity to test how LaTeXML can generate MathML inside SVG, although I saw on July something interesting for Firefox on the LaTeXML mailing list.

The pdf version provides a good print layout which allows to workaround some issues that I had two years ago when I printed my Master Thesis in Computer Science directly from Firefox. XeLaTeX also seems much faster and so more convenient to use when you only want to check that your LaTeX code is syntactically correct and get a quick preview. It seems that XeLaTeX uses a kind of cache: there are intermediary files that I guess are used again when you regenerate the document. In contrast, LaTeXML seems to always regenerate one big XML file in a first step and the Web pages in a second step. Perhaps LaTeXML has an option to avoid that behavior or perhaps the idea of a cache system does not work well in the case of Web pages.

The output of LaTeXML has the classical advantages of HTML+MathML for publication on the Web and is much more comfortable to read on a screen. Generally speaking, I think Firefox renders pretty well the LaTeXML output. LaTeXML generates HTML rows to implement labelling and does not rely on mathvariant, which allow to avoid issues with <mlabeledtr> and token elements. However, I still note some MathML's rendering imperfections which, not surprisingly, have already be mentioned in the MathML project roadmap:

• Linebreaking: bad line breaks inside some equations, apparently those generated by some environments like multline or gathered. Sometimes, I also see bad line breaks around equations for example when they are inside parenthesis.
• Spacing: the lack of support for mtable@rowspacing/columnspacing seems to give wrong spacing inside binom-like notations. For some reason LaTeXML generates <mpadded> elements of zero width in some places and they cause weird overlappings in some summations.
• Operator Stretching: commutative diagrams in the definition of Hopf algebras would look better if we support stretching operators in table cells.

This also gives me the opportunity to report various bugs and give some suggestions to the LaTeXML team, including the use of MathJax (for browsers without MathML support), the replacement of <mfenced> by the equivalent <mrow>, <mo> constructions (better rendering in Firefox), improvement to the generation of headers in HTML5 and more.

The title of my master thesis is "Specialization of Quantum Groups at a Root of Unity and Finite Dimensional Representations". The concept of Quantum Groups is based on ideas from theoretical physics, but I studied these structures from a purely algebraic point of view. That is not likely to be interesting if you have never heard about Lie algebras or are not familiar with representation theory, so I will present my contribution in a separate blog post.