目前 Excalidraw 不支持 ,这很糟糕。变通方法是先生成所需数学公式的 SVG 图像,然后粘贴到画布中。
你可以使用以下脚本生成 SVG:
import matplotlib.pyplot as plt
# 使用 svg 后端
plt.switch_backend('svg')
# 启用 latex 渲染
plt.rcParams['text.usetex'] = True
# 创建图形
fig, ax = plt.subplots(figsize=(4, 2))
ax.axis('off') # 无坐标轴
latex_str = r"$\nabla \mathcal J(\theta)$"
ax.text(0.5, 0.5, latex_str, fontsize=20, ha='center', va='center')
fig.savefig("latex.svg", format="svg", bbox_inches='tight', transparent=True)
搞定: