Friday, June 24, 2011

Including mathematics on blog using LaTeX notation: MathJax

If you want to display mathematical equations on your blog you can do that using MathJax Content Delivery Network (CDN). Here is the link: MathJax.

The default math delimiters are \(\$\$...\$\$\), \\([...\)\] for displayed mathematics, and \\((...\)\\()\) for inline mathematics. What it means is you need to keep either \(\$\$\) at the beginning and end of LaTeX notation or \\([\) at the beginning and \] at the end of the same LaTeX notation to display the equation on the page. If I do this with this text, \sqrt{3x-1}+(1+x)^2:

\(\$\$\sqrt{3x-1}+(1+x)^2\$\$\)                         on the page shows up as
$$\sqrt{3x-1}+(1+x)^2$$

\\([\)\sqrt{3x-1}+(1+x)^2\]                         also shows up as
\[\sqrt{3x-1}+(1+x)^2\]

As an example of inline equation, \\((\)\sqrt{3x-1}+(1+x)^2\) shows up as an inline equation, \(\sqrt{3x-1}+(1+x)^2\).

To make it possible, you need to link MathJax by including the below lines in your design html code on your blog. After logging onto your blog, click on Design, Edit HTML and then add the lines either in the head section or before head tag. If you want to keep in side the head tag, use browser search for </head> and insert these lines right before that. Or you can simply place them right before <head>.

<script type="text/javascript"
  src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

Finally, I'd like to say one more great feature of MathJax. If you right click on the equation on the page, you can see the LaTeX source code for the eqation, which is quite useful in case you are looking at some complicated equation on some other page which was in fact put on the page using MathJax. This way you can see the TeX code. Anyway, hope this helps someone.

No comments:

PBS Script Generator: Interdependent dropdown/select menus in Javascript

PBS SCRIPT GENERATOR
SH/BASH TCSH/CSH
Begin End Abort

About Me

LA, CA, United States
Here I write about the battles that have been going on in my mind. It's pretty much a scribble.

Sreedhar Manchu

Sreedhar Manchu
Higher Education: Not a simple life anymore