Skip to content

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:

  1. Inline formulas: Formulas embedded in paragraphs
  2. Block formulas: Formulas displayed independently

Inline Formulas

Use single $ symbol to wrap:

markdown
Einstein's mass-energy equation is $E = mc^2$.

Effect:

Einstein's mass-energy equation is E=mc2 .

Block Formulas

Use double $ symbols to wrap:

markdown
$$
E = mc^2
$$

Effect:

E=mc2

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

markdown
Superscript: $x^2$, $x^n$
Subscript: $x_1$, $x_{ij}$
Combined: $x^{2n}$, $x_{i+j}$

Effect:

Superscript: x2 , xn Subscript: x1 , xij Combined: x2n , xi+j

Fractions

markdown
Simple fraction: $\frac{a}{b}$
Nested fraction: $\frac{\frac{a}{b}}{c}$
Complex fraction: $\frac{a + b}{c - d}$

Effect:

Simple fraction: ab Nested fraction: abc Complex fraction: a+bcd

Roots

markdown
Square root: $\sqrt{x}$
nth root: $\sqrt[n]{x}$
Complex expression: $\sqrt{a^2 + b^2}$

Effect:

Square root: x nth root: xn Complex expression: a2+b2

Summation and Integration

markdown
Summation: $\sum_{i=1}^{n} x_i$
Integration: $\int_{a}^{b} f(x) dx$
Indefinite integral: $\int f(x) dx$

Effect:

Summation: i=1nxi Integration: abf(x)dx Indefinite integral: f(x)dx

Limits

markdown
Limit: $\lim_{x \to \infty} f(x)$
One-sided limit: $\lim_{x \to 0^+} f(x)$

Effect:

Limit: limxf(x) One-sided limit: limx0+f(x)

Greek Letters

Lowercase Greek Letters

markdown
$\alpha$  $\beta$  $\gamma$  $\delta$  $\epsilon$  $\zeta$
$\eta$  $\theta$  $\iota$  $\kappa$  $\lambda$  $\mu$
$\nu$  $\xi$  $\pi$  $\rho$  $\sigma$  $\tau$
$\upsilon$  $\phi$  $\chi$  $\psi$  $\omega$

Effect:

αβγδϵζηθικλμνξπρστυϕχψω

Uppercase Greek Letters

markdown
$\Gamma$  $\Delta$  $\Theta$  $\Lambda$  $\Sigma$  $\Phi$  $\Psi$  $\Omega$

Effect:

ΓΔΘΛΣΦΨΩ

Math Symbols

Relation Symbols

markdown
Equals: $=$
Not equals: $\neq$
Less than: $<$
Greater than: $>$
Less than or equal: $\leq$
Greater than or equal: $\geq$
Approximately equal: $\approx$
Identically equal: $\equiv$

Effect:

Equals: = Not equals: Less than: < Greater than: > Less than or equal: Greater than or equal: Approximately equal: Identically equal:

Operation Symbols

markdown
Addition: $+$
Subtraction: $-$
Multiplication: $\times$
Division: $\div$
Dot product: $\cdot$
Cross product: $\times$
Plus minus: $\pm$

Effect:

Addition: + Subtraction: Multiplication: × Division: ÷ Dot product: Cross product: × Plus minus: ±

Set Symbols

markdown
Element of: $\in$
Not element of: $\notin$
Subset: $\subset$
Proper subset: $\subsetneq$
Union: $\cup$
Intersection: $\cap$
Empty set: $\emptyset$
Universal quantifier: $\forall$

Effect:

Element of: Not element of: Subset: Proper subset: Union: Intersection: Empty set: Universal quantifier:

Logic Symbols

markdown
Because: $\because$
Therefore: $\therefore$
And: $\land$
Or: $\lor$
Not: $\lnot$
Implies: $\implies$
If and only if: $\iff$

Effect:

Because: Therefore: And: Or: Not: ¬ Implies: If and only if:

Arrow Symbols

markdown
Right arrow: $\rightarrow$
Left arrow: $\leftarrow$
Left-right arrow: $\leftrightarrow$
Up arrow: $\uparrow$
Down arrow: $\downarrow$
Long right arrow: $\Longrightarrow$

Effect:

Right arrow: Left arrow: Left-right arrow: Up arrow: Down arrow: Long right arrow:

Matrices

Basic Matrix

markdown
$$
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
$$

Effect:

(abcd)

Bracketed Matrix

markdown
$$
\begin{bmatrix}
1 & 2 \\
3 & 4
\end{bmatrix}
$$

Effect:

[1234]

Braced Matrix

markdown
$$
\begin{Bmatrix}
a & b \\
c & d
\end{Bmatrix}
$$

Effect:

{abcd}

Determinant

markdown
$$
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix}
$$

Effect:

|abcd|

3x3 Matrix

markdown
$$
\begin{pmatrix}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33}
\end{pmatrix}
$$

Effect:

(a11a12a13a21a22a23a31a32a33)

Systems of Equations

Basic System

markdown
$$
\begin{cases}
3x + 2y = 7 \\
x - y = 1
\end{cases}
$$

Effect:

{3x+2y=7xy=1

Aligned Equations

markdown
$$
\begin{aligned}
f(x) &= (x + a)(x - a) \\
     &= x^2 - a^2
\end{aligned}
$$

Effect:

f(x)=(x+a)(xa)=x2a2

Piecewise Functions

Basic Piecewise Function

markdown
$$
f(x) =
\begin{cases}
x & \text{if } x \geq 0 \\
-x & \text{if } x < 0
\end{cases}
$$

Effect:

f(x)={xif x0xif x<0

Complex Piecewise Function

markdown
$$
f(x) =
\begin{cases}
x^2 & x < 0 \\
2x & 0 \leq x < 1 \\
1 + x & x \geq 1
\end{cases}
$$

Effect:

f(x)={x2x<02x0x<11+xx1

Advanced Formulas

Differential Equations

markdown
$$
\frac{dy}{dx} = 2x + 3
$$

Effect:

dydx=2x+3

Partial Derivatives

markdown
$$
\frac{\partial f}{\partial x} = \frac{\partial}{\partial x}(x^2 + y^2) = 2x
$$

Effect:

fx=x(x2+y2)=2x

Taylor Series

markdown
$$
f(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}(x - a)^n
$$

Effect:

f(x)=n=0f(n)(a)n!(xa)n

Euler's Formula

markdown
$$
e^{i\pi} + 1 = 0
$$

Effect:

eiπ+1=0

Normal Distribution

markdown
$$
f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}
$$

Effect:

f(x)=1σ2πe(xμ)22σ2

Fourier Transform

markdown
$$
F(\omega) = \int_{-\infty}^{\infty} f(t) e^{-i\omega t} dt
$$

Effect:

F(ω)=f(t)eiωtdt

Common Formula Examples

Pythagorean Theorem

markdown
$$
a^2 + b^2 = c^2
$$

Effect:

a2+b2=c2

Quadratic Formula

markdown
$$
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$

Effect:

x=b±b24ac2a

Logarithmic Formula

markdown
$$
\log_a(x) = \frac{\ln x}{\ln a}
$$

Effect:

loga(x)=lnxlna

Probability Formula

markdown
$$
P(A|B) = \frac{P(B|A)P(A)}{P(B)}
$$

Effect:

P(A|B)=P(B|A)P(A)P(B)

Formula Numbering

Basic Numbering

markdown
$$
E = mc^2 \tag{1}
$$

Effect:

(1)E=mc2

Reference Formulas

markdown
According to formula (1), we can draw conclusions.

Formatting Tips

Spacing Adjustment

markdown
Wide spacing: $a \quad b$
Narrow spacing: $a \, b$
Negative spacing: $a \! b$

Effect:

Wide spacing: ab Narrow spacing: ab Negative spacing: ab

Text in Formulas

markdown
Text in formula: $f(x) = x^2 \text{ if } x > 0$

Effect:

Text in formula: f(x)=x2 if x>0

Large Brackets

markdown
Large brackets: $\left( \frac{a}{b} \right)$
Adapts to content size

Effect:

Large brackets: (ab) Adapts to content size

Practical Examples

Physics Documentation

markdown
# Classical Mechanics

## Newton's Second Law

$$
F = ma
$$

## Energy Conservation

$$
E = K + U = \frac{1}{2}mv^2 + mgh
$$

## Circular Motion

$$
F_c = \frac{mv^2}{r} = m\omega^2r
$$

Math Tutorial

markdown
# Calculus Basics

## Derivative Definition

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

## Integration Calculation

$$
\int x^n dx = \frac{x^{n+1}}{n+1} + C
$$

## Definite Integral

$$
\int_{0}^{\pi} \sin x dx = 2
$$

Statistics Documentation

markdown
# Statistics Basics

## Expected Value

$$
E[X] = \sum_{i=1}^{n} x_i P(x_i)
$$

## Variance

$$
Var(X) = E[(X - \mu)^2] = E[X^2] - (E[X])^2
$$

## Standard Deviation

$$
\sigma = \sqrt{Var(X)}
$$

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:

markdown
$$
f(x) = x^2 + 2x + 1 \\
     = (x + 1)^2
$$

Q: How to display large brackets?

A: Use \left\{ and \right\}:

markdown
$$
f(x) = \left\{
\begin{array}{ll}
x^2 & x \geq 0 \\
-x^2 & x < 0
\end{array}
\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.

Content is for learning and research only.