啊哈,我发现了一个可以与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'#####################################################
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)