Table of Contents
MathJax
MathJax allows to insert mathematical expressions in one's web pages with the advantages of a high-quality typography and compatibility with all modern browsers. It requires JavaScript enabled.
Configure MathJax
The following is a typical MathJax's configuration file that can be edited as one's please:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], displayMath: [["$$","$$"], ["\\[","\\]"]], processEscapes: true }, TeX: { equationNumbers: {autoNumber: "AMS"}, extensions: ["enclose.js", "cancel.js" } });
Insert maths formulae
To enable MathJax to process maths formulae within $
and $$
delimiters, add to one's configuration file for MathJax the following code:
tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], displayMath: [["$$","$$"], ["\\[","\\]"]], processEscapes: true }
Basically there are three ways to delimit a maths formulae:
- in-line formula:
$...$
- centred formula:
$$...$$
- aligned multi-line formula:
\begin{align}...\end{align}
Tags and Refs
In order to number maths equations automatically, add to one's configuration file for MathJax the following code:
TeX: { equationNumbers: {autoNumber: "AMS"} }
Code
Output
Note
\begin{align} y = x + 1 \end{align}
\begin{align} y = x + 1 \end{align}
{align}
to number automatically.
\begin{align*} y = x + 1 \end{align*}
\begin{align*} y = x + 1 \end{align*}
{align*}
for not to number.
... eq. (\ref{A}) is: \begin{align} y = x + 1 \label{A} \end{align} As in eq. (\ref{A}) ...
… eq. (\ref{A}) is: \begin{align} y = x + 1 \label{A} \end{align} As in eq. (\ref{A}) …
... eq. (\ref{B}) is: \begin{align} y = x + 1 \tag{$\clubsuit$} \label{B} \end{align} As in eq. (\ref{B}) ...
… eq. (\ref{B}) is: \begin{align} y = x + 1 \tag{$\clubsuit$} \label{B} \end{align} As in eq. (\ref{B}) …
\begin{align} \begin{split} x + y + z & = 3 \\ x & = 1 \\ y & = 1 \\ \end{split} \end{align}
\begin{align}
\begin{split}
x + y + z & = 3
x & = 1
y & = 1
\end{split}
\end{align}
{split}
to give unique number to multi-line equation.
\begin{align} x + y + z & = 3 \\ x & = 1 \notag \\ y & = 1 \\ \end{align}
\begin{align}
x + y + z & = 3
x & = 1 \notag
y & = 1
\end{align}
\notag
for not to number the corresponding line.
Wrapped objects
In order to use the \enclose
extension, add to one's configuration file for MathJax the following code:
TeX: { extensions: ["enclose.js"] }
Code
Output
\begin{align} \bbox[20px, lightblue, border: 1px solid grey]{ y = x + 1 } \end{align}
\begin{align} \bbox[20px, lightblue, border: 1px solid grey]{ y = x + 1 } \end{align}
$$ \enclose{roundedbox}{10} $$
$$ \enclose{roundedbox}{10} $$
$$ \begin{bmatrix} \overset{ \color{red}{c_{ij}} }{ \bbox[border:2px solid red]{ \begin{matrix} 1 & 2 \\ 4 & 5 \\ \end{matrix} } } & \begin{matrix} 3 \\ 6 \\ \end{matrix} \\ \begin{matrix} 7 & 8 \\ \end{matrix} & \begin{matrix} 9 \\ \end{matrix} \end{bmatrix} $$
$$ \begin{bmatrix}
\overset{ \color{red}{c_{ij}} }{
\bbox[border:2px solid red]{
\begin{matrix}
1 & 2
4 & 5
\end{matrix}
}
}
&
\begin{matrix}
3
6
\end{matrix}
\begin{matrix}
7 & 8
\end{matrix}
&
\begin{matrix}
9
\end{matrix}
\end{bmatrix}
$$
Colours
Code
Output
$$ \color{red}{text} $$
$$ \color{red}{text} $$
Fonts
Code
Output
\Bbb{CHNQRZ}
$$ \Bbb{CHNQRZ} $$
{\cal AaBbCc .. XxYyZz}
$$ {\cal AaBbCc .. XxYyZz} $$
Radical signs
Code
Output
$$ \sqrt{x^3} $$
$$ \sqrt{x^3} $$
$$ \sqrt[3]{\frac xy} $$
$$ \sqrt[3]{\frac xy} $$
Matrices
Code
Output
$$ \begin{matrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{matrix} $$
$$
\begin{matrix}
1 & x & x^2
1 & y & y^2
1 & z & z^2
\end{matrix}
$$
$$ \begin{pmatrix} 1 & 2 \\ 3 & 4 \\ \end{pmatrix} $$
$$
\begin{pmatrix}
1 & 2
3 & 4
\end{pmatrix}
$$
$$ \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ \end{bmatrix} $$
$$
\begin{bmatrix}
1 & 2
3 & 4
\end{bmatrix}
$$
$$ \begin{Bmatrix} 1 & 2 \\ 3 & 4 \\ \end{Bmatrix} $$
$$
\begin{Bmatrix}
1 & 2
3 & 4
\end{Bmatrix}
$$
$$ \begin{vmatrix} 1 & 2 \\ 3 & 4 \\ \end{vmatrix} $$
$$
\begin{vmatrix}
1 & 2
3 & 4
\end{vmatrix}
$$
$$ \begin{Vmatrix} 1 & 2 \\ 3 & 4 \\ \end{Vmatrix} $$
$$
\begin{Vmatrix}
1 & 2
3 & 4
\end{Vmatrix}
$$
$$ \begin{pmatrix} 1 & a & \cdots & z \\ 1 & a & \cdots & z \\ \vdots & \vdots & \ddots & \vdots \\ 1 & a & \cdots & z \\ \end{pmatrix} $$
$$
\begin{pmatrix}
1 & a & \cdots & z
1 & a & \cdots & z
\vdots & \vdots & \ddots & \vdots
1 & a & \cdots & z
\end{pmatrix}
$$
$$ \begin{bmatrix} \begin{array}{cc|c} 1 & 2 & 3 \\ 4 & 5 & 6 \\ \end{array} \end{bmatrix} $$
$$
\begin{bmatrix}
\begin{array}{cc|c}
1 & 2 & 3
4 & 5 & 6
\end{array}
\end{bmatrix}
$$
Arrays
Code
Output
$$ \begin{array}{c|lcr} n & \text{A} & \text{B} & \text{C} \\ \hline center & left & 2 & 3 \\ 0 & 1 & center & 3 \\ 0 & 1 & 2 & right \\ \end{array} $$
$$
\begin{array}{c|lcr}
n & \text{A} & \text{B} & \text{C}
\hline
center & left & 2 & 3
0 & 1 & center & 3
0 & 1 & 2 & right
\end{array}
$$
Horizontal space
Code
Output
$$ {\cal normal\ space} $$
$$ {\cal normal\ space} $$
$$ \forall x \in X, \quad \exists y \leq \epsilon $$
$$ \forall x \in X, \quad \exists y \leq \epsilon $$
$$ \overset{small \: space}{ text } $$
$$ \overset{small \: space}{ text } $$
Parentheses
Code
Output
$$ \left\{ \left[ \left( \frac{1}{2} \right) \right] \right\}^{3/2} $$
$$ \left\{ \left[ \left( \frac{1}{2} \right) \right] \right\}^{3/2} $$
\Bigg\{ \bigg[ \Big( \big( (
$$ \Bigg\{ \bigg[ \Big( \big( ( $$
\begin{align*} & \left( x + y\ + \right. \\ & \left. -\ z \right) \\ \end{align*}
\begin{align*}
& \left( x + y\ + \right.
& \left. -\ z \right)
\end{align*}
Aligned equations
Code
Output
\begin{align*} a + b + c & = d + f \\ a + b & = d \\ \end{align*}
\begin{align*}
a + b + c & = d + f
a + b & = d
\end{align*}
System of equations
Code
Output
\begin{align} \left\{ \begin{array}{ll} a + b + c & = d + f \\ a + b & = d \\ \end{array} \right. \end{align}
\begin{align}
\left\{
\begin{array}{ll}
a + b + c & = d + f
a + b & = d
\end{array}
\right.
\end{align}
Definitions by cases
Code
Output
$$ f = \begin{cases} x & \text{if ..} \\ x+1 & \text{otherwise} \\ \end{cases} $$
$$ f =
\begin{cases}
x & \text{if ..}
x+1 & \text{otherwise}
\end{cases}
$$
$$ \left. \begin{array}{l} \text{if ..} & x \\ \text{otherwise} & x + 1 \\ \end{array} \right\} = f $$
$$
\left.
\begin{array}{l}
\text{if ..} & x
\text{otherwise} & x + 1
\end{array}
\right\}
= f
$$
Cross out symbol
In order to use the \cancel
extension, add to one's configuration file for MathJax the following code:
TeX: { extensions: ["cancel.js"] }
Code
Output
$$ \cancel{y + x} $$
$$ \cancel{y + x} $$
$$ \bcancel{y + x} $$
$$ \bcancel{y + x} $$
$$ \xcancel{y + x} $$
$$ \xcancel{y + x} $$
$$ \cancelto{0}{y + x} $$
$$ \cancelto{0}{y + x} $$
Pile of objects
Code
Output
$$ \overset{over}{ text } $$
$$ \overset{over}{ text } $$
$$ \underset{under}{ \underbrace{text} } $$
$$ \underset{under}{ \underbrace{text} } $$
$$ \stackrel{(\ref{B})} = $$
$$ \stackrel{(\ref{B})} = $$
$$ \lim_{x \to 0} $$
$$ \lim_{x \to 0} $$
$$ \sum_{i = 1}^{n} $$
$$ \sum_{i = 1}^{n} $$
$$ \int_{a}^{b} $$
$$ \int_{a}^{b} $$
Links
- meta.math.stackexchange.com: quick reference about MathJax.
- onemathematicalcat.org: all the symbols available in MathJax.
- detexify.kirelabs.org: automatic recognition of a LaTex's symbol from its sketch.
- docs.mathjax.org: the official MathJax's doc.