Math Formula Guide
A LaTeX/KaTeX math formula guide for Markdown: how to write inline and block formulas, plus fractions, sub/superscripts, roots, matrices, integrals, summations and Greek letters — every example rendered live.
#Inline and Block Formulas
Inline Math
Markdown Source
In Markdown, wrap LaTeX formulas with a single `$` symbol to create **inline formulas**. Einstein's mass-energy equation $E = mc^2$ is one of the most famous formulas in physics. The Pythagorean theorem can be expressed as $a^2 + b^2 = c^2$. The area of a circle is $A = \pi r^2$. Inline formulas display within the same line of text, perfect for embedding short mathematical expressions in paragraphs.
Rendered Result
Block Math
Markdown Source
Use double `$$` symbols to create **block formulas** that are centered on their own line:
$$
E = mc^2
$$
$$
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
$$
Block formulas are ideal for displaying longer or more prominent mathematical expressions.Rendered Result
#Basic Operators
Arithmetic and Power Operations
Markdown Source
LaTeX supports common mathematical operators:
**Addition/Subtraction**: $a + b$, $a - b$
**Multiplication**: $a \times b$, $a \cdot b$
**Division**: $a \div b$
**Power**: $x^2$, $x^3$, $2^{10}$
**Modulo**: $a \mod b$
Combined example:
$$
(x + y)^2 = x^2 + 2xy + y^2
$$Rendered Result
Comparison Operators
Markdown Source
Common comparison operators: - Equal: $a = b$ - Not equal: $a \neq b$ - Greater than: $a > b$ - Less than: $a < b$ - Greater than or equal: $a \geq b$ - Less than or equal: $a \leq b$ - Approximately equal: $a \approx b$ - Equivalent to: $a \equiv b$
Rendered Result
#Fractions and Roots
Fractions
Markdown Source
Use `\frac{numerator}{denominator}` to create fractions:
Simple fractions: $\frac{1}{2}$, $\frac{3}{4}$
Complex fractions: $\frac{a+b}{c-d}$
Nested fractions:
$$
\frac{1}{1+\frac{1}{1+\frac{1}{2}}}
$$
Use `\dfrac` for larger inline fractions: $\dfrac{a}{b}$ vs $\frac{a}{b}$Rendered Result
Roots
Markdown Source
Use `\sqrt{}` for square roots and `\sqrt[n]{ }` for nth roots:
Square roots: $\sqrt{2}$, $\sqrt{x^2 + y^2}$
nth roots: $\sqrt[3]{8}$, $\sqrt[n]{x}$
Combined example:
$$
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$
This is the famous **quadratic formula**.Rendered Result
#Subscripts and Superscripts
Superscripts
Markdown Source
Use `^` to create superscripts:
$x^2$, $x^3$, $x^{n+1}$
Multi-character superscripts require braces: $x^{10}$ (not `x^10`)
Common uses:
- Exponents: $e^{x}$
- Powers: $2^{32}$
- Transpose: $A^{T}$
- Derivatives: $f^{\prime}(x)$, $f^{\prime\prime}(x)$Rendered Result
Subscripts
Markdown Source
Use `_` to create subscripts:
$x_1$, $x_2$, $x_{i,j}$
Multi-character subscripts require braces: $a_{max}$
Common uses:
- Indices: $x_1, x_2, \ldots, x_n$
- Matrix elements: $a_{ij}$
- Partial derivatives: $f_{x}$
Combined subscripts and superscripts: $x_1^2$, $a_{i}^{n}$Rendered Result
#Greek Letters
Common Greek Letters
Markdown Source
LaTeX provides full Greek letter support: **Lowercase letters**: $\alpha$, $\beta$, $\gamma$, $\delta$, $\epsilon$, $\zeta$, $\eta$, $\theta$, $\lambda$, $\mu$, $\nu$, $\xi$, $\pi$, $\rho$, $\sigma$, $\tau$, $\phi$, $\chi$, $\psi$, $\omega$ **Uppercase letters**: $\Gamma$, $\Delta$, $\Theta$, $\Lambda$, $\Xi$, $\Pi$, $\Sigma$, $\Phi$, $\Psi$, $\Omega$ **Variant forms**: $\varepsilon$ (variant epsilon), $\vartheta$ (variant theta), $\varphi$ (variant phi)
Rendered Result
Greek Letter Applications
Markdown Source
Greek letters are widely used in mathematical formulas: **Physics**: $F = ma$ (force), $\omega = 2\pi f$ (angular frequency), $\lambda$ (wavelength), $\rho$ (density) **Calculus**: $\delta$ (variation symbol), $\epsilon$-$\delta$ definition **Probability & Statistics**: $\mu$ (mean), $\sigma$ (standard deviation), $\Omega$ (sample space) $$ \Delta x = x_2 - x_1 $$
Rendered Result
#Sums and Integrals
Summation and Products
Markdown Source
**Summation** `\sum`:
$$
\sum_{i=1}^{n} i^2 = \frac{n(n+1)(2n+1)}{6}
$$
**Product** `\prod`:
$$
n! = \prod_{i=1}^{n} i
$$
**Limit** `\lim`:
$$
\lim_{n \to \infty} \left(1 + \frac{1}{n}\right)^n = e
$$
Inline versions: $\sum_{i=1}^{n} i$, $\prod_{k=1}^{n} k$, $\lim_{x \to 0} f(x)$Rendered Result
Integrals
Markdown Source
**Indefinite integral**:
$$
\int x^2 \, dx = \frac{x^3}{3} + C
$$
**Definite integral**:
$$
\int_{0}^{1} x^2 \, dx = \frac{1}{3}
$$
**Multiple integrals**:
$$
\iint_D f(x,y) \, dx \, dy
$$
$$
\iiint_V f(x,y,z) \, dx \, dy \, dz
$$
**Line/surface integrals**:
$$
\oint_C \vec{F} \cdot d\vec{r}
$$Rendered Result
#Matrices
Basic Matrices
Markdown Source
Use `\begin{matrix}` for unbracketed matrices:
$$
\begin{matrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{matrix}
$$
Use `\begin{pmatrix}` for parentheses:
$$
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
$$
Use `\begin{bmatrix}` for square brackets:
$$
\begin{bmatrix}
1 & 0 \\
0 & 1
\end{bmatrix}
$$Rendered Result
More Matrix Styles and Determinants
Markdown Source
**Curly brace matrix** `\begin{Bmatrix}`:
$$
\begin{Bmatrix}
a & b \\
c & d
\end{Bmatrix}
$$
**Determinant** `\begin{vmatrix}`:
$$
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix} = ad - bc
$$
**Matrix with ellipsis**:
$$
\begin{pmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\
a_{21} & a_{22} & \cdots & a_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m1} & a_{m2} & \cdots & a_{mn}
\end{pmatrix}
$$Rendered Result
#Equations and Alignment
Multi-line Equation Alignment
Markdown Source
Use the `align` environment to align multi-line equations. `&` specifies alignment points:
$$
\begin{align}
f(x) &= x^2 + 2x + 1 \\
&= (x+1)^2
\end{align}
$$
Multi-step derivation:
$$
\begin{align}
(a+b)^2 &= (a+b)(a+b) \\
&= a^2 + ab + ba + b^2 \\
&= a^2 + 2ab + b^2
\end{align}
$$Rendered Result
Equation Systems
Markdown Source
Use the `cases` environment for piecewise functions or equation systems:
**Piecewise function**:
$$
f(x) = \begin{cases}
x^2 & \text{if } x \geq 0 \\
-x^2 & \text{if } x < 0
\end{cases}
$$
**Equation system**:
$$
\begin{cases}
x + y = 5 \\
2x - y = 1
\end{cases}
$$
**Absolute value function**:
$$
|x| = \begin{cases}
x & x \geq 0 \\
-x & x < 0
\end{cases}
$$Rendered Result
#Common Mathematical Symbols
Set and Logic Symbols
Markdown Source
**Set symbols**:
- Element of: $x \in A$
- Not an element of: $x \notin A$
- Subset: $A \subset B$, $A \subseteq B$
- Proper subset: $A \subsetneq B$
- Union: $A \cup B$
- Intersection: $A \cap B$
- Empty set: $\emptyset$ or $\varnothing$
- Universal set: $\mathbb{U}$
**Logic symbols**:
- And: $p \land q$
- Or: $p \lor q$
- Not: $\neg p$
- Implies: $p \Rightarrow q$
- If and only if: $p \Leftrightarrow q$
- For all: $\forall$
- There exists: $\exists$Rendered Result
Arrows and Special Symbols
Markdown Source
**Arrows**: - Right arrow: $\rightarrow$ or $\to$ - Left arrow: $\leftarrow$ - Bidirectional arrow: $\leftrightarrow$ - Long arrow: $\Longrightarrow$ - Maps to: $\mapsto$ **Special symbols**: - Infinity: $\infty$ - Partial derivative: $\partial$ - Nabla (gradient operator): $\nabla$ - Plus-minus: $\pm$, $\mp$ - Ellipsis: $\ldots$, $\cdots$, $\vdots$, $\ddots$ - Degrees: $30^\circ$ - Angle: $\angle ABC$
Rendered Result
#Advanced Usage
Brackets and Delimiters
Markdown Source
LaTeX provides various brackets. Use `\left` and `\right` for auto-sizing:
**Manual vs auto-sizing**:
$(\frac{a}{b})$ vs $\left(\frac{a}{b}\right)$
**Bracket types**:
- Parentheses: $\left( \frac{a}{b} \right)$
- Square brackets: $\left[ \frac{a}{b} \right]$
- Curly braces: $\left\{ \frac{a}{b} \right\}$
- Angle brackets: $\left\langle \frac{a}{b} \right\rangle$
- Absolute value: $\left| \frac{a}{b} \right|$
- Norm: $\left\| \vec{v} \right\|$
**One-sided brackets**:
$\left. \frac{dy}{dx} \right|_{x=1}$Rendered Result
Fonts and Function Names
Markdown Source
**Math fonts**:
- Bold: $\mathbf{A}$ (vectors/matrices)
- Blackboard bold: $\mathbb{R}$ (real numbers), $\mathbb{N}$ (natural numbers)
- Italic: $\mathit{x}$ (variables)
- Roman: $\mathrm{d}x$ (differential symbol)
- Fraktur: $\mathfrak{g}$
**Common function names** (upright style):
$\sin x$, $\cos x$, $\tan x$
$\log x$, $\ln x$, $\exp(x)$
$\max(a,b)$, $\min(a,b)$
$\det(A)$, $\dim(V)$
Vectors:
$\vec{a}$, $\mathbf{a}$, $\hat{x}$Rendered Result
Spacing and Layout Tips
Markdown Source
Spacing control in LaTeX math mode:
- No space: $ab$
- Thin space: $a\,b$
- Medium space: $a\;b$
- Thick space: $a\quad b$
- Extra thick space: $a\qquad b$
**Common layout tips**:
Adding space in integrals:
$$
\int_0^1 x^2 \, dx \quad \text{vs} \quad \int_0^1 x^2 dx
$$
Using `\text{}` to insert text in formulas:
$$
\text{When } x > 0, \text{ we have } f(x) = \sqrt{x}
$$
Using `\color{}` to change color (partial support):
$$
\textcolor{red}{E} = mc^2
$$Rendered Result
#Practical Tips
Common Physics and Math Formulas
Markdown Source
**Newton's Second Law**:
$$
\vec{F} = m\vec{a} = m\frac{d\vec{v}}{dt}
$$
**Schrödinger Equation**:
$$
i\hbar\frac{\partial}{\partial t}\Psi(\vec{r},t) = \hat{H}\Psi(\vec{r},t)
$$
**Euler's Identity**:
$$
e^{i\pi} + 1 = 0
$$
**Taylor Series**:
$$
f(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}(x-a)^n
$$
**Gaussian Integral**:
$$
\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}
$$Rendered Result
Writing Tips and Notes
Markdown Source
**1. Special character escaping**
In LaTeX, these characters need escaping: `# $ % & _ { }`
Use backslash to escape: $\$$, $\%$, $\&$, $\_$
**2. Line breaks in long formulas**
Use `\\` to break lines in the align environment:
$$
\begin{align}
y &= a_0 + a_1x + a_2x^2 \\
&\quad + a_3x^3 + a_4x^4
\end{align}
$$
**3. Custom equation numbering**
Use `\tag{}` for custom numbering:
$$
a^n + b^n = c^n \tag{1}
$$
**4. Inline formula tips**
For complex inline formulas, consider using block formulas for better readability.Rendered Result
#More Resources
Keep Exploring
Markdown Source
Want to learn more Markdown syntax? Check out the **[Syntax Guide](/en/syntax)** page for complete Markdown syntax documentation including headings, lists, code blocks, tables, diagrams, and more with live rendering previews. Ready to edit math formulas? Open the **[Markdown Editor](/en/)** to start writing with real-time LaTeX/KaTeX formula rendering. > **Tip**: This editor uses the KaTeX engine for math formula rendering, supporting most LaTeX math syntax. For more LaTeX symbols, refer to the [KaTeX documentation](https://katex.org/docs/supported).
Rendered Result