AI Web FeedsAI Web FeedsOpen web AI reader
  • Features
    Documentation

    Math Equations

    Render beautiful mathematical equations in your documentation using KaTeX

    Source: apps/web/content/docs/features/math.mdx

    Overview

    KaTeX is a fast, easy-to-use JavaScript library for rendering TeX math notation on the web. This site integrates KaTeX to enable beautiful mathematical equations in documentation.

    Features

    • Fast rendering - KaTeX is significantly faster than MathJax
    • High quality - Produces crisp output at any zoom level
    • Self-contained - No dependencies on external fonts or stylesheets
    • Server-side rendering - Works without JavaScript enabled
    • TeX/LaTeX syntax - Familiar notation for mathematicians

    Basic Usage

    Inline Math

    Wrap inline equations with single dollar signs $...$:

    The Pythagorean theorem states that $c = \pm\sqrt{a^2 + b^2}$ for a right triangle.

    The Pythagorean theorem states that c=±a2+b2c = \pm\sqrt{a^2 + b^2} for a right triangle.

    Block Math

    Use code blocks with the math language identifier or wrap with double dollar signs $$...$$:

    ```math
    c = \pm\sqrt{a^2 + b^2}
    ```
    c=±a2+b2c = \pm\sqrt{a^2 + b^2}

    Or using double dollar signs:

    $$
    E = mc^2
    $$
    E=mc2E = mc^2

    Common Examples

    Algebra

    Quadratic Formula:

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

    Binomial Theorem:

    (x+y)n=k=0n(nk)xnkyk(x + y)^n = \sum_{k=0}^{n} \binom{n}{k} x^{n-k} y^k

    Calculus

    Fundamental Theorem of Calculus:

    abf(x)dx=F(b)F(a)\int_a^b f(x) \, dx = F(b) - F(a)

    Partial Derivatives:

    2fxy=2fyx\frac{\partial^2 f}{\partial x \partial y} = \frac{\partial^2 f}{\partial y \partial x}

    Limit Definition:

    limx(1+1x)x=e\lim_{x \to \infty} \left(1 + \frac{1}{x}\right)^x = e

    Linear Algebra

    Matrix Multiplication:

    [abcd][efgh]=[ae+bgaf+bhce+dgcf+dh]\begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} e & f \\ g & h \end{bmatrix} = \begin{bmatrix} ae + bg & af + bh \\ ce + dg & cf + dh \end{bmatrix}

    Determinant:

    det(A)=abcd=adbc\det(A) = \begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc

    Statistics & Probability

    Normal Distribution:

    f(x)=1σ2πe12(xμσ)2f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2}

    Bayes' Theorem:

    P(AB)=P(BA)P(A)P(B)P(A|B) = \frac{P(B|A) \cdot P(A)}{P(B)}

    Complex Analysis

    Taylor Series Expansion:

    The Taylor expansion expresses a holomorphic function f(z)f(z) as a power series:

    Tf(z)=k=0(zc)k2πiγf(w)(wc)k+1dw=12πiγf(w)wck=0(zcwc)kdw=12πiγf(w)wc(11zcwc)dw=12πiγf(w)wzdw=f(z),\displaystyle {\begin{aligned}T_{f}(z)&=\sum _{k=0}^{\infty }{\frac {(z-c)^{k}}{2\pi i}}\int _{\gamma }{\frac {f(w)}{(w-c)^{k+1}}}\,dw\\&={\frac {1}{2\pi i}}\int _{\gamma }{\frac {f(w)}{w-c}}\sum _{k=0}^{\infty }\left({\frac {z-c}{w-c}}\right)^{k}\,dw\\&={\frac {1}{2\pi i}}\int _{\gamma }{\frac {f(w)}{w-c}}\left({\frac {1}{1-{\frac {z-c}{w-c}}}}\right)\,dw\\&={\frac {1}{2\pi i}}\int _{\gamma }{\frac {f(w)}{w-z}}\,dw=f(z),\end{aligned}}

    Euler's Formula:

    eix=cos(x)+isin(x)e^{ix} = \cos(x) + i\sin(x)

    Physics

    Schrödinger Equation:

    itΨ(r,t)=H^Ψ(r,t)i\hbar\frac{\partial}{\partial t}\Psi(\mathbf{r},t) = \hat{H}\Psi(\mathbf{r},t)

    Maxwell's Equations:

    E=ρϵ0B=0×E=Bt×B=μ0J+μ0ϵ0Et\begin{aligned} \nabla \cdot \mathbf{E} &= \frac{\rho}{\epsilon_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\epsilon_0\frac{\partial \mathbf{E}}{\partial t} \end{aligned}

    Lagrangian Mechanics:

    The action functional SS is defined as:

    S[q]=abL(t,q(t),q˙(t))dt.\displaystyle S[{\boldsymbol {q}}]=\int _{a}^{b}L(t,{\boldsymbol {q}}(t),{\dot {\boldsymbol {q}}}(t))\,dt.

    Advanced Features

    Multi-line Equations

    Use aligned environment for aligned equations:

    f(x)=(x+a)(x+b)=x2+(a+b)x+ab\begin{aligned} f(x) &= (x+a)(x+b) \\ &= x^2 + (a+b)x + ab \end{aligned}

    Cases and Piecewise Functions

    f(x)={x2if x0x2if x<0f(x) = \begin{cases} x^2 & \text{if } x \geq 0 \\ -x^2 & \text{if } x < 0 \end{cases}

    Fractions and Continued Fractions

    11+12+13+14\frac{1}{\displaystyle 1+\frac{1}{\displaystyle 2+\frac{1}{\displaystyle 3+\frac{1}{4}}}}

    Greek Letters and Symbols

    Common symbols used in mathematics:

    • Greek: α,β,γ,δ,ϵ,θ,λ,μ,π,σ,ω\alpha, \beta, \gamma, \delta, \epsilon, \theta, \lambda, \mu, \pi, \sigma, \omega
    • Operators: ,,,,\sum, \prod, \int, \nabla, \partial
    • Relations: ,,,,,\leq, \geq, \neq, \approx, \equiv, \propto
    • Sets: ,,,,,,\in, \notin, \subset, \subseteq, \cup, \cap, \emptyset
    • Logic: ,,¬,,,    ,    \forall, \exists, \neg, \land, \lor, \implies, \iff

    Subscripts and Superscripts

    x1,x2,,xnanda2+b2=c2x_1, x_2, \ldots, x_n \quad \text{and} \quad a^2 + b^2 = c^2

    Large Operators

    Summation:

    i=1ni=n(n+1)2\sum_{i=1}^{n} i = \frac{n(n+1)}{2}

    Product:

    i=1ni=n!\prod_{i=1}^{n} i = n!

    Integration:

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

    Special Formatting

    Colored Equations

    KaTeX supports color through the \textcolor and \colorbox commands:

    F=maandE=mc2\textcolor{red}{F = ma} \quad \text{and} \quad \colorbox{yellow}{$E = mc^2$}

    Sizing

    Control the size of your equations:

    tinysmallnormallargeLargeLARGEhuge\tiny{tiny} \quad \small{small} \quad \normalsize{normal} \quad \large{large} \quad \Large{Large} \quad \LARGE{LARGE} \quad \huge{huge}

    Spacing

    Fine-tune spacing in equations:

    a ⁣bababa  ba bababa\!b \quad a\,b \quad a\:b \quad a\;b \quad a\ b \quad a\quad b \quad a\qquad b

    Best Practices

    Keep It Readable

    Use clear variable names and proper spacing:

    P(X=k)=(nk)pk(1p)nkP(X = k) = \binom{n}{k} p^k (1-p)^{n-k}

    Cramped or unclear notation:

    P(X=k)=(nk)pk(1p)nkP(X=k)=\binom{n}{k}p^k(1-p)^{n-k}

    Use Display Style for Complex Equations

    For complex fractions and large operators, use \displaystyle:

    i=1n1i2=π26\displaystyle \sum_{i=1}^{n} \frac{1}{i^2} = \frac{\pi^2}{6}

    Break Long Equations

    For very long equations, use multiple lines with aligned:

    (a+b)3=(a+b)(a+b)2=(a+b)(a2+2ab+b2)=a3+3a2b+3ab2+b3\begin{aligned} (a + b)^3 &= (a + b)(a + b)^2 \\ &= (a + b)(a^2 + 2ab + b^2) \\ &= a^3 + 3a^2b + 3ab^2 + b^3 \end{aligned}

    Label Important Equations

    Use text annotations to explain components:

    eiπEuler’s identity+1=0\underbrace{e^{i\pi}}_{\text{Euler's identity}} + 1 = 0

    Common Syntax Reference

    Basic Operations

    SyntaxResultDescription
    x + yx+yx + yAddition
    x - yxyx - ySubtraction
    x \times yx×yx \times yMultiplication
    x \div yx÷yx \div yDivision
    \frac{x}{y}xy\frac{x}{y}Fraction
    x^yxyx^ySuperscript
    x_yxyx_ySubscript
    \sqrt{x}x\sqrt{x}Square root
    \sqrt[n]{x}xn\sqrt[n]{x}nth root

    Delimiters

    SyntaxResultDescription
    (x)(x)(x)Parentheses
    [x][x][x]Brackets
    \{x\}{x}\{x\}Braces
    \langle x \ranglex\langle x \rangleAngle brackets
    \lvert x \rvertx\lvert x \rvertAbsolute value
    \lVert x \rVertx\lVert x \rVertNorm

    Troubleshooting

    Equation Not Rendering

    • Check that katex/dist/katex.css is imported in your layout
    • Verify the TeX syntax is valid
    • Ensure remark-math and rehype-katex are configured correctly
    • Use the KaTeX Live Demo to test syntax

    Missing Symbols

    • Not all LaTeX commands are supported by KaTeX
    • Check the KaTeX Support Table
    • Consider using alternative notation

    Escaping Special Characters

    Use backslash to escape special characters:

    Use \$ for a dollar sign, not $\$$ in math mode.

    Pro Tip

    You can copy equations from Wikipedia - they're already in LaTeX format and work directly with KaTeX!

    Try it: Visit any Wikipedia math article, right-click an equation, and select "Copy LaTeX code".

    Resources

    Next Steps

    Math Equations | AI Web Feeds