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 7.2.3.2 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">
    <mtext>Xantyping</mtext>
</mstyle>

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.

Iโ€™m a couple of years late, butโ€ฆ

Perhaps you could use bold/math Unicode symbols?

๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ๐‰๐Š๐‹๐Œ๐๐Ž๐๐๐‘๐’๐“๐”๐•๐–๐—๐˜๐™ ๐š๐›๐œ๐๐ž๐Ÿ๐ ๐ก๐ข๐ฃ๐ค๐ฅ๐ฆ๐ง๐จ๐ฉ๐ช๐ซ๐ฌ๐ญ๐ฎ๐ฏ๐ฐ๐ฑ๐ฒ๐ณ
๐‘จ๐‘ฉ๐‘ช๐‘ซ๐‘ฌ๐‘ญ๐‘ฎ๐‘ฏ๐‘ฐ๐‘ฑ๐‘ฒ๐‘ณ๐‘ด๐‘ต๐‘ถ๐‘ท๐‘ธ๐‘น๐‘บ๐‘ป๐‘ผ๐‘ฝ๐‘พ๐‘ฟ๐’€๐’ ๐’‚๐’ƒ๐’„๐’…๐’†๐’‡๐’ˆ๐’‰๐’Š๐’‹๐’Œ๐’๐’Ž๐’๐’๐’‘๐’’๐’“๐’”๐’•๐’–๐’—๐’˜๐’™๐’š๐’›
๐—”๐—•๐—–๐——๐—˜๐—™๐—š๐—›๐—œ๐—๐—ž๐—Ÿ๐— ๐—ก๐—ข๐—ฃ๐—ค๐—ฅ๐—ฆ๐—ง๐—จ๐—ฉ๐—ช๐—ซ๐—ฌ๐—ญ ๐—ฎ๐—ฏ๐—ฐ๐—ฑ๐—ฒ๐—ณ๐—ด๐—ต๐—ถ๐—ท๐—ธ๐—น๐—บ๐—ป๐—ผ๐—ฝ๐—พ๐—ฟ๐˜€๐˜๐˜‚๐˜ƒ๐˜„๐˜…๐˜†๐˜‡
๐˜ผ๐˜ฝ๐˜พ๐˜ฟ๐™€๐™๐™‚๐™ƒ๐™„๐™…๐™†๐™‡๐™ˆ๐™‰๐™Š๐™‹๐™Œ๐™๐™Ž๐™๐™๐™‘๐™’๐™“๐™”๐™• ๐™–๐™—๐™˜๐™™๐™š๐™›๐™œ๐™๐™ž๐™Ÿ๐™ ๐™ก๐™ข๐™ฃ๐™ค๐™ฅ๐™ฆ๐™ง๐™จ๐™ฉ๐™ช๐™ซ๐™ฌ๐™ญ๐™ฎ๐™ฏ

Caveat: I havenโ€™t tried it.

Sadly not a very viable solution, as it would result in very slow input speed. It would be possible to define those as special symbols (e.g. %bolda), but that takes some setup effort and would need to be redone for each PC.

I tried the trick of the bold unicode symbols.

  • It works (yay!), MS Word displays the Unicode character as bold;
  • it isnโ€™t very elegant because the Unicode character style does not match the math font.

It isnโ€™t perfect, but itโ€™s already a workaround; it enables me to send a converted .docx document for my colleagues to review and they wonโ€™t complain about the missing bold.