# test math formula in github pages

### update 20170513:

If use pelican, the easist way is to include the plug-in called Math Render Plugin For Pelican

It use MathJax to give pelican the ability to render mathematics. It supports both markdown and reStructuredText.

It also supports color and mhchem.

It only enables math formula. But it did not support complicated things like equation number and so on.

### method 1. copy the following in the md file

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>


### method 2. copy that into the header.html file

For me, the header.html is in blog/pelican-themes/pelican-octopress-theme/templates/_includes/header.html

Then input the formula inside $$...$$ will create formula centered in new line

$$\frac{\partial f(y)}{\partial x} = \frac{\partial f}{\partial y} \times \frac{\partial y}{\partial x}$$


will generate

$$\frac{\partial f(y)}{\partial x} = \frac{\partial f}{\partial y} \times \frac{\partial y}{\partial x}$$

And \$\frac{1}{n} \$ will create formula inline: $\frac{1}{n}$.

Let's test some inline math $x$, $y$, $x_1$, $y_1$.

Now a inline math with special character: $|\psi\rangle$, $x'$, $x^\*$.

Test a display math:

$$|\psi_1\rangle = a|0\rangle + b|1\rangle$$

Test a display math with equation number:

\begin{equation} |\psi_1\rangle = a|0\rangle + b|1\rangle \end{equation}

Test a display math with equation number:

\begin{align} |\psi_1\rangle &= a|0\rangle + b|1\rangle \\\\ |\psi_2\rangle &= c|0\rangle + d|1\rangle \end{align}

And test a display math without equaltion number:

\begin{align\*} |\psi_1\rangle &= a|0\rangle + b|1\rangle \\\\ |\psi_2\rangle &= c|0\rangle + d|1\rangle \end{align\*}

Test a display math with equation number:

\begin{align} |\psi_1\rangle &= a|0\rangle + b|1\rangle \\\\ |\psi_2\rangle &= c|0\rangle + d|1\rangle \end{align}

And test a display math without equaltion number:

\begin{align\*} |\psi_1\rangle &= a|0\rangle + b|1\rangle \\\\ |\psi_2\rangle &= c|0\rangle + d|1\rangle \end{align\*}

Here are some notes about the above example:

1. The inline formula is between $...$.

2. The display formula is between $$...$$.

3. You can use the math envrionment directly, for example, \begin{equation}...\end{equation} or \begin{align}...\end{align}.

4. Whenever in the inline math or display math, the star character '*' must be escaped.

5. In the multi-lines display math, the line break symbol double-backslash '\\' should be escaped, i.e., use four backslash '\\\\'.

6. If you found error while typeseting math formula, try to escape some special characters.

\begin{aligned} \frac{\partial L}{\partial W} & = \frac{\partial ( (Y - XW)'(Y-XW))}{\partial W} \\\\ & = \frac{\partial (Y'Y - 2W'X'Y + W'X'XW)}{\partial W} \\\\ &= -2X'(Y - XW) \end{aligned}