Pages

Saturday, June 9, 2012

Installing MathJax in Blogger for LaTeX Equations

Installing MathJax in Blogger for LaTeX Equations Physicists write equations a lot and the best typesetting program for equations is not MS Word but TeX or LaTeX. The problem is that you have a LaTeX document and you want this reflected in your blog posts and pages. Unfortunately, web pages are written in HTML and not in LaTeX. So what will you do?

One solution is to blog using Wordpress and enclose your Latex equations with $\$latex\ \ldots\ \$ $, where the $\dots$ are where you write your equation (see Wordpress LaTeX support). The only problem is when you wish to align your equations using the align environment. This is not supported by Wordpress.

I tried to get around this problem by writing my manuscript in LaTeX. Then I screen-grab the pdf images, upload the images in my Google+ page, and post these images in my Wordpress page. You may like to check out the finished product in Ateneo Physics Teacher: Projectile motion of a waterfall. Since the Google spider can't see pictures, I use Wordpress tags using keywords from the article, hoping that the spider will somehow see the page and rank it in the first page of certain search queries. Had the article been text and images, the web page ranking would have been higher.

 Another solution is to blog using Blogger. Unlike the free version of Wordpress hosted in wordpress.com, Blogger allows the use of scripts. In this blog, I use MathJax scripts.

To see how easy it is to use MathJax, go to MathJax download page.  Click on Using the MathJax CDN.  CDN means Content Distribution Network. Copy the sample HTML file with script. The file is on how to typeset the quadratic equation in-line and the quadratic formula in display.

Equations may also be written using LaTeX's equation and align environments. Equation labels and references are supported. You may use the equation numbering feature in MathJax. But you need to insert a script just before the script tag that loads Mathjax itself. Unfortunately, subequations are not supported.

As an illustration of MathJax's capability, the unified Maxwell's equation in geometric algebra is written as \begin{equation} \label{eq:Maxwell} \left(\frac{1}{c}\frac{\partial}{\partial t}+\boldsymbol\nabla\right)(\mathbf E +i\zeta\mathbf H) = \zeta(\rho c - \mathbf j), \end{equation} where $\zeta=\mu/\epsilon$ and $c=\sqrt{\mu\epsilon}$. Using the Pauli identity $\mathbf a\mathbf b = \mathbf a\cdot\mathbf b + i(\mathbf a\times\mathbf b)$, the Maxwell's equation in Eq.~(\ref{eq:Maxwell}) expands to \begin{align} \boldsymbol\nabla\cdot\mathbf E &=\frac{\rho}{\epsilon},\\ \frac{1}{c}\frac{\partial\mathbf E}{\partial t} -\mu\boldsymbol\nabla\mathbf H&=-\zeta\mathbf j,\\ \boldsymbol\nabla\times\mathbf E +\mu\frac{\partial\mathbf H}{\partial t} &= 0,\\ \zeta\boldsymbol\nabla\cdot\mathbf H &= 0, \end{align} after separating the scalar, vector, imaginary vector, and imaginary scalar parts. Note that we have factored out the imaginary number $i$ in the last two equations. These four equations correspond to the Gauss's law, Ampere's Law, Faraday's law, and Magnetic Flux Continuity Law, respectively.

2 comments:

  1. Can you publish a post showing detailed steps of using Mathjax to write Equations on Blogger with necessary screenshots. The link you provided, showed the steps of using mathjax in any random webpages and not blogger in general, and the steps are complex [at least I didn't understand]. If you did, it'd be a great help. Thank You.

    ReplyDelete
  2. Thanks. Very helpful...
    I used to use jqmath but there are some troubles...

    ReplyDelete