【问题标题】:MathJax not processing latex environmentsMathJax 不处理乳胶环境
【发布时间】:2022-01-17 05:54:37
【问题描述】:

我正在 blogspot 上写一篇博文。这是我在主题的 html 文件中的 MathJax 配置。

<script defer='defer' id='MathJax-script' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js' type='text/javascript'/>
<script>
window.MathJax = {
  tex: {
    loader: {load: [&#39;[tex]/ams&#39;]},
    inlineMath: [ [&#39;$&#39;,&#39;$&#39;],[&#39;\\(&#39;,&#39;\\)&#39;] ],
    displayMath: [ [&#39;$$&#39;,&#39;$$&#39;], [&#39;\\[&#39;,&#39;\\]&#39;] ],
    processEscapes: true,      
    processEnvironments: true, 
    processRefs: true,
    packages: {
        &#39;[+]&#39;: [&#39;ams&#39;]
    },
  },
};
</script>

这是我使用 amsmath align 环境的尝试。

...
By linearity of expectation 

\begin{align}
    \mathbb{E}[I_r] & \leq  |I_{r-1}|+\sum_{u\in \overline{I_{r-1}}\setminus \{v_{r-1}\}}{\mathbb{E}[X_{u,r}]}+1\\
        & \leq |I_{r-1}| + c_2k(|\overline{I_{r-1}}|-1)|I_{r-1}|/n^2+1\\
        & \leq |I_{r-1}|\cdot(1+c_2k/n) + 1\\
\end{align}
...

但是,在预览我的页面时,它只是按字面意思呈现文本,而不进行 MathJax 处理。我该如何解决这个问题?

【问题讨论】:

    标签: javascript mathjax


    【解决方案1】:

    这非常有效。希望它对你有用。

    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    
        <script>
        MathJax = {
            tex: {
                inlineMath: [
                    ['$', '$'],
                    ['\\(', '\\)']
                ]
            },
            svg: {
                fontCache: 'global'
            }
        };
        </script>
        <script type="text/javascript" id="MathJax-script" async
            src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
        </script>
    </head>
    
    <body>
    
        <div class="math">
            \begin{align}
            \mathbb{E}[I_r] & \leq |I_{r-1}|+\sum_{u\in \overline{I_{r-1}}\setminus \{v_{r-1}\}}{\mathbb{E}[X_{u,r}]}+1\\
            & \leq |I_{r-1}| + c_2k(|\overline{I_{r-1}}|-1)|I_{r-1}|/n^2+1\\
            & \leq |I_{r-1}|\cdot(1+c_2k/n) + 1\\
            \end{align}
        </div>
    
    </body>
    
    <script>
    const
        math = document.querySelector('.math')
    
    MathJax.typeset();
    </script>
    
    </html>

    【讨论】:

      猜你喜欢
      • 2014-11-28
      • 2014-10-08
      • 2017-08-11
      • 2014-12-03
      • 2021-04-12
      • 2021-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多