Back to blogs

Mathematical Notation with KaTeX

1. Inline Mathematics

Mathematical notation should flow naturally within the text. For example, the Pythagorean theorem is defined as a2+b2=c2a^2 + b^2 = c^2.

We can also discuss Euler's identity, eiπ+1=0e^{i\pi} + 1 = 0, which is often cited as one of the most beautiful equations in mathematics. When xx approaches infinity (xx \to \infty), the function f(x)=1xf(x) = \frac{1}{x} approaches zero.


2. Display (Block) Mathematics

Equations that need emphasis should be rendered in their own block.

The Quadratic Formula:

x=b±b24ac2ax = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

The Gaussian Integral:

This is a famous integral in statistics and physics.

ex2dx=π\int_{-\infty}^{\infty} e^{-x^2} \,dx = \sqrt{\pi}

Limit Definition of the Derivative:

f(x)=limh0f(x+h)f(x)hf'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}

3. Matrices and Arrays

Testing grid alignment and bracket scaling.

A=(a11a12a13a21a22a23a31a32a33)A = \begin{pmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \end{pmatrix}

A system of equations:

{3x+5yz=102xy+2z=5x+y+z=4\begin{cases} 3x + 5y - z = 10 \\ 2x - y + 2z = 5 \\ x + y + z = 4 \end{cases}

4. Complex Notations & Summation

Riemann Sum:

S=i=1nf(xi)ΔxiS = \sum_{i=1}^{n} f(x_i^*) \Delta x_i

Maxwell's Equations (Differential Form):

E=ρε0B=0×E=Bt×B=μ0J+μ0ε0Et\begin{aligned} \nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\ \nabla \cdot \mathbf{B} &= 0 \\ \nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \\ \nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0 \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \end{aligned}

5. Logic and Set Theory

  • Union: ABA \cup B
  • Intersection: ABA \cap B
  • Subset: ABA \subseteq B
  • For All: xR\forall x \in \mathbb{R}
  • Exists: nN\exists n \in \mathbb{N} such that n>10n > 10.
NZQRC\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C}

6. Chemistry Test (mhchem support check)

Note: Standard KaTeX supports basic chemistry, but mhchem extension is required for complex reactions. If this renders as plain text variables, you may need to enable the extension in your config.

\ce2H2+O2>2H2O\ce{2H2 + O2 -> 2H2O}

(If the above looks like "ce 2H2..." it means the mhchem extension is not enabled, which is the default for standard KaTeX).