-
-
Notifications
You must be signed in to change notification settings - Fork 75
Description
Hello,
I am currently trying to export \mhchem equations to DocX using Pandoc. Since \mhchem is not supported natively, I transformed the TeX to MathML and then tried to convert the MathML to OOML for Word.
Using https://johnmacfarlane.net/texmath.html I could see that even in the MathML to MathML conversion the zero-width mpadded element is dropped. This would explain the additional horizontal space in the screenshot.
Looking at the OOML that Word produces directly (I am attaching the DocX file) I can see that Word added a <m:zeroWid m:val="1"/> element whereas in the the <m:phant> element in the OOML produced by TeXMath does not have a zero-width thus pushing the 2 down correctly but introducing white space.
Source Equation:
\ce{ H2O }
Resulting MathML (using MathJax):
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow data-mjx-texclass="ORD">
<mrow data-mjx-texclass="ORD">
<mi data-mjx-auto-op="false" mathvariant="normal">H</mi>
</mrow>
<msub>
<mrow data-mjx-texclass="ORD">
<mrow data-mjx-texclass="ORD">
<mpadded width="0">
<mphantom>
<mi>A</mi>
</mphantom>
</mpadded>
</mrow>
</mrow>
<mrow data-mjx-texclass="ORD">
<mrow data-mjx-texclass="ORD">
<mpadded height="0">
<mn>2</mn>
</mpadded>
</mrow>
</mrow>
</msub>
<mrow data-mjx-texclass="ORD">
<mi data-mjx-auto-op="false" mathvariant="normal">O</mi>
</mrow>
</mrow>
</math>
DocX file as produced by Word:
HA2O.docx
I think that using MathML directly could open up a whole other world of equations for researchers, since we would not depend on all packages being available through Pandoc directly. I'd be happy to help and to provide further examples - unfortunately, I do not understand the code base enough to provide a fix or analysis.
Kindly
Frederik
