![Sphinx 文档包中 LaTeX 输出的自定义颜色](https://linux22.com/image/376415/Sphinx%20%E6%96%87%E6%A1%A3%E5%8C%85%E4%B8%AD%20LaTeX%20%E8%BE%93%E5%87%BA%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E9%A2%9C%E8%89%B2.png)
我正在尝试在使用 Sphinx 文档包和 html 输出时自定义 LaTeX 内联公式的颜色。
细节:
我有一个名为的文件func.rst
,其中包含以下行:
Let :math:`x_{1}` be a binary variable.
在我使用 Sphinx 创建的文档中,它已成功呈现为 LaTeX。
(我已在中'sphinx.ext.imgmath'
列出)extensions
conf.py
我的目标是涂成x_{1}
红色。
我尝试过的事情:
在公式中添加颜色:
Let :math:`\color{red}x_{1}` be a binary variable.
同时还定义
latex_elements['preamble'] = '\usepackage{xcolor}'
在
conf.py
文件中。尝试使用以下方法全局定义所有数学输出:
latex_elements['preamble'] = r''' \usepackage{xcolor} \everymath{\color{red}} \everydisplay{\color{red}} '''
毋庸置疑,这两个想法(以及许多不太有前景的想法)都失败了。
非常感谢您的帮助:)
答案1
由于您似乎将数学运算呈现为 PNG 图像(或 SVG),因此当前要配置的配置值不是latex_elements
,但是imgmath_latex_preamble
。
请注意,这个问题与 TeX/LaTeX 没有直接关系,而主要是关于狮身人面像。 看sphinx 用户gmane.comp.python.sphinx.user
邮件列表(在(news://news.gmane.org:119/gmane.comp.python.sphinx.user
)下有一个 Gmane 界面
啊,我现在看到这个问题是交叉发布的https://stackoverflow.com/questions/50440108/custom-color-for-latex-output-in-sphinx-documentation-package