Monday, August 15, 2016

Using Latex Based Typesetting in Blogger

If you are interested in including math contents in your blogs created using blogspot, and you are familiarized with 'Latex' for typesetting the math contents, you can now configure 'Mathjax' in your blogs to add the Latex math functionalities. Since Mathjax is not a feature of blogspot, we have to access Mathjax through a javascript which takes the help of a remote server on which Mathjax is hosted. In order to use Latex math typesetting in your blogs,
  1. Log into blogspot.
  2. Click on the orange 'e' button appearing on the top left corner so that all your blogs are displayed (First start a blog if you haven't any)
  3. Click on the blog's name in which you have to add the Latex math typesetting functionality.
  4. Click on the 'Layout' button from the list appearing on the left pane.
  5. Scroll down the page and click on the '+Add a gadget' option appearing on the right side of the page.
  6. A list of available gadgets will now pop up.
  7. From the list of available gadgets, scroll down and click the HTML/Javascript option.
  8. In the 'Title' field, add a title of your choice, and copy paste the following script in the field named 'Content'
--------------------------------------- script ------------------------------------------------------------
 <script type="text/javascript" async
  src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
 
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: {
    inlineMath: [['$','$'], ['\\(','\\)']],
    processEscapes: true
  }
});
</script>
 
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  TeX: { equationNumbers: { autoNumber: "AMS" } }
});
-------------------------------------------------------------------------------------------------------------

Now first click the 'save' button in the HTML-javascript gadget and then click the 'Save arrangement' button of the Layout to finish the process of configuring Mathjax. You can now use the Latex style typesetting with '\$ \$' for inline math, '[ ]' for displayed math without numbering, and, 'begin{equation}  end{equation}' for numbered equations.
Note 1: Backslashes before opening and closing square brackets for displayed math and the numbered math environments are not shown above, but should be added just as how it is used in normal Latex. Those backslashes are not shown above because, if we add them, it will be interpreted as an equation..!!
Note 2: Regardless of whether the inline math, displayed math or numbered equations are used, never use new lines between the environment opening and closing if you are using the wordpad like 'Compose' window for editing your blogs. In other words, open and close your environment in the same line with a single whitespace in between, and add the math content in the place of the whitespace - Never put the 'begin{equation}' and 'end{equation}' on different lines and the math content in the middle line as practiced in Latex. 
Examples are given below:

This is an inline math: $\omega_k$

Displayed math:
\[\mathbf{A}\mathbf{x} = \mathbf{b}\]

Numbered equations:
\begin{equation} X\left(\omega\right) = \sum_{n=1}^N x\left[n\right]\textrm{e}^{-j2\pi \omega n}  \end{equation}

No comments:

Post a Comment