Maybe
Maybe

Reputation: 2279

Math is not rendered correctly on Github Pages but correctly on my local computer

Here's my personal website: https://xlnwel.github.io/blog/. It does not render Math at all. However, when I launch it from my local computer, everything is fine. What might be the root of the problem? And how can I fix it?

Here's the source code: https://github.com/xlnwel/blog and a guide to run it locally.

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

A snapshot of success rendering on my local computer enter image description here

And a snapshot of failure rendering on the website: https://xlnwel.github.io/blog/reinforcement%20learning/Retrace/

enter image description here

Upvotes: 0

Views: 763

Answers (1)

Maybe
Maybe

Reputation: 2279

There are two points I missed. First, as this answer pointed out, I should add the following code to _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>

Second, I should replace all inline math surrounded by $...$ with \\(...\\), as well as all math blocks surrounded by $$...$$ with \\[...\\].

However, I still cannot figure out why everything works fine on my local computer before.

Upvotes: 1

Related Questions