Friday, December 2, 2011

MathJax in Blogger

Playing around getting MathJax to work in blogger. Below is the spherical law of cosines. It was getting cut off at the right so I had to break it up into two pieces. A bit ugly.

\[ d = \cos^{-1}(\sin(lat_1)\sin(lat_2) + \] \[ \cos(lat_1)\cos(lat_2)\cos(lon_2-lon_1))R \]

And some other mess that I got from here. \[ z \left( 1 \ +\ \sqrt{\omega_{i+1} + \zeta -\frac{x+1}{\Theta +1} y + 1} \ \right) \ \ \ =\ \ \ 1 \]

And this is from the MathJax main page.

\[ J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \, \Gamma(m + \alpha + 1)}{\left({\frac{x}{2}}\right)}^{2 m + \alpha} \]

So I think we can say it works. Right click on any equation and Show Source to see the LaTex.

So to use MathJax in a blog post you need to edit a post as HTML and insert the Javascript below.

<script src="http://cdn.mathjax.org/mathjax/1.1-latest/MathJax.js">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
    tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]}
  });
</script> 

Now add LaTex equations in your HTML using \[ latex-equation \].

2 comments:

Unknown said...

Thank you!

Shawn H. Golley said...

Woot! No more froggering around with clunky image generation!