2024-7-5

Latex in This Blog’s Markdown

A guide to using Latex in this blog’s markdown

Table of Contents

Basic Latex Usage

  1. Simple Inline Equations:
    markdown
    Here are some inline equations:
    - Area of a circle: $A = \pi r^2$
    - Quadratic formula: $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$
    - Einstein's famous equation: $E = mc^2$
    Output:Here are some inline equations:
    • Area of a circle: A=πr2A = \pi r^2
    • Quadratic formula: x=b±b24ac2ax = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
    • Einstein's famous equation: E=mc2E = mc^2
  2. Basic Block Equations:
    markdown
    The Gaussian integral:
    $$
    \int_{-\infty}^\infty e^{-x^2} dx = \sqrt{\pi}
    $$
    Output:The Gaussian integral:ex2dx=π\int_{-\infty}^\infty e^{-x^2} dx = \sqrt{\pi}

Advanced Mathematical Expressions

  1. Matrix Operations:
    markdown
    $$
    \begin{pmatrix}
        a & b \\
        c & d
    \end{pmatrix}
    \begin{pmatrix}
        x \\
        y
    \end{pmatrix} =
    \begin{pmatrix}
        ax + by \\
        cx + dy
    \end{pmatrix}
    $$
    Output:(abcd)(xy)=(ax+bycx+dy)\begin{pmatrix} a & b \\ c & d \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} ax + by \\ cx + dy \end{pmatrix}
  2. Multi-line Equations with Alignment:
    markdown
    $$
    \begin{align}
        (x + y)^3 &= (x + y)(x + y)^2 \\
        &= (x + y)(x^2 + 2xy + y^2) \\
        &= x^3 + 3x^2y + 3xy^2 + y^3
    \end{align}
    $$
    Output:(x+y)3=(x+y)(x+y)2=(x+y)(x2+2xy+y2)=x3+3x2y+3xy2+y3\begin{align} (x + y)^3 &= (x + y)(x + y)^2 \\ &= (x + y)(x^2 + 2xy + y^2) \\ &= x^3 + 3x^2y + 3xy^2 + y^3 \end{align}

Other examples

markdown
$$
    A \cap (B \cup C) = (A \cap B) \cup (A \cap C)
$$
Output:A(BC)=(AB)(AC) A \cap (B \cup C) = (A \cap B) \cup (A \cap C)
markdown
$$
    \forall x \in \mathbb{R}, \exists y : y > x
$$
Output:xR,y:x<y \forall x \in \mathbb{R}, \exists y : x < y
markdown
$$
    P(A|B) = \frac{P(B|A)P(A)}{P(B)}
$$
Output:P(AB)=P(BA)P(A)P(B) P(A|B) = \frac{P(B|A)P(A)}{P(B)}
markdown
$$
    \frac{d}{dx}\left[\int_a^x f(t)dt\right] = f(x)
$$
Output:ddx[axf(t)dt]=f(x) \frac{d}{dx}\left[\int_a^x f(t)dt\right] = f(x)
markdown
$$
    \sum_{n=0}^{\infty} x^n = \frac{1}{1-x}, |x| < 1
$$
Output:n=0xn=11x,x<1 \sum_{n=0}^{\infty} x^n = \frac{1}{1-x}, |x| < 1
markdown
$$
    \lim_{x \to 0} \frac{\sin x}{x} = 1
$$
Output:limx0sinxx=1 \lim_{x \to 0} \frac{\sin x}{x} = 1
markdown
The most beautiful equation in mathematics:
$$
    e^{i\pi} + 1 = 0
$$
Output:The most beautiful equation in mathematics:eiπ+1=0 e^{i\pi} + 1 = 0
markdown
$$
    \zeta(s) = \sum_{n=1}^{\infty} \frac{1}{n^s} \quad \text{(Riemann zeta function)}
$$
Output:ζ(s)=n=11ns(Riemann zeta function) \zeta(s) = \sum_{n=1}^{\infty} \frac{1}{n^s} \quad \text{(Riemann zeta function)}
markdown
$$
    \Gamma(z) = \int_0^{\infty} t^{z-1}e^{-t}dt \quad \text{(Gamma function)}
$$
Output:Γ(z)=0tz1etdt(Gamma function) \Gamma(z) = \int_0^{\infty} t^{z-1}e^{-t}dt \quad \text{(Gamma function)}
markdown
$$
    \vartheta(z) = \sum_{n=-\infty}^{\infty} e^{-\pi n^2 z} \quad \text{(Theta function)}
$$
Output:ϑ(z)=n=eπn2z(Theta function) \vartheta(z) = \sum_{n=-\infty}^{\infty} e^{-\pi n^2 z} \quad \text{(Theta function)}
Spacing in LaTeX
FeatureNotationOutput
Negative space$a \! b$a ⁣ba\!b
Small space$a \, b$aba\,b
Medium space$a \; b$a  ba\;b
Large space$a \quad b$aba\quad b
Extra large space$a \qquad b$aba\qquad b