# Thoughts on LibreOffice Math

Regina Henschel rb.henschel at t-online.de
Mon Jun 24 05:23:07 PDT 2013

Hi Frédéric,

Frédéric WANG schrieb:
> Hi all,
>
> My name is Frédéric Wang and as some you may have noticed, I've recently
> contributed some patches for the LibreOffice Formula Editor. For those
> who don't know me: I work for the MathJax project, I've been
> contributing to the Mozilla MathML project for several years and I
> recently started to do some developments on MathML in WebKit too.
>
> Some people on the MathJax user list reported issues with the
> mathematical formulas generated with LibreOffice and it turned out that
> the exported MathML code is currently quite bad.

Can you please describe in more details what is wrong with the exported
MathML? LibreOffice uses "Presentation Markup" and not "Content Markup".
But besides that, what is bad?

Hence I looked into the
> LibreOffice Math a few days ago, reported bugs and submitted a few
> patches. I'd like to share my thoughts on the situation and future of
> LibreOffice Math. Thomas Lange a message a long time ago about how Math
> could evolved:
> http://www.mail-archive.com/dev@sw.openoffice.org/msg00200.html. First,
> I note the following requirements:
>
> 1) Some people like the current Math semi-WYSIWYG interface and are
> familiar with the StarMath syntax. So this interface should be preserved
> anyway.
> 2) Some people would like a complete WYSIWYG editor.
> 3) Some people would like a LaTeX input mode to enter mathematical
> formulas (like in Abiword)
> 4) Some people (at least the MathML & MathJax communities) would like
> MathML import/export

MathML import and export is already available. What is needed in addition?

and copy and paste, like in Microsoft Word. It is
> also a requirement of the ODT format.
> 5) Some people would like a high quality rendering (e.g. for printing,
> to export to SVG etc). This is subjective but that would mean at least
> the quality level of documents generated by Microsoft Word or LaTeX.
>
> Currently, LibreOffice Math is centered around its StarMath syntax and
> internal tree structure, which make 1) possible and there is already an
> experimental visual editor to do 2). As I read the code, the MathML
> export is not very good but that can be improved. However, importing
> from more expressive language like LaTeX or MathML seems very hard and
> makes 3) and 4) unlikely. I didn't look at the rendering code, but
> Khaled Hosny mentioned on bug 32362 that it would have to be rewritten
> from scratch and I suspect one issue is the StarMath internal tree.
>
> I'd like to propose to center LibreOffice Math around the MathML syntax
> (and corresponding DOM structure) instead:
>
> * I hope I can improve the code to get a decent MathML export and thus
> 1) and 2) could be preserved.

Do you want an export to Content Markup?

It would still be possible to keep the UI
> to work directly on the MathML DOM.
> * For 3), there are many LaTeX to MathML converters like itex2MML (used
> in Abiword), BlahTeX, MathJax etc that could be integrated in LibreOffice.
> * This would obviously make 4) easy. MathML has a <semantics> element
> which is currently used to store the StarMath syntax

The StarMath code is stored in the <annotation> element.

and could be used
> to store LaTeX too. Davide Carlisle also has an XSLT stylesheet to
> convert MathML code to LaTeX.
> * Microsoft Word uses an XML language for mathematics similar to MathML
> so it should be possible to get 5). Khaled Hosny mentioned a fork of
> GtkMathView that has support for Open Type MATH and can produce a good
> rendering. It takes MathML as input and can export PNG or SVG images.
>

Export to PNG already exists but needs improvement.

There are not only the large goals you have outlined, but a lot of
enhancement request, which are open for many years, like arbitrary
colors, storing in Gallery, better integral sign.

The Math module has got very small enhancements in the last years. It
would be really good, if you can help in that area.

Kind regards
Regina