Write inline and display math in LaTeX with amsmath: fractions, sums, integrals, aligned equations, matrices, cases, theorem environments, and numbered equations you can reference.
Mathematics
Mathematics is where LaTeX shines. Everything between math delimiters is typeset in "math mode", with its own fonts, spacing, and commands. Load amsmath (and usually amssymb) in the preamble; every example below assumes you have:
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm} % for theorem environments
In the Coauthor editor, typing $ inserts a matching $ and places the cursor between them, and the autocomplete popup knows \frac, \sum, \int, \sqrt, Greek letters, and common symbols. Compile with Ctrl+S to check the result.
Inline Math
Wrap short expressions in $...$ (or the equivalent \(...\)) so they flow with the text:
Let $x \in \mathbb{R}^n$ and $f(x) = \alpha x^2 + \beta x + \gamma$.
The error is $O(n \log n)$.
Display Math
Use equation for a numbered one-line formula and equation* (or \[ ... \]) for an unnumbered one. Avoid $$ ... $$; it is a plain TeX construct with inconsistent spacing.
\begin{equation}
\hat{\theta} = \arg\min_{\theta} \sum_{i=1}^{n} \bigl(y_i - f_\theta(x_i)\bigr)^2
\label{eq:objective}
\end{equation}
\[ \int_0^\infty e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2} \]
Building Blocks
| What | Code | Notes |
|---|---|---|
| Fraction | \frac{a}{b} | \dfrac forces display size inline |
| Subscript, superscript | x_i, x^2, x_{ij}^{(k)} | Braces around anything longer than one character |
| Root | \sqrt{x}, \sqrt[3]{x} | |
| Sum, product, integral | \sum_{i=1}^{n}, \prod_i, \int_a^b | Limits go above and below in display math |
| Limit | \lim_{n \to \infty} | |
| Greek | \alpha, \beta, \Gamma, \epsilon, \varepsilon | |
| Sets and logic | \in, \subseteq, \cup, \cap, \forall, \exists, \emptyset | |
| Relations | \leq, \geq, \neq, \approx, \sim, \propto | |
| Arrows | \to, \rightarrow, \Rightarrow, \mapsto | |
| Dots | \ldots, \cdots, \vdots, \ddots | |
| Fonts | \mathbb{R}, \mathcal{L}, \mathbf{x}, \mathrm{d} | \mathbb needs amssymb |
| Text in math | \text{if } x > 0 | From amsmath; keeps normal spacing |
| Brackets that grow | \left( \frac{a}{b} \right), \bigl[ \bigr] | Every \left needs a \right |
| Operators | \sin, \log, \exp, \max, \operatorname{softmax} | Upright, correctly spaced |
Several Lines: align
align numbers every line and lines up at each &. Use \\ to end a line and \nonumber or align* to drop numbers.
\begin{align}
L(\theta) &= \sum_{i} \log p_\theta(y_i \mid x_i) \label{eq:loglik} \\
&= \sum_{i} \bigl( y_i \log \sigma(z_i) + (1-y_i)\log(1-\sigma(z_i)) \bigr) \nonumber
\end{align}
Related: gather (centered lines, no alignment), multline (one long equation split over lines), split (one number for several aligned lines, inside equation).
Matrices and Cases
\begin{equation}
A = \begin{pmatrix} a & b \\ c & d \end{pmatrix}, \qquad
|x| = \begin{cases}
x & \text{if } x \geq 0 \\
-x & \text{otherwise}
\end{cases}
\end{equation}
pmatrix uses parentheses, bmatrix brackets, vmatrix vertical bars, and matrix none. Columns are separated by &, rows by \\.
Theorems and Proofs
\newtheorem{theorem}{Theorem}[section] % preamble
\newtheorem{lemma}[theorem]{Lemma}
\begin{theorem}\label{thm:main} % body
For all $n \geq 1$, $\sum_{k=1}^{n} k = \frac{n(n+1)}{2}$.
\end{theorem}
\begin{proof} By induction on $n$. \end{proof}
Many venue templates define theorem, lemma, and friends already; check the template's .sty or example file before adding your own to avoid Command \theorem already defined.
Referencing Equations
Label inside the environment and use \eqref for the parenthesized number:
Substituting into \eqref{eq:objective} gives the estimator in \eqref{eq:loglik}.
See Cross-References and Labels for why references show as ?? until the next compile.
Common Math Errors
- Missing $ inserted — a math-only command (
\alpha,_,^,\frac) outside math mode, or a missing closing$. - Extra }, or forgotten $ — brace and dollar mismatch; count them on the reported line.
- Missing \right. inserted — a
\left(without a matching\right). Use\right.for an invisible closer. - Display math should end with $$ — usually a blank line inside a display environment; remove it.
The Compilation Results panel shows the line; see Fixing Common LaTeX Errors. If you know what an expression should say but not how to write it, describe it to the AI coauthor ("the softmax over the logits z with temperature tau") and ask for the LaTeX.
Related articles
Prefer to ask?
Inside Coauthor, ask the AI coauthor how any feature works — it answers from these same help articles. For anything else, use the ? button in the top-right corner of the app.