In Microsoft word, I can paste the following MathML equation and it will become an editable equation <math xmlns="http://www.w3.org/1998/Math/MathML"><msqrt><mn>56</mn></msqrt></math> which is square root of 56.

However, when I add a textrun of the same string using Docx, it just appears as text.

Can there be support for the equations? If there already is, can there be documentation for it?
Will prioritize!
Thanks
Will prioritize!
Thanks
Thank you so much! Please do keep this post updated and if you can, an ETA would be greatly appreciated. We are also willing to help as time is available if you need (though we would need quite a bit of direction).
Did some research, sadly it's not so easy as Office uses a variation of MathML:

I think pasting MathML works in Word is because Word does some conversion
@dolanmiu I have looked around, and it looks like it is using something call OMML (Ecma Math or Office Math) and it comes with Microsoft office. The python docx package seems to have done this here: https://github.com/python-openxml/python-docx/issues/320#issuecomment-288073960
Do you think it would be possible to do something like this?
I think I found something! Is this what we would need? https://stackoverflow.com/questions/10993621/openxml-sdk-and-mathml/11004619#11004619
I was thinking of implementing it all in JS, so the API will be in code, there wont be any copy and pasting the raw MathML going on.
In the link you provided, it says:
In conjunction with the .Net Framework class XslCompiledTransform we are able to transform presentation MathML into Office MathML.
Not going to use the .NET framework in this library
I was thinking of implementing it all in JS, so the API will be in code, there wont be any copy and pasting the raw
MathMLgoing on.In the link you provided, it says:
In conjunction with the .Net Framework class XslCompiledTransform we are able to transform presentation MathML into Office MathML.
Not going to use the .NET framework in this library
Any update on this? If not, any suggestion on how i can proceed with implementing it?
Leave this feature out until after 5.0.0 is released! (Will be soon)
This feature is in progress now
Any progress on this feature? I know it's obscure and ill-documented, but I think can amount to just adding mml2omml.xsl as a style header.
Hi @dolanmiu! Is there any prevision of merging this PR? We are really needing this feature at Mettzer :D We can help if this is necessary.
Soon! After v5 is released
This will be in 5.1.0
Hi @dolanmiu. How it goes? Now we are on 5.3.0. Do you expect it anytime soon?
Hi @dolanmiu. How it goes? Now we are on 5.3.0. Do you expect it anytime soon?
https://github.com/dolanmiu/docx/pull/381
Done now! Will be released in 5.4.0
Documentation here: https://docx.js.org/#/usage/math
@dolanmiu Thanks for the great Math implementation! It works really well.
Is there a way to configure a Word doc to display equations as "Professional" by default?
@douglance Could you elaborate what that means?
@dolanmiu Happy to!
By default, embedding a LaTeX equation in a MathRun displays like this:

But if you click this in Word:

It displays the equation in "Professional" mode that displays the equations as, well, equations:

I am wondering if there's a way to configure the equations to display in that "Professional" mode by default using DOCX.js.
@douglance That is very cool! Does this mean people can write in LateX and directly paste the equation into docx? I will look into this
@dolanmiu Yes. It even works using DOCX.js to simply create a MathRun() using the LaTeX syntax directly. Word has its own specific syntax, so not everything translates directly, but for ~80% of things it works as expected.
I am building a tool that lets people compose with LaTeX in the browser (using Katex and ProseMirror) and to download their draft for Word using DOCX.js. So this Math implementation has been a godsend for my project. Thanks again!
Did some digging, and it does not seem possible
Microsoft Word has some sort of Latex equation to MathML transpiler in their software.
Something like this: https://dlmf.nist.gov/LaTeXML/
Unless you would like to write one for docx :P
@dolanmiu Sorry if I was unclear. I am asking only about the "Professional" view. Inserting LaTeX already works right now. It doesn't cover all the possible operations.
If you do MathRun('e=mc^2') in the latest docx it inserts it into the Word Doc, no problem. Then you just need to change the display mode to "Professional" to see it with the nice notation.
I was wondering if you can set that display mode in the Word Doc itself while generating it. I couldn't find the setting in the Word XML.
Yeah I understand what you're saying, but I am saying that the "Professional view" you speak of is not part of the OOXML spec, and is part of Microsoft Word itself
It will be difficult to re-create that feature
It isn't a simple on/off switch
Most helpful comment
Hi @dolanmiu! Is there any prevision of merging this PR? We are really needing this feature at Mettzer :D We can help if this is necessary.