問題描述
我試圖弄清楚如何轉換數學方程的 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...?
感謝 Optimal Cynic,我能夠使用 這個 Java 庫 來做我想做的事.然而,它并不完美,但我可以輕松地對其進行修改并使其正常工作.但是,我仍然希望在 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.
注意:我正在使用 MathJax 在頁面上呈現 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.
推薦答案
試試http://www.tilman.de/programme/mathparser/anleitung_en.html - 它是用 Java 編寫的,源代碼可用.
Try http://www.tilman.de/programme/mathparser/anleitung_en.html - it's written in Java and the source is available.
這篇關于MathML 到 LaTeX 的轉換的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!