Writer / MS Word compatibility for equations?

I recently got into a situation, where I have to provide a DOCX version of a mathematical document I have originally written in Libreoffice Writer. I usually use Libreoffice Math rather than addon-based solutions.

When opening the ODT file in MS Office, it reports an error and all equations are missing.

When using “save copy” to DOCX, some formatting commands are lost, e.g. bold. Since it is common to write vectors and matrices as upright bold characters (bold "M" cdot bold "x" in Libreoffice Math) that constitutes an issue.

For the use-case of “editing in Writer, but providing a DOCX version”, what is the best way to handle equations?

Since I have no Word to test for it, I can only suggest workaround you’ll have to check.

Try to paste the equation as an image. Make sure there is no scaling issue when converted to .docx otherwise the equation will look blurred.

1 Like

I also can’t test with any MS Word, but the export to DOCX (whereof even MS seems to not know how this “international standard” is actually specified) was improved more than once.
Since ODF is writing formulas to files in MathML code, and Word (or some associated component) can interpret MathML as I was told here (silly clip instead of clear info; sorry), your results on export may seriously depend on the version of your LibO and of the Word another party is using. What version is yours?

My test with the two supported (by LibO) variants of DOCX written by LibO V resulted in files at least correctly re-read with LibO. Of course, TDF may be expected to know OOXML better than MS.

demoFormulaExport_ODF.odt (12.5 KB)
demoFormulaExport_OOXML.docx (4.7 KB)
demoFormulaExport_2007_365.docx (4.7 KB)
I didn’t yet experiment with your specific issue concerning boöls parts.

=== editing ===
Sorry. I meanwhile did, and learned that the “bold” attribute actually was missing in both the re-loaded DOCX versions.
Have no clue so far what to suggest.
//next investigation showed me:
Problem seems to be introduced on export. The document.xml wrapped into the OOXML file (which contains the MathML part) nowhere has a related tag to a “bold” setting, while the ODF version of my reworked example contained

<mstyle mathvariant="bold">

The respective content of the OOXML file isn’t MathML at all, but some slang I don’t know anything of. I don’t know if that slang has a way to set the “bold” attribute at all.
I can’t do anything more now.

1 Like

Would this require manually copy/paste-converting each equation? Then it would not be viable in terms of effort and editability.

I personally can’t tell you anything concerning this additional question.
If the MS way to describe Formulas and to write them to files has means at all for the needed attributes, and you know a text describing them correctly, you can probably wite some code (in a general purpose programming language) to “repair” the bad export in the file. It may even be possible (though not simple), to do it with the help of an XML editor. (I used Notepad++ with extensions.)
A bug report may help to get it clear (at least) if the missing attributes in the exported vesions actually are a bug, or were knowingly accepted due to fundamental incompatibilities.

Just an additional hint.
In LibO a Math formula is inserted as an OLE object, and it is saved in the respective way in the file. It’s not inside the top-level content.xml there, but in an additional content.xml placed in a wrapped-in subfolder. To get it displayed in the correct place it (the hosting frame) an anchor is placed somewere in the text.
Having inspected (first time in life) an DOCX file, it seems that Word there is treating formulas as special parts of the general text. Probably elements of a formula can then accept text attributes in the same way as ordinary text does. I simply don’t know,

I thought there was a possibility in Math to specify an output format. Unfortunately, this is possible only through export, creating a new file (PNG, JPEG, PDF or other) and inserting the resulting image in Writer manually to replace the formula object.

So it requires some effort to put things in place. It is up to you to decide if it is worth it.

Editability: no problem but less user-friendly. You keep your formulas as .odf files which you can edit but you must re-export after the edit. Depending on how the “images” are inserted in Writer you may have automatic updates without the need to re-insert them.

If this is a one-off situation, based on what Lupp found out, have you considered whether bolding happens in regular enough circumstances to use an XSLT transformation to add it back to the content.xml or settings.xml for each ObjectN in the odt zip directory? The idea is outside my wheel house, but thought I’d throw it out there…although quickly trying to hand add bold tagging within the content.xml of the math object isn’t working for me loading the ODT into Word 2016.