Pages

Friday, June 12, 2015

Inserting mathematical equations using Latex into Blogger posts


To enter in equations in Blogger posts, try copying the following code into HTML mode at the beginning of your post:

<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>

Then switch to compose mode and you can type equations using latex surrounded by single dollar signs and the equations will display properly when published.  For instance, I typed the following:

  Einstein's famous equation was $E=mc^2$.
  The definition of a derivative is $\lim_{h\to0} \frac{f(x+h)-f(x)}{h}$.
  The definition of a derivative is $$\lim_{h\to0} \frac{f(x+h)-f(x)}{h}$$

And this is what displayed:
  Einstein's famous equation was $E=mc^2$.
  The definition of a derivative is $\lim_{h\to0} \frac{f(x+h)-f(x)}{h}$.
  The definition of a derivative is $$\lim_{h\to0} \frac{f(x+h)-f(x)}{h}$$

It appears single dollar signs are for inline equations and double dollar signs are separate centered equations.

I am not an expert in latex, blogger, or html.  I published this article more for my own future reference then as an instruction manual for everyone else, so you can complain in the comments that it didn't work for you if you'd like, but I'm not going to be able to help you fix it.  I learned this information primarily through Steve Holden's Blog.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...