Markdown Math Formulas
In technical documentation, academic papers, and tutorials, mathematical formulas are often needed. While standard Markdown doesn't support math formulas, many Markdown editors and platforms support math formula display through LaTeX syntax. This chapter will detail how to write math formulas in Markdown.
Math Formula Basics
Two Types of Formulas
Math formulas are divided into two types:
- Inline formulas: Formulas embedded in paragraphs
- Block formulas: Formulas displayed independently
Inline Formulas
Use single $ symbol to wrap:
Effect:
Einstein's mass-energy equation is $E = mc^2$.
Block Formulas
Use double $ symbols to wrap:
Effect:
$$ E = mc^2 $$
Supported Platforms
GitHub
- Does not support math formulas (unless using special renderers)
- Needs MathJax or KaTeX
GitLab
- Full support
- Uses KaTeX rendering
Typora
- Full support
- Supports real-time preview
Obsidian
- Full support
- Uses MathJax
Jupyter Notebook
- Full support
- Native Markdown cells
VS Code
- Needs plugin support
- Recommend Markdown Preview Enhanced
LaTeX Syntax Basics
Superscripts and Subscripts
Effect:
Superscript: $x^2$, $x^n$ Subscript: $x_1$, $x_{ij}$ Combined: $x^{2n}$, $x_{i+j}$
Fractions
Effect:
Simple fraction: $\frac{a}{b}$ Nested fraction: $\frac{\frac{a}{b}}{c}$ Complex fraction: $\frac{a + b}{c - d}$
Roots
Effect:
Square root: $\sqrt{x}$ nth root: $\sqrt[n]{x}$ Complex expression: $\sqrt{a^2 + b^2}$
Summation and Integration
Effect:
Summation: $\sum_{i=1}^{n} x_i$ Integration: $\int_{a}^{b} f(x) dx$ Indefinite integral: $\int f(x) dx$
Limits
Effect:
Limit: $\lim_{x \to \infty} f(x)$ One-sided limit: $\lim_{x \to 0^+} f(x)$
Greek Letters
Lowercase Greek Letters
Effect:
$\alpha$ $\beta$ $\gamma$ $\delta$ $\epsilon$ $\zeta$ $\eta$ $\theta$ $\iota$ $\kappa$ $\lambda$ $\mu$ $\nu$ $\xi$ $\pi$ $\rho$ $\sigma$ $\tau$ $\upsilon$ $\phi$ $\chi$ $\psi$ $\omega$
Uppercase Greek Letters
Effect:
$\Gamma$ $\Delta$ $\Theta$ $\Lambda$ $\Sigma$ $\Phi$ $\Psi$ $\Omega$
Math Symbols
Relation Symbols
Effect:
Equals: $=$ Not equals: $\neq$ Less than: $<$ Greater than: $>$ Less than or equal: $\leq$ Greater than or equal: $\geq$ Approximately equal: $\approx$ Identically equal: $\equiv$
Operation Symbols
Effect:
Addition: $+$ Subtraction: $-$ Multiplication: $\times$ Division: $\div$ Dot product: $\cdot$ Cross product: $\times$ Plus minus: $\pm$
Set Symbols
Effect:
Element of: $\in$ Not element of: $\notin$ Subset: $\subset$ Proper subset: $\subsetneq$ Union: $\cup$ Intersection: $\cap$ Empty set: $\emptyset$ Universal quantifier: $\forall$
Logic Symbols
Effect:
Because: $\because$ Therefore: $\therefore$ And: $\land$ Or: $\lor$ Not: $\lnot$ Implies: $\implies$ If and only if: $\iff$
Arrow Symbols
Effect:
Right arrow: $\rightarrow$ Left arrow: $\leftarrow$ Left-right arrow: $\leftrightarrow$ Up arrow: $\uparrow$ Down arrow: $\downarrow$ Long right arrow: $\Longrightarrow$
Matrices
Basic Matrix
Effect:
$$ \begin{pmatrix} a & b \ c & d \end{pmatrix} $$
Bracketed Matrix
Effect:
$$ \begin{bmatrix} 1 & 2 \ 3 & 4 \end{bmatrix} $$
Braced Matrix
Effect:
$$ \begin{Bmatrix} a & b \ c & d \end{Bmatrix} $$
Determinant
Effect:
$$ \begin{vmatrix} a & b \ c & d \end{vmatrix} $$
3x3 Matrix
Effect:
$$ \begin{pmatrix} a_{11} & a_{12} & a_{13} \ a_{21} & a_{22} & a_{23} \ a_{31} & a_{32} & a_{33} \end{pmatrix} $$
Systems of Equations
Basic System
Effect:
$$ \begin{cases} 3x + 2y = 7 \ x - y = 1 \end{cases} $$
Aligned Equations
Effect:
$$ \begin{aligned} f(x) &= (x + a)(x - a) \ &= x^2 - a^2 \end{aligned} $$
Piecewise Functions
Basic Piecewise Function
Effect:
$$ f(x) = \begin{cases} x & \text{if } x \geq 0 \ -x & \text{if } x < 0 \end{cases} $$
Complex Piecewise Function
Effect:
$$ f(x) = \begin{cases} x^2 & x < 0 \ 2x & 0 \leq x < 1 \ 1 + x & x \geq 1 \end{cases} $$
Advanced Formulas
Differential Equations
Effect:
$$ \frac{dy}{dx} = 2x + 3 $$
Partial Derivatives
Effect:
$$ \frac{\partial f}{\partial x} = \frac{\partial}{\partial x}(x^2 + y^2) = 2x $$
Taylor Series
Effect:
$$ f(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}(x - a)^n $$
Euler's Formula
Effect:
$$ e^{i\pi} + 1 = 0 $$
Normal Distribution
Effect:
$$ f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}} $$
Fourier Transform
Effect:
$$ F(\omega) = \int_{-\infty}^{\infty} f(t) e^{-i\omega t} dt $$
Common Formula Examples
Pythagorean Theorem
Effect:
$$ a^2 + b^2 = c^2 $$
Quadratic Formula
Effect:
$$ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} $$
Logarithmic Formula
Effect:
$$ \log_a(x) = \frac{\ln x}{\ln a} $$
Probability Formula
Effect:
$$ P(A|B) = \frac{P(B|A)P(A)}{P(B)} $$
Formula Numbering
Basic Numbering
Effect:
$$ E = mc^2 \tag{1} $$
Reference Formulas
Formatting Tips
Spacing Adjustment
Effect:
Wide spacing: $a \quad b$ Narrow spacing: $a , b$ Negative spacing: $a ! b$
Text in Formulas
Effect:
Text in formula: $f(x) = x^2 \text{ if } x > 0$
Large Brackets
Effect:
Large brackets: $\left( \frac{a}{b} \right)$ Adapts to content size
Practical Examples
Physics Documentation
Math Tutorial
Statistics Documentation
Common Questions
Q: Formulas not displaying on GitHub?
A: GitHub natively doesn't support math formulas, you can:
- Use GitLab
- Use static site generators (like Jekyll + MathJax)
- Use third-party renderers
Q: How to quickly find LaTeX commands?
A:
- Use online tools: Detexify
- Check LaTeX reference manuals
- Use editor's auto-completion feature
Q: How to wrap long formulas?
A: Use \\ for line breaks:
Q: How to display large brackets?
A: Use \left\{ and \right\}:
Summary
This chapter detailed Markdown math formula writing methods:
- Basic syntax: Inline formulas
$and block formulas$$ - Basic elements: Fractions, roots, superscripts, subscripts
- Greek letters: Common Greek letter symbols
- Math symbols: Relations, operations, sets, logic symbols
- Advanced features: Matrices, equation systems, piecewise functions
- Common formulas: Physics, mathematics, statistics formulas
- Formatting tips: Spacing, text, brackets, etc.
Mastering LaTeX syntax for math formulas allows you to precisely express mathematical concepts in technical documentation.
Next: Learn Markdown Diagram Drawing methods.