Cao Yi

How to Display Math Formulas in GitHub Pages


If you have encountered a problem where the math formulas do not display when your site is published, despite being visible while editing in markdown, you can follow these steps to fix it.

First, input the following math formulas in plaintext:

$$ P(A\cup B)=P(A)+P(B)-P(A\cap B) $$

$$ P(\Omega -E)=1-P(E) $$

$$ P(A\cap B)=P(A)\cdot P(B\vert A) $$

You expect to see the formulas as shown below:

However, you may see some unintelligible text:

\[P(A\cup B)=P(A)+P(B)-P(A\cap B)\] \[P(\Omega -E)=1-P(E)\] \[P(A\cap B)=P(A)\cdot P(B\vert A)\]


To resolve this issue, add the following script to the head or append it the end of the markdown document, following the instructions on

MathJax = {
  tex: {
    inlineMath: [['$', '$'], ['\\(', '\\)']]
<script id="MathJax-script" async

This version is edited by ChatGPT. It’s better than my original version.