【问题标题】:Math is not rendered correctly on Github Pages but correctly on my local computer数学在 Github 页面上未正确呈现,但在我的本地计算机上正确呈现
【发布时间】:2021-04-04 08:24:38
【问题描述】:

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

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

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

在我的本地计算机上成功渲染的快照

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

【问题讨论】:

    标签: rubygems jekyll bundle github-pages mathjax


    【解决方案1】:

    我错过了两点。首先,正如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>
    
    

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

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

    【讨论】:

      猜你喜欢
      • 2020-08-22
      • 2019-08-29
      • 2020-10-09
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-16
      • 1970-01-01
      相关资源
      最近更新 更多