LaTeX Math Formulas: A Detailed Guide

LaTeX is the standard for typesetting mathematical formulas. You can use it in many environments, including Markdown, Jupyter Notebooks, Overleaf, and more.

1. Math Modes

Display Math: Use double dollar signs or \[ ... \]:

$$E = mc^2$$

or

\[ E = mc^2 \]

Renders as:
\[ E = mc^2 \]

Inline Math: Use single dollar signs:

$E = mc^2$

Renders as: \(E = mc^2\)


2. Basic Symbols

Symbol LaTeX Code Renders as
Greek letter alpha \alpha \(\alpha\)
Plus-minus \pm \(\pm\)
Multiplication \times \(\times\)
Division \div \(\div\)
Infinity \infty \(\infty\)
Partial derivative \partial \(\partial\)

3. Superscripts and Subscripts

  • Superscript: a^2 → \(a^2\)
  • Subscript: a_1 → \(a_1\)
  • Combined: x_i^2 → \(x_i^2\)
  • Grouping: Use curly braces for more than one character:
    x^{10} → \(x^{10}\)

4. Fractions, Roots, and Sums

  • Fraction: \frac{a}{b} → \(\frac{a}{b}\)
  • Square root: \sqrt{x} → \(\sqrt{x}\)
  • n-th root: \sqrt[n]{x} → \(\sqrt[n]{x}\)
  • Sum: \sum_{i=1}^n i → \(\sum_{i=1}^n i\)
  • Product: \prod_{i=1}^n i → \(\prod_{i=1}^n i\)
  • Integral: \int_0^1 x\,dx → \(\int_0^1 x,dx\)

5. Common Functions

  • Trigonometric: \sin, \cos, \tan
    Example: \sin^2 \theta + \cos^2 \theta = 1 → \(\sin^2 \theta + \cos^2 \theta = 1\)
  • Logarithms: \log, \ln, \exp
    Example: \ln(e^x) = x → \(\ln(e^x) = x\)

6. Brackets and Parentheses

  • Normal size: (a+b) → \((a+b)\)
  • Auto-sized: \left( a+b \right) → \(\left( a+b \right)\)
  • Other brackets:
    • \left[ ... \right] → \(\left[ ... \right]\)
    • \left\{ ... \right\} → \(\left\{ ... \right\}\)
    • \left| ... \right| → \(\left| ... \right|\)

7. Matrices

\begin{bmatrix}
a & b \\
c & d
\end{bmatrix}

Renders as:
\[ \begin{bmatrix} a & b \\ c & d \end{bmatrix} \]

Other environments: pmatrix (parentheses), vmatrix (vertical bars).


8. Special Symbols

Symbol Code Renders as
Less or equal \leq \(\leq\)
Greater or equal \geq \(\geq\)
Not equal \neq \(\neq\)
Approximately \approx \(\approx\)
Element of \in \(\in\)
Subset \subset \(\subset\)

9. Text in Math

To insert text in math mode:

\text{some text}

Example:
\text{if } x > 0 → \(\text{if } x > 0\)


10. Example: Quadratic Formula

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

Renders as:
\[ x = \frac{ -b \pm \sqrt{b^2 - 4ac} }{ 2a } \]


11. Resources


Note: In Markdown, LaTeX math is rendered only if the platform supports it.