用 Java 生成 LaTeX 输出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4229190/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Producing LaTeX output in Java
提问by myahya
Is there a Java library for producing LaTeX output from Java?
是否有用于从 Java 生成 LaTeX 输出的 Java 库?
回答by Alexis Dufrenoy
To render Latex:
渲染乳胶:
JLatexMath: https://github.com/opencollab/jlatexmath
JLatexMath:https: //github.com/opencollab/jlatexmath
To produce Latex:
生产乳胶:
JTex: https://sourceforge.net/projects/jtex/
JTex:https://sourceforge.net/projects/jtex/
回答by koppor
I would start with JLaTeXMath:
我将从JLaTeXMath开始:
"JLaTeXMath is the best Java library to display LaTeX code."
“JLaTeXMath 是显示 LaTeX 代码的最佳 Java 库。”
import org.scilab.forge.jlatexmath.TeXConstants;
import org.scilab.forge.jlatexmath.TeXFormula;
public class Example5 {
public static void main(String[] args) {
String latex = "\begin{array}{|c|l|||r|c|}";
latex += "\hline";
latex += "\text{Matrix}&\multicolumn{2}{|c|}{\text{Multicolumns}}&\text{Font sizes commands}\cr";
latex += "\hline";
latex += "\begin{pmatrix}\alpha_{11}&\cdots&\alpha_{1n}\cr\hdotsfor{3}\cr\alpha_{n1}&\cdots&\alpha_{nn}\end{pmatrix}&\Large \text{Large Right}&\small \text{small Left}&\tiny \text{tiny Tiny}\cr";
latex += "\hline";
latex += "\multicolumn{4}{|c|}{\Huge \text{Huge Multicolumns}}\cr";
latex += "\hline";
latex += "\end{array}";
TeXFormula formula = new TeXFormula(latex);
formula.createPNG(TeXConstants.STYLE_DISPLAY, 20, "target/Example5.png", Color.white, Color.black);
}
}
Other solutions to evaluate
其他评估解决方案
- SnuggleTeX- seems to have a good parser, too. See the calling at https://sourceforge.net/p/snuggletex/code/HEAD/tree/trunk/snuggletex-core/src/main/java/uk/ac/ed/ph/snuggletex/samples/MinimalExample.java.
- JavaTex: https://sourceforge.net/projects/javatex/files/javatex/V0.2/. Seems to be a complete LaTeX engine.
- JavaTeX from CTAN- from 1998, but might still perform well.
- SnuggleTeX- 似乎也有一个很好的解析器。请参阅https://sourceforge.net/p/snuggletex/code/HEAD/tree/trunk/snuggletex-core/src/main/java/uk/ac/ed/ph/snuggletex/samples/MinimalExample.java 中的调用。
- JavaTex:https: //sourceforge.net/projects/javatex/files/javatex/V0.2/。似乎是一个完整的LaTeX引擎。
- 来自 CTAN 的 JavaTeX- 从 1998 年开始,但可能仍然表现良好。
(partially based on https://tex.stackexchange.com/q/41609/9075)