matplotlib.sphinxext.mathmpl
#
用于在 Sphinx 中显示数学文本的角色和指令#
mathmpl
Sphinx 扩展在 Matplotlib 中创建数学文本图像并将其显示在 HTML 输出中。因此,它真实且忠实地表示了您将给定 LaTeX 字符串传递给 Matplotlib 时将看到的内容(参见编写数学表达式)。
警告
在大多数情况下,您可能希望使用 Sphinx 的内置数学扩展之一,而不是此扩展。内置的 Sphinx 数学指令使用 MathJax 来渲染数学表达式,并且解决了 mathmpl
未解决的可访问性问题。
数学文本可以通过两种方式包含:
行内,使用角色
This text uses inline math: :mathmpl:`\alpha > \beta`.
产生:
此文本使用行内数学:
。
独立,使用指令
Here is some standalone math: .. mathmpl:: \alpha > \beta
产生:
以下是一些独立的数学文本
选项#
mathmpl
角色和指令都支持以下选项
- fontsetstr, 默认: 'cm'
显示数学时使用的字体集。参见
rcParams["mathtext.fontset"]
(默认:'dejavusans'
)。- fontsizefloat
字体大小,以磅为单位。默认为下面定义的扩展配置选项的值。
配置选项#
数学文本扩展具有以下配置选项
- mathmpl_fontsizefloat, 默认: 10.0
默认字体大小,以磅为单位。
- mathmpl_srcsetstr 列表, 默认: []
嵌入 HTML 时要生成的附加图像尺寸,以支持响应式分辨率图像。该列表应包含要生成的附加 x-描述符(
'1.5x'
,'2x'
等)(1x 是默认值且始终包含)。
- class matplotlib.sphinxext.mathmpl.MathDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]#
.. mathmpl::
指令,如模块的文档字符串中所述。- final_argument_whitespace = False#
最后一个参数是否可以包含空格?
- has_content = True#
指令是否可以包含内容?
- option_spec = {'fontset': <function fontset_choice>, 'fontsize': <function _make_type_validator.<locals>.validate_float_or_None>}#
选项名称到验证函数的映射。
- optional_arguments = 0#
必需参数后的可选参数数量。
- required_arguments = 0#
必需指令参数的数量。