在 Java 中生成 LaTeX 输出 [已关闭]

2022-09-03 07:02:02

有没有一个Java库可以从Java生成LaTeX输出?


答案 1

要渲染乳胶:

JLatexMath: https://github.com/opencollab/jlatexmath

要生产乳胶:

JTex: https://sourceforge.net/projects/jtex/


答案 2

我会从JLaTeXMath开始:

“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);
    }
}

其他要评估的解决方案

(部分基于 https://tex.stackexchange.com/q/41609/9075)


推荐