【问题标题】:Left-align all math blocks in Sphinx HTML output左对齐 Sphinx HTML 输出中的所有数学块
【发布时间】:2022-01-17 21:03:36
【问题描述】:

我通过the math directive 获得了包含数学块的 Sphinx 文档。默认情况下,它们在 HTML 输出中居中。我希望它们都显示在左侧对齐,但相对于周围的文本有一些缩进。

例如,如果这是在index.rst

For :math:`|r| < 1`:

.. math::

   \sum\limits_{k=0}^{\infty} r^k = \frac{1}{1-r}

Text in following paragraph put here to demonstrate that the math block
is in fact centered on the page.

conf.py 完全为空,然后在同一文件夹中运行sphinx-build . output 会生成在浏览器中查看的以下 HTML 页面:

我希望该公式和所有其他数学块左对齐,例如 2 "em" 缩进。 This question 询问如何左对齐单个数学块。我希望有一种方法可以在整个文档中实现相同的效果,而无需更改 reStructuredText 源中的每个数学指令。

【问题讨论】:

    标签: python-sphinx mathjax restructuredtext


    【解决方案1】:

    此答案适用于 MathJax,HTML 输出中的默认数学渲染器。

    conf.py 中的以下设置左对齐所有math 指令内容:

    mathjax3_config = {'chtml': {'displayAlign': 'left'}}
    

    可以使用displayIndent自定义缩进:

    mathjax3_config = {'chtml': {'displayAlign': 'left',
                                 'displayIndent': '2em'}}
    

    参考资料:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-19
      • 2014-04-11
      • 1970-01-01
      • 2014-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多