JLaTeXMath - A Java API to render LaTeX


Table of Content

Simple usage to produce images

Here is a simple fragment of Java code that renders the given formula and places the result into BufferedImage b:

 import org.scilab.forge.jlatexmath.TeXConstants;
 import org.scilab.forge.jlatexmath.TeXFormula;
 import org.scilab.forge.jlatexmath.TeXIcon;

 import java.awt.image.BufferedImage;
 import javax.swing.JLabel;


 String math = "\\frac {V_m} {K_M+S}";

 TeXFormula fomule = new TeXFormula(math);
 TeXIcon ti = fomule.createTeXIcon(
 TeXConstants.STYLE_DISPLAY, 40);
 BufferedImage b = new BufferedImage(ti.getIconWidth(), ti
    .getIconHeight(), BufferedImage.TYPE_4BYTE_ABGR);
 ti.paintIcon(new JLabel(), b.getGraphics(), 0, 0);

This fragment runs on a server side with good performance and stability. If you want, please visit our Free online encyclpedia to see it in action. As browsers now provide zoom capabilities, it is good to generate a picture with a little bit higher resolution than it is ultimately shown (HTML IMG tag allows to specify dimensions explicitly). This may create some extra load but allows formulas to show much better after some zoom is applied in browser settings.

We license this fragment of code public domain.

Created: 4 years 8 days ago
by Meskauskas Audrius

Updated: 2 years 7 months ago
by Calixte Denizet

Old Revisions