使用mathml输出sympy方程式

时间:2021-07-04 20:21:23

It seems that MathML works OK with my word with simple copy and paste for strings such as

似乎MathML可以正常工作,只需简单的复制和粘贴字符串即可

<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:

但是当我尝试使用sympy的mathml打印机时:

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.

而且我无法将其复制并粘贴到word中以使其成为Word等式。

Could anyone please help?

有人可以帮忙吗?

1 个解决方案

#1


4  

Looks like the MathML that works is presentation MathML, whereas SymPy outputs 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.

看起来有效的MathML是演示MathML,而SymPy输出内容MathML。不出所料,Word无法从内容转换为演示文稿,因为这需要软件方面的某种程度的数学知识。

SymPy probably ought to support 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).

SymPy可能应该支持输出演示文稿格式,但在实现之前,您可能会尝试找到一些可以在两者之间进行转换的其他软件(不幸的是,我不知道自己)。

#1


4  

Looks like the MathML that works is presentation MathML, whereas SymPy outputs 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.

看起来有效的MathML是演示MathML,而SymPy输出内容MathML。不出所料,Word无法从内容转换为演示文稿,因为这需要软件方面的某种程度的数学知识。

SymPy probably ought to support 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).

SymPy可能应该支持输出演示文稿格式,但在实现之前,您可能会尝试找到一些可以在两者之间进行转换的其他软件(不幸的是,我不知道自己)。