Thursday 11 June 2015

Creating Math in Blogger

I've decided to add MathJax1 to my blog.

I have tried in the past to use MathML3, but it's support among internet browsers is still too fragmented to be of any use. It looks like this situation is likely to continue. Also, I am a big fan of the Tex notation, instead of the verbose XML I would need to get anything done in MathML.

The difference is obvious when you right-click on the Math Expressions below.

Example

When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c =
0\) and they are \[x = {-b \pm \sqrt{b^2 - 4ac} \over 2a}\]

JavaScript Snippet

I have added the below snippet to my HTML in my Template, as according to source [2].
<!-- Script for installing MathJax -->
<script type='text/x-mathjax-config'>
   //  <![CDATA[
    MathJax.Hub.Config({
      extensions: ["tex2jax.js"],
      showProcessingMessages : true,
      tex2jax: {
          inlineMath: [ ["\\(","\\)"] ],
          displayMath: [ ["\\[","\\]"] ],
          preview : "TeX",
          processEscapes: true
      },
      TeX: {
        Macros: {
            Moon: "{&#9790;}"
   }
   }
    });
   //   ]]>
</script>
<script src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' type='text/javascript'/>
<!-- End Script for installing MathJax -->

References

[1] MathJax
https://www.mathjax.org/
[2] The Astronomy Learner - MathJax on Blogger
http://astro-learned.blogspot.nl/2015/01/mathjax-on-blogger.html
[3] Wikipedia - MathML
http://en.wikipedia.org/wiki/MathML
W3 - MathJax Overview
http://www.w3.org/Math/MJ/Overview.html
Hanselman - Exploring Crossbrowser Math Equations Using MathML or LaTeX With MathJax
http://www.hanselman.com/blog/ExploringCrossbrowserMathEquationsUsingMathMLOrLaTeXWithMathJax.aspx

No comments:

Post a Comment