Mediawiki extensions: math

From wikinotes

Renders MathML in <math> blocks, falling back onto SVG.
I believe this extension is used by wikipedia itself as of 2021.

Documentation

official docs https://www.mediawiki.org/wiki/Extension:Math
supported LaTeX syntax https://www.mediawiki.org/wiki/Extension:Math/Help:Formula#Formatting_using_Template:TeX

Install

1. First, download the extension for your mediawiki version, extract to ${www}/mediawiki/extensions.

2. enable extension

# ${www}/mediawiki/LocalSettings.php

wfLoadExtension( 'Math' );


3. (backup then) run database updater

cd ${www}/mediawiki/maintenance
mysqldump --all-databases > out.sql
php update.php

4. Confirm plugin detected on Special:Version

5. Confirm plugin renders math alright on Special:MathStatus

Usage

Simply write tex between math tags.
Here are some examples:

<math>\exp_a b = a^b, \exp b = e^b, 10^m</math>

Cheat Sheet

Some of the more common items.

\texttt{my-variable}  # arbitrary text

\dfrac{1}{2}          # 1/2
\times{1}{2}          # 1*2
1^{2}                 # 1**2

\bigg( 1+2 \bigg)     # brackets (each 'g' makes larger)

\begin{align}         # within align blocks, newlines align on '&' char
& 2 * 1 = 2 \\
& 2 * 2 = 4 \\        # a \\ indicates a line-break
& 2 * 3 = 6 \\
\end{align}

Configuration

Rendering Modes

All math is expressed in tex, but can be rendered in a variety of ways:

  • MathML
  • LaTex
  • LaTeXML