本文介绍了MathML到LaTeX转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图弄清楚如何转换数学方程的MathML表示并将其转换为该数学方程的LaTeX表示。例如......

I'm trying to figure out how to convert a MathML representation of a math equation and convert it to the LaTeX representation of that math equation. So for example...

<math>
  <mrow>
    <mfrac>
      <mrow><mi>x</mi></mrow>
      <mrow><mi>y</mi></mrow>
    </mfrac>
  </mrow>
</math>

...是一个简单的堆积分数,它的LaTeX表示将是......

... is a simple stacked fraction and it's LaTeX representation would be...

\frac{x}{y}

我保证MathML没有表示性标记,因为我正在动态构造MathML字符串并控制MathML元素的插入方式/位置; MathML字符串只是数学方程式的纯粹结构。

I'm guaranteed that the MathML has no presentational markup because I am constructing the MathML string dynamically and I control how/where the MathML elements are inserted; the MathML string is just pure structure of the math equation.

所以我的问题是,是否有任何Java / JavaScript库可以采用MathML输入字符串,如上面的那个,并生成相应的LaTeX字符串?我宁愿不必自己编写这个解析器。如果不是Java / JavaScript,是否有任何库可以做到这一点?

So my question is, are there any Java/JavaScript libraries out there that can take a MathML input string, like the one above, and generate the corresponding LaTeX string? I would much rather not have to write this parser myself. If not Java/JavaScript, are any libraries at all that can do this?

如果没有,有关如何解决编写我自己的解析器这个问题的任何建议吗?从哪里开始,需要考虑的事项,资源等......?

If not, any suggestions on how to approach this problem of writing my own parser? Where to start, things to consider, resources, etc...?

感谢,我能够使用做我想做的事。然而,它并不完美,但我可以很容易地修改它并使其运行良好。但是,我仍然希望在JavaScript中看到这一点。那么有没有用JavaScript编写的这样的工具?如果没有,我会自己翻译。

Thanks to Optimal Cynic, I was able to use this Java library to do what I want. It is not perfect however, but I can easily modify it and make it work well. However, I would still like to see this done in JavaScript. So are there any tools like this written in JavaScript? If not, I'll resort to translating it myself.

注意:我正在使用在页面上呈现MathML,但MathJax目前不支持从MathML转到LaTeX的方法。它只能从LaTeX转到MathML。

Note: I am using MathJax to render the MathML on the page, but MathJax does not currently support a way to go from MathML to LaTeX. It can only go from LaTeX to MathML.

推荐答案

尝试 - 它是用Java编写的,源代码可用。

Try http://www.tilman.de/programme/mathparser/anleitung_en.html - it's written in Java and the source is available.

这篇关于MathML到LaTeX转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 06:54