数学在 Github Pages 上未正确呈现,但在我的本地计算机上正确呈现

时间:2021-04-04 08:24:38

标签: rubygems jekyll bundle github-pages mathjax

这是我的个人网站:https://xlnwel.github.io/blog/。它根本不渲染 Math。但是,当我从本地计算机启动它时,一切都很好。问题的根源可能是什么?我该如何解决?

这是源代码:https://github.com/xlnwel/blog 和在本地运行它的指南。

git clone https://github.com/xlnwel/blog
cd blog/docs
bundle install 
jekyll server

在我的本地计算机上成功渲染的快照 enter image description here

以及网站上失败渲染的快照:https://xlnwel.github.io/blog/reinforcement%20learning/Retrace/

enter image description here

1 个答案:

答案 0 :(得分:0)

我遗漏了两点。首先,正如 this answer 指出的,我应该将以下代码添加到 _includes/*.html


<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
        inlineMath: [['\\(','\\)'], ['$', '$']]
      }
    });
  </script>
  <script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>

第二,我应该用 $...$ 替换所有由 \\(...\\) 包围的内联数学,以及用 $$...$$ 替换所有由 \\[...\\] 包围的数学块。

但是,我仍然无法弄清楚为什么我之前在本地计算机上一切正常。

相关问题