Tuesday, December 13, 2016

在Blogger中使用Latex公式

It took me a while to figure out how to insert equations here.
This is some quoted text.
This is a exciting moment

 $E = mc^{2}$

Copy-past the following code
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
MathJax.Hub.Config({
 extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
 jax: ["input/TeX", "output/HTML-CSS"],
 tex2jax: {
     inlineMath: [ ['$','$'], ["\\(","\\)"] ],
     displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
 },
 "HTML-CSS": { availableFonts: ["TeX"] }
});
</script> 
in the HTML of the Blogger template (Design→Edit HTML→Edit Template) between <head> and </head>.

The advantage of this code here is that the Mathjax rendered is closer to the one practiced on the SE network (in particular with the $). Also one may use macros (\newcommand).

No comments:

Post a Comment