在Sphinx中创建LaTeX数学宏

在Sphinx中创建LaTeX数学宏,第1张

在Sphinx中创建LaTeX数学

啊哈,我发现了一个可以与Sphinx
pngmath扩展一起使用的解决方案。这是Sage(开源数学软件)使用的技巧。灵感来自http://www.sagemath.org/doc/reference/sage/misc/latex_macros.html。

要将自己的Latex宏添加到Sphinx文档中:

1)创建一个文件,说“ latex_macros.sty”,其中包含您的宏(每行一个),并将其放在与Sphinx conf.py文件相同的目录中;

2)将以下代码添加到您的Sphinx conf.py文件中:

# Additional stuff for the LaTeX preamble.latex_elements['preamble'] = 'usepackage{amsmath}nusepackage{amssymb}n'###################################################### add LaTeX macrosf = file('latex_macros.sty')try:    pngmath_latex_preamble  # check whether this is already definedexcept NameError:    pngmath_latex_preamble = ""for macro in f:    # used when building latex and pdf versions    latex_elements['preamble'] += macro + 'n'    # used when building html version    pngmath_latex_preamble += macro + 'n'#####################################################


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5674480.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存