使用 mathml 将 sympy 方程式输出到单词
Output sympy equation to word using mathml
MathML 似乎可以用我的单词进行简单的复制和粘贴,例如
<math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mn>1</mn><mn>2</mn></mfrac></math>
但是当我尝试使用 sympy
的 mathml 打印机时:
from sympy import S
from sympy.printing.mathml import mathml
my_eqn = S(1) / 2
print(mathml(my_eqn))
输出为:
<apply><divide/><cn>1</cn><cn>2</cn></apply>
而且我无法将其复制并粘贴到 Word 中以使其成为 Word 方程式。
有人可以帮忙吗?
看起来有效的 MathML 是 presentation MathML, whereas SymPy outputs content MathML。不出所料,Word 无法将内容转换为表示形式,因为这需要软件具备一定程度的数学知识。
SymPy probably ought to support 输出演示文稿格式,但在实施之前,您可能会尝试找到一些可以在两者之间转换的其他软件(不幸的是,我自己不知道)。
SymPysupports presentation MathML now。为此,您使用 arg printer="presentation"
mathml(expr, printer="presentation")
您应该将输出放在 <math>
标签内:
<math xmlns = "http://www.w3.org/1998/Math/MathML">
</math>
MathML 似乎可以用我的单词进行简单的复制和粘贴,例如
<math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mn>1</mn><mn>2</mn></mfrac></math>
但是当我尝试使用 sympy
的 mathml 打印机时:
from sympy import S
from sympy.printing.mathml import mathml
my_eqn = S(1) / 2
print(mathml(my_eqn))
输出为:
<apply><divide/><cn>1</cn><cn>2</cn></apply>
而且我无法将其复制并粘贴到 Word 中以使其成为 Word 方程式。
有人可以帮忙吗?
看起来有效的 MathML 是 presentation MathML, whereas SymPy outputs content MathML。不出所料,Word 无法将内容转换为表示形式,因为这需要软件具备一定程度的数学知识。
SymPy probably ought to support 输出演示文稿格式,但在实施之前,您可能会尝试找到一些可以在两者之间转换的其他软件(不幸的是,我自己不知道)。
SymPysupports presentation MathML now。为此,您使用 arg printer="presentation"
mathml(expr, printer="presentation")
您应该将输出放在 <math>
标签内:
<math xmlns = "http://www.w3.org/1998/Math/MathML">
</math>