Search code examples
githubmarkdown

Github the pair of underline _ in math equtions $$ in markdown is explained to italic text not math equtions


In the markdown file, I try to write my in-line math equations in the $$.

But there must be something wrong when I use the _ for subscript in two in-line equations.

The engine of the GitHub markdown file will explain them as an italic font text, not two equations.

But my markdown preview in VS Code shows it well.


Sample:

the origin text:

math sample $a_i$ and $b_i$ and $\\hat{p}\_{\\sigma(i)}(c_i)$ and $\\mathcal{L}\_{box}(b_i,\\hat{b}\_{\\sigma(i)})$.

the GitHub result:

github result

you see the underline _ after hat{} and mathcal{} are explained to italic text.


my VS Code preview result:

my VS Code preview result


Solution

  • I find an answer myself, it is a little trick.

    Just add a little space after underline _ to cheat the Github Markdown engine, and it will not think the pair of underline _ as mark of italic text and show the true math equations.

    Just try the under text, there is space after \hat{p}_ and $\mathcal{L}_.

    math sample $a_i$ and $b_i$ and $\hat{p}_ {\sigma(i)}(c_i)$ and $\mathcal{L}_ {box}(b_i,\hat{b}_{\sigma(i)})$.
    

    Result in Github:

    Result in Github

    I hope it may help others to make there markdown text more beautiful.