LaTeX Formula Rules
Strict Formatting Requirements
Inline Formulas
- Format:
$formula$
- Rule: NO spaces inside delimiters
- Examples:
- ✅
$x + y$
- ✅
$\sum_{i=1}^{n} x_i$
- ❌
$ x + y $
- ❌
$x+y$ (missing spaces around operators is ok, but be consistent)
Display Formulas
- Format:
$$formula$$
- Rule: NO spaces inside delimiters
- Examples:
- ✅
$$\nabla f(x)$$
- ✅
$$\mathbb{E}_{x \sim p}[f(x)]$$
- ❌
$$ \nabla f(x) $$
Common Symbols
| Symbol |
LaTeX |
Meaning |
| Σ |
\sum |
Summation (for loop) |
| ∏ |
\prod |
Product |
| ∫ |
\int |
Integral |
| ∇ |
\nabla |
Gradient (.grad) |
| ∂ |
\partial |
Partial derivative |
| ∈ |
\in |
Element of |
| ⊂ |
\subset |
Subset |
| ∀ |
\forall |
For all |
| ∃ |
\exists |
Exists |
| ℝ |
\mathbb{R} |
Real numbers |
| 𝔼 |
\mathbb{E} |
Expectation |
| θ |
\theta |
Parameters |
| ∇_θ |
\nabla_\theta |
Gradient w.r.t. θ |
Greek Letters (Common in ML)
α \alpha β \beta γ \gamma δ \delta
ε \epsilon ζ \zeta η \eta θ \theta
λ \lambda μ \mu ν \nu ξ \xi
π \pi ρ \rho σ \sigma τ \tau
φ \phi χ \chi ψ \psi ω \omega
Best Practices
- Always escape special characters:
#, $, %, &, _, {, }
- Use
\left( and \right) for auto-sizing parentheses
- Use
\cdot for multiplication dots: $x \cdot y$
- Use
\frac{num}{den} for fractions: $\frac{1}{n}$
- Use
\sqrt{} for square roots: $\sqrt{x^2 + y^2}$