用 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 05:24:59  来源:igfitidea点击:

Producing LaTeX output in Java

javalatex

提问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

其他评估解决方案

(partially based on https://tex.stackexchange.com/q/41609/9075)

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