Chapter 1 · LaTeX

Everything below is a live playground — edit the left side, the math re-renders instantly. You cannot break anything; errors show in red and vanish when fixed. Ten topics, from first symbol to publication-grade formulas — roughly 4 hours, best split over several days (the streak system will thank you).
🎯 New: each topic ends with a “write this in LaTeX” challenge — we show the math, you reproduce it, the page tells you instantly when your version matches.

Topics 1 Mental model2 Symbols 3 Real formulas4 Brackets & multi-line 5 Matrices6 Documents 7 Decorations8 Calculus 9 Fine-tuning10 Grand formulas ✅ Self-exam
🧠 Before you start (30 seconds)Try to answer these from intuition — being wrong is fine, guessing first is proven to make the real answers stick better:
How do you think LaTeX makes a fraction?
You guessed something like frac? It's \frac{a}{b} — command, then two brace arguments. Details in Topic 1.
What might the symbol for 'infinity' be called?
\infty — most symbols are just their English name with a backslash. Topic 2 has the greatest hits.
Guess: how would LaTeX tell a fraction's top from its bottom?
Braces: first {top} then {bottom}. Order and braces are the whole grammar — Topic 3.

1What LaTeX is (and the 60-second mental model)

LaTeX is not a text editor — it's a language: you type plain text with commands like \frac{a}{b}, and a program turns it into perfectly typeset output. Every command starts with a backslash \, arguments go in braces { }. That's 90% of the mental model.

EASYYour first formula — edit it!

This playground renders as you type. Change the 2 to a 3. Break it. Fix it.

💡 ^ makes a superscript (exponent). _ makes a subscript.

EASYSubscripts and superscripts

💡 Braces group things: try x_{10} vs x_10 to see why braces matter.

LEVEL UPCommands take arguments in braces

💡 \frac{top}{bottom} takes TWO arguments. \sqrt takes an optional [n] for nth roots.

LEVEL UPNesting: commands inside commands

💡 Any argument can itself contain commands — that's how complex formulas are built.

🎯 Can you write this? (superscripts + subscripts)
a_n = a_1 r^{n-1}

2Greek letters & the symbols mathematicians actually use

Every Greek letter is a command: \alpha → α. Capitalize the command for capitals: \Delta → Δ. You'll memorize the ~15 you use, and look up the rest.

EASYThe greatest hits

💡 Try \Omega, \phi, \varphi, \epsilon, \varepsilon.

EASYComparison & arrows

💡 \le ≤, \ge ≥, \ne ≠, \approx ≈, \to →, \Rightarrow ⇒, \infty ∞.

LEVEL UPSets and logic

💡 \mathbb{R} = blackboard bold. \in / \notin = set membership. \; adds a little space.

LEVEL UPOperators that size themselves

💡 On \sum and \prod, _ and ^ become the lower/upper limits automatically.

🎯 Your turn — an infinite sum with Greek letters:
\sum_{k=1}^{\infty} \frac{\lambda^k}{k!} = e^{\lambda} - 1

3Fractions, roots, integrals, limits — building real formulas

Real formulas are just the pieces you've seen, combined. The skill is reading a formula outside-in: find the outermost structure first, then fill the slots.

EASYThe quadratic formula, step by step

Outer structure: a fraction. Top slot: -b \pm \sqrt{...}. Bottom slot: 2a.

💡 \pm gives the ± sign.

EASYA definite integral

💡 \int works like \sum: _ lower limit, ^ upper limit. \, is a thin space before dx.

LEVEL UPLimits and derivatives

💡 \lim_{...} puts its argument underneath in display mode.

LEVEL UPPutting it all together

💡 Read it outside-in: an integral, with limits, of a product of two powers.

🎯 Write this Gaussian integral:
\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}

4Brackets that grow & multi-line math

Plain parentheses stay small around tall content — ugly. \left( and \right) grow to fit. For multi-line derivations, aligned lines up the = signs: & marks the alignment column, \\ ends a line.

EASYSmall vs growing brackets

💡 Every \left needs a matching \right. Use \left. or \right. for an invisible side.

EASYAll the bracket families

💡 Braces must be escaped: \{ \}. Try \left\langle ... \right\rangle too.

LEVEL UPA two-line derivation with aligned

💡 & marks where lines align (before the =). \\ starts a new line.

LEVEL UPCases (piecewise functions)

💡 \text{...} switches to normal words inside math mode.

🎯 Recreate this piecewise definition:
f(x) = \begin{cases} x^2 & x \ge 0 \\ -x & x < 0 \end{cases}

5Matrices & vectors

Matrices are grids: & separates columns, \\ separates rows. The environment name picks the brackets: pmatrix ( ), bmatrix [ ], vmatrix | |.

EASYA 2×2 matrix

💡 Change pmatrix to bmatrix or vmatrix and watch the brackets change.

EASYColumn vectors

💡 \vec{v} draws the arrow. One column = no & needed, just \\\\ between rows.

LEVEL UPMatrix × vector

💡 This is the 2D rotation matrix — you'll animate exactly this in the Manim chapter.

LEVEL UPA determinant with dots

💡 \cdots horizontal, \vdots vertical, \ddots diagonal dots.

🎯 Build this matrix equation:
\begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}^n = \begin{bmatrix} 1 & n \\ 0 & 1 \end{bmatrix}

6Complete documents (the part Manim does for you)

Everything so far was math mode — which is all Manim needs. But a standalone LaTeX document wraps that math in a small skeleton. Learn the skeleton once, mostly so error messages make sense.

EASYThe minimal document

This is a full compilable .tex file (paste into any LaTeX editor — this one isn't live because it's a document, not a formula):

\documentclass{article}
\begin{document}
Hello, \LaTeX!  Inline math: $E = mc^2$.
\end{document}
EASYInline vs display math
Euler proved that $e^{i\pi} + 1 = 0$   % inline: flows with text
\[ e^{i\pi} + 1 = 0 \]                  % display: own centered line

Same formula, two contexts. In Manim you'll only ever write the math part.

LEVEL UPSections, packages, labels
\documentclass{article}
\usepackage{amsmath}          % better math environments
\begin{document}
\section{The identity}
As shown in equation~\eqref{eq:euler}:
\begin{equation}\label{eq:euler}
  e^{i\pi} + 1 = 0
\end{equation}
\end{document}
LEVEL UPHow Manim uses this
# Manim writes the document FOR you. When you type:
MathTex(r"e^{i\pi} + 1 = 0")
# ...Manim generates a tiny document around your math,
# compiles it, and turns the result into animatable shapes.
# The r"" (raw string) stops Python from eating your backslashes!

This is why the math-mode skills above transfer 1:1 to Manim.

🎯 Final boss — everything at once:
\left( \sum_{i=1}^{n} x_i^2 \right)^{1/2} \le \sum_{i=1}^{n} |x_i|

7Decorations: vectors, hats, braces that explain

Real math is annotated math: arrows over vectors, hats on estimates, braces that point at part of a formula and name it. These commands wrap around anything.

EASYAccents on single letters

💡 \dot / \ddot are time-derivatives in physics. \hat is 'estimate' in statistics.

EASYWide versions stretch over groups

💡 \overline stretches; \bar does not. Same idea: \widehat vs \hat.

LEVEL UPBraces that label parts of a formula

💡 _ after \underbrace puts the label BELOW; ^ after \overbrace puts it ABOVE.

LEVEL UPBoxing the result

💡 \boxed{...} draws a frame — perfect for final answers on slides.

🎯 Label this sum with an underbrace:
\underbrace{\frac{1}{2} + \frac{1}{4} + \frac{1}{8} + \cdots}_{= 1}

8Calculus notation: derivatives, partials, big integrals

The notation of calculus is its own dialect: primes, Leibniz fractions, curly partials, double integrals, closed-loop integrals, and evaluation bars.

EASYThree ways to write a derivative

💡 ' is just an apostrophe. The Leibniz form is an ordinary \frac.

EASYPartial derivatives and the gradient

💡 \partial is the curly d. \nabla is the gradient triangle.

LEVEL UPBigger integrals

💡 \iint double, \iiint triple, \oint closed loop. \, adds the thin space before dx.

LEVEL UPEvaluation bars and limits underneath

💡 \left. is an invisible left wall so \right| can grow. \lim takes limits with _.

🎯 Write the heat equation:
\frac{\partial u}{\partial t} = \alpha \, \frac{\partial^2 u}{\partial x^2}

9Fine-tuning: spacing, color, size — typesetting like a pro

The difference between 'renders' and 'beautiful' is spacing and emphasis. These are the knobs professionals turn — and in Manim they work exactly the same inside MathTex.

EASYThe spacing ladder

💡 From squeeze to gap: \! negative, \, thin, \; medium, \quad wide, \qquad double.

EASYWords and proper operator names

💡 \operatorname gives upright type + correct spacing — sin/cos/log already exist: \sin \log.

LEVEL UPColor for emphasis (works in KaTeX and Manim)

💡 \textcolor{name}{...}. In Manim you'd more often use set_color_by_tex.

LEVEL UPForcing display style in tight places

💡 \displaystyle makes things full-size; \textstyle compact. Useful inside fractions and tables.

🎯 Highlight the discriminant in orange:
x = \frac{-b \pm \sqrt{\textcolor{orange}{b^2-4ac}}}{2a}

10Grand formulas: multi-line proofs & famous equations

Everything combines here. If you can typeset these, you can typeset anything you will ever put on a slide — this is the level of a published paper.

EASYA real chained derivation

💡 Three lines, one story. & always sits before the =.

LEVEL UPStacked conditions under a sum

💡 \substack stacks multiple lines under one \sum. \lceil\rceil are ceiling brackets.

LEVEL UPThe Fourier series — a formula with everything

💡 Fractions, subscripts, an infinite sum, growing brackets, operators — all four chapters of skills.

LEVEL UPMaxwell (integral form) — the boss fight

💡 Closed-loop integral, vectors, Leibniz derivative, double integral. You know every piece now.

🎯 The final exam — Euler's identity, derived:
e^{i\pi} + 1 = 0 \quad \text{because} \quad e^{i\theta} = \cos\theta + i\sin\theta

Self-examination

No peeking at the topics above — that's the exam part. Solutions are one click away.

Which of these renders a fraction one-half?
What does the & symbol do inside an aligned or matrix environment?
Why must Python strings for Manim's MathTex be written as r\"...\"?
Write the LaTeX for: the sum from k = 0 to n of (n choose k) x^k = (1+x)^n. (Binomial coefficient is \binom{n}{k}.) Try it in any playground above first!
show solution
\sum_{k=0}^{n} \binom{n}{k} x^k = (1+x)^n
Typeset a 3×3 identity matrix with square brackets.
show solution
I = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}
Typeset the piecewise sign function: sgn(x) = -1 if x < 0, 0 if x = 0, 1 if x > 0.
show solution
\operatorname{sgn}(x) = \begin{cases} -1 & x < 0 \\ 0 & x = 0 \\ 1 & x > 0 \end{cases}
← PreviousSetup Next chapter →2 · Manim