这里分享两个Python LaTex工具latexify和handcalcs。

latexify生成LaTeX 数学公式
import math
import latexify
@latexify.with_latex #调用latexify的装饰器
def solve(a, b, c):
return (-b + math.sqrt(b**2 - 4*a*c)) / (2*a)
solve

更多例子.......


handcalcs生成LaTeX 数学公式
import handcalcs.render
from scipy.integrate import quad #借助scipy.quad实现积分
%%render
a = 2
b = 6
n=100
z = quad(f,a,b)

from math import sqrt,cos,sin,tan,asin
import handcalcs.render
%%render
#symbolic
f = a-c**2 / b + sqrt(cos(sin(b- 2
/ c))) + tan(a/b) - asin(a/c) #Comment part

ref
https://github.com/google/latexify_py
https://github.com/connorferster/handcalcs>