Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Producing LaTeX output in Java [closed]

Tags:

java

latex

Is there a Java library for producing LaTeX output from Java?

like image 469
myahya Avatar asked Nov 19 '10 20:11

myahya


2 Answers

To render Latex:

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

To produce Latex:

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

like image 155
Alexis Dufrenoy Avatar answered Sep 24 '22 04:09

Alexis Dufrenoy


I would start with JLaTeXMath:

"JLaTeXMath is the best Java library to display LaTeX code."


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.

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

like image 43
koppor Avatar answered Sep 23 '22 04:09

koppor