Tuesday, December 4, 2012

Creating a post template in Blogger to allow for native $\LaTeX{}$

Since I want to use a lot of math typesetting in my blog posts, I created a post template to include the MathJax script that will enable $\LaTeX{}$ tyepsetting in my blogposts.
This way I won't need to add the script in the HTML code for every post (as I detailed in this blog post).

First, go to the Blogger design page and hit Template:

Then, we want to add this script in the HTML code for the blog template at the appropriate spot:

<script type="text/x-mathjax-config">   MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}}); </script> <script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"> </script>

Go to Edit HTML:

and then click on Proceed:
You should get a wall of HTML text for the template:
You want to enter the script in the <head> section, but put it last. So you want to enter it right before the end head symbol, </head>.
The way I find this is to hit Control-F (or Command-F on a Mac). This will enable the Find feature on your Google Chrome browser with a Find text box in the upper right corner of your browser window.
Type in </head> and it will highlight it in the HTML text:

On the line right before </head> paste the script for MathJax:

Hit Save Template, then Close and you will be back at the Blogger Design Page.

Now, you no longer need to enter the script on the HTML code of every post! The MathJax script will automatically run on every post, so you can just enter math preceeded by $\$$ or $\$\$$ (depending on whether you want inline math or not) and end it with $\$$ or $\$\$$.