将latex数学公式转图片
/**
* @description:
* @author: lyp
* @date: 2020/8/21 18:01
*/
public class FormulaToPng {
public static Image image(String latex) throws Exception {
// 样式 符号以最大的尺寸呈现
int style = TeXConstants.STYLE_DISPLAY;
// 生成公式图片的字体大小
float size = 20;
// 字体颜色,黑色
Color fg = Color.BLACK;
// 图片背景色,默认为透明北京
Color bg = null;
return TeXFormula.createBufferedImage(latex, style, size, fg, bg);
}
public static void main(String[] args) throws Exception {
String latex = "\(- \left| - 2 \right|\)"
BufferedImage image = (BufferedImage) FormulaToPng.image(latex);
}
}
推荐一个转换神器 pandoc
可以把latex格式的tex文件一键转换成其他格式的文件 非常方便