Mathematical expressions and MathJax

MathJax is a JavaScript library that renders AsciiMath, LaTeX or MathML markup in a web document.

The document needs a link (with the desired configuration) to the MathJax library in the <head> of the document. Look in the source code of this page how this is done. The MathJax documentation provides more information.

LaTeX is a famous markup (non XML/SGML) language for making scientific documents. AsciiMath is a markup that resembles the plain text math format. LaTeX and especially AsciiMath are considerably easier to read and edit for humans, but their markup syntax is alien to HTML. MathJax makes it look acceptable, but the semantic structure of the document will be rather messed up. Moreover, using HTML to mark up simple math or variables make things appear in a messy mix of different markup types.

MathJax is the best-known application for math expressions in web documents, but not the only one. jqMath for instance, is a smaller and faster alternative JavaScript library, using its own math markup language.

Pros:

Cons:

Examples

In Unicode (no MathJax rendering): x2abc = 4.

In AsciiMath: `x = (-b +- sqrt(b^2-4ac))/(2a)`.

In LaTeX: \( x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}\).

In MathML: x = b ± b 2 4 a c 2 a .

AsciiMath:

`φ^2 - φ - 1 = 0 ⇔ φ = (1 + sqrt(5))/2`.

Euler's equation: `e^(iπ) + 1 = 0`.

Summation: `sum_(i=1)^n i^3=((n(n+1))/2)^2`

`[[x'],[y']] = [[cosθ,sinθ],[-sinθ,cosθ]] [[x],[y]]`

LaTeX:

\(φ^{2} - φ -1=0 \Leftrightarrow φ = \frac{1+\sqrt{5}}{2}\).

\[φ^{2} - φ -1=0 ⇔ φ = \frac{1+\sqrt{5}}{2}\]

Euler's equation: \(e^{iπ} + 1 = 0\).

Summation: \(\sum_{i=1}^{n}i^{3}=\left ( \frac{n(n+1))}{2} \right )^{2}\)

\[\sum_{i=1}^{n}i^{3}=\left ( \frac{n(n+1))}{2} \right )^{2}\]

\[ \begin{bmatrix} x'\\y' \end{bmatrix} = \begin{bmatrix} cos\theta & sin\theta \\ -sin\theta & cos\theta \end{bmatrix} \begin{bmatrix} x\\y \end{bmatrix} \]