пятница, 23 ноября 2012 г.

Math render in Blogger

Sorry for my bad english.
I use MathJax, because it gives me perfect font quality (even exporting page as PDF file gives you perfect result). Downside is the low speed of rendering really big posts.

How to use

Add this lines to your post (in HTML mode):
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({ TeX: { extensions: ["color.js"] }});
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript">
</script>

Then surround math code by $ if you want inline math:
---> Do wou now formula $E=mc^{2}$?
Or by $$, if you want stand-alone math: $$E=mc^{2}$$
$E=mc^{2}$ - inline
$$E=mc^{2}$$ - stand-alone

That's all. Now you have math in your blog.

Configuration

Without this code math cannot be rendered at all.
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript">
</script>


This code gives you inline math:
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>



This code includes color.js extension.

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({ TeX: { extensions: ["color.js"] }});
</script>
I need colors.js extension, because I use Lyx as the main math editor. By default, MathJax color formula in TeX mode, not LaTeX. Feel different, this code

{\color{blue}x_{1}+\cfrac{a_{12}}{a_{11}}x_{2}+\cfrac{a_{13}}{a_{11}}x_{3}+\cfrac{a_{14}}{a_{11}}x_{4}+...+\cfrac{a_{1n}}{a_{11}}x_{n}=\cfrac{b_{1}}{a_{11}}}

in LaTeX mode (with color.js) looks like:
$${\color{blue}x_{1}+\cfrac{a_{12}}{a_{11}}x_{2}+\cfrac{a_{13}}{a_{11}}x_{3}+\cfrac{a_{14}}{a_{11}}x_{4}+...+\cfrac{a_{1n}}{a_{11}}x_{n}=\cfrac{b_{1}}{a_{11}}}$$

but by default:
$${\color{blue}x}_{1}+\cfrac{a_{12}}{a_{11}}x_{2}+\cfrac{a_{13}}{a_{11}}x_{3}+\cfrac{a_{14}}{a_{11}}x_{4}+...+\cfrac{a_{1n}}{a_{11}}x_{n}=\cfrac{b_{1}}{a_{11}}$$