Search code examples
mathjaxgithub-pages

MathJax-how can I used it in the Github pages?


I cannot use mathjax in MarkDown page as described here and here. I would like to know how to do that?

I can use mathjax in html files now.

It seems that mathjax cannot render the $$ displayformula?


Solution

  • You actually do have MathJax working with the first page that you cite (the other link seems to be broken). If you notice the first equation, it has been typeset by MathJax (note that its contextual menu is MathJax's). The problem is that Markdown is turning your underscores into <em> tags, and that means MathJax won't process those equations (MathJax doesn't process math that contains HTML tags).

    One solution is to put spaces around your underscores, so that Markdown will ignore them.

    Another would be to use backticks (`) around the math to turn it into "verbatim" mode, so Markdown won't modify its contents. That may cause the math to be enclosed in <code> tags, which MathJax will ignore. So you would need to modify your configuration to include

    tex2jax: {
      skipTags: ["script","noscript","style","textarea","pre"]
    }
    

    (the default has "code" in that list) so that MathJax will process the contents of <code> tags.

    Addition:

    Your theme styles code blocks with white text on black backgrounds, so you may want to add some additional CSS to set that back. You may be able to do that somewhere in your theme controls, but you could also add

    styles: {
      code: {
        "font-family": "inherit",
        "color": "inherit!important",
        "background": "inherit!important"
      }
    }
    

    to your MathJax configuration, and it will set the styles for you. Note that this will also modify how any backticked material will show up. If you want to have it only affect MathJax output, that would take more work.