【问题标题】:How can I get MkDocs with Arithmatex and MathJax to recognize \\[ ... \\] as display math delimiters?如何使用 Arithmatex 和 MathJax 获取 MkDocs 以将 \\[ ... \\] 识别为显示数学分隔符?
【发布时间】:2021-11-02 22:12:14
【问题描述】:

我正在使用MkDocs 1.2.2MathJax 3.2,通过Arithmatex 来自pymdown-extensions。我试图让 Arithmatex 将 \\[\\](而不是默认的 \[ ... \])中的数学识别为显示数学。从基本配置开始,

markdown_extensions:
  - footnotes
  - pymdownx.arithmatex
  - pymdownx.highlight
  - pymdownx.superfences
extra_javascript:
  - javascripts/mathjax-config.js
  - https://polyfill.io/v3/polyfill.min.js?features=es6
  - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg-full.js

其中mathjax-config.jsLoading MathJax 部分中恰好包含the code under the tab "Default – MathJax 3",在Markdown 输入文件中写入以下内容,

\\[
\Sigma_n
\\]

生产

像这样更改 MkDocs 配置文件以添加 tex_block_wrap

markdown_extensions:
  - footnotes
  - pymdownx.arithmatex:
      tex_block_wrap: ['\\\\[', '\\\\]']
  - pymdownx.highlight
  - pymdownx.superfences

不改变输出。我尝试了\ 字符数的变化,但没有效果。通过将以下内容添加到我的 mathjax-config.js 文件中,我在 MathJax 端尝试了类似的配置更改:

window.MathJax = {
    tex: {
        displayMath: [ ["\\\\[", "\\\\]"] ],
    },
....

还有\ 字符数的变化,但没有成功。

如何在 MkDocs 中获取 Arithmatex+MathJax 以允许使用 \\[\\] 作为显示数学分隔符?

【问题讨论】:

    标签: mathjax mkdocs


    【解决方案1】:

    您不需要在 Markdown 文件中使用 \(\[。 Arithmatex 将$ 转换为内联数学,将$$ 转换为块数学。请参阅 Arithmatex 文档中的示例。按照那里的说明,我让它在通用和非通用模式下工作。

    通用模式的 .js 文件是

    window.MathJax = {
      tex: {
        inlineMath: [ ["\\(","\\)"] ],
        displayMath: [ ["\\[","\\]"] ],
        processEscapes: true,
        processEnvironments: true
      },
      options: {
        ignoreHtmlClass: ".*",
        processHtmlClass: "arithmatex"
      }
    }; 
    

    在 markdown 文件中,您可以使用 \($ 进行内联数学运算。 Arithmatex 将 $ 对转换为 \(\)。如果您使用\[,请不要转义反斜杠,即NOT \\(

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-09
      • 2018-02-22
      • 1970-01-01
      • 2020-08-15
      • 1970-01-01
      • 2011-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多