Output sympy equation to word using mathml

393 views
Skip to first unread message

Yuxiang Wang

unread,
Dec 1, 2016, 5:14:49 PM12/1/16
to sympy
(cross-posting between here and SO)

Dear all,

It seems that MathML works OK with my word with simple copy and paste for strings such as
<math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mn>1</mn><mn>2</mn></mfrac></math>


But when I try to use sympy's mathml printer:

from sympy import S
from sympy.printing.mathml import mathml
my_eqn = S(1) / 2
print(mathml(my_eqn))


The output is:

<apply><divide/><cn>1</cn><cn>2</cn></apply>


And I cannot copy and paste it into word to make it a Word equation.


Could anyone please help?


Thank you,


Shawn

Aaron Meurer

unread,
Dec 1, 2016, 5:25:32 PM12/1/16
to sy...@googlegroups.com
(cross posting my SO answer here)

Looks like the MathML that works is [presentation
MathML](https://en.wikipedia.org/wiki/MathML#Presentation_MathML),
whereas SymPy outputs [content
MathML](https://en.wikipedia.org/wiki/MathML#Content_MathML).
Unsurprisingly, Word is unable to convert from content to
presentation, as that requires some degree of mathematical knowledge
on the part of the software.

SymPy [probably ought to
support](https://github.com/sympy/sympy/issues/11893) outputting
presentation format, but until that is implemented, you might try to
find some other software that can convert between the two (I don't
know of any myself, unfortunately).

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/7ffc6145-0c00-4911-86fb-db8bb6ade0a5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Denis Akhiyarov

unread,
Dec 5, 2016, 4:09:02 AM12/5/16
to sympy
Not cross-posting from SO:

WORD supports LATEX, so does SYMPY.

Here are more details:

http://superuser.com/a/509805/299586

Reply all
Reply to author
Forward
0 new messages