将latex数学公式转图片

这篇博客介绍了如何将LaTeX数学公式转化为图片,使用Java的`FormulaToPng`类实现了该功能,并给出了代码示例。此外,推荐了Pandoc这个强大的工具,可以一键将LaTeX文件转换为其他格式,方便快捷。
摘要由CSDN通过智能技术生成

将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文件一键转换成其他格式的文件 非常方便

官方链接:https://pandoc.org/demos.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值