Search code examples
javascriptmathjaxkatex

How can I replace Matjax script with Katex script on blogger?


I have a website that is using many equations together with MathJax. Until now I found just a single MathJax script that is working on my blog. The script that I have now is Java

https://i.sstatic.net/5eAh6.jpg

I want a KaTeX script to replace this MathJax script to work with my blog without making any modification. I have the LaTeE part written between $...$. I will appreciate a simple script that has the .js file already hosted. A script that I can copy-paste to my blogger site and work. Can you advise please? Thank you.


Solution

  • According to docs, you should first install KaTeX like this:

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.js"></script>
    

    and then install the Auto-render extension, presumably like this:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/contrib/auto-render.min.js"></script>
    

    and add

    <script>renderMathInElement(document.body);</script>
    

    to the end of the body element. See details on the page I've referenced (looks like you will need to set delimeters like this:

    <script>renderMathInElement(document.body,{delimiters:
      [{left: "$", right: "$", display: false}]
    });</script>