LatexNotes
All posts

LaTeX guides

Maths to LaTeX: How to Convert Any Maths, With 150+ Examples

How to turn maths into LaTeX: write it yourself or convert handwriting, photos, PDFs, Word and AI output, with 150+ maths to LaTeX examples to copy.

Convert handwritten maths to LaTeX →

Upload a photo or PDF of your notes and get a full LaTeX document back. For one equation, Text to LaTeX is free with no sign-up.

This is the quadratic formula in LaTeX:

LaTeX
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
x=−b±b2−4ac2ax = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

Read it left to right and nearly every piece is a word. \frac takes a top and a bottom, each in braces. \pm is plus or minus. \sqrt puts a root over whatever is in its braces, and ^2 raises the 2. Converting maths to LaTeX is mostly that: a few dozen commands you use all the time, a handful of rules about braces and spacing, and a long tail of symbols you look up when you need them.

Below are the rules, more than 150 examples to copy, and the small details that decide whether your maths looks like a textbook or like a first attempt. After that come the routes for maths that starts somewhere other than your keyboard: handwritten notes, photos, PDFs, Word, maths software and AI chat.

Where is your maths now?

Your maths isThe quickest way to LaTeX
In your head, or on the page in front of youType it, using the examples below
One symbol you cannot nameDraw it in a symbol finder
Handwritten, on paper or a tabletA handwriting to LaTeX converter
A photo or a screenshotA maths OCR tool
In a PDFThe original source if it exists, otherwise OCR
A Word or Google Docs equationWord's LaTeX mode, or pandoc for a whole file
In Mathematica, Maple, MATLAB or PythonThe software's own LaTeX export
A ChatGPT answerCopy the code, then check it against the rendered maths

How LaTeX writes maths

LaTeX does not read maths from a picture. You describe it in plain text and LaTeX does the layout. Six rules get you a long way.

  1. Maths goes in maths mode. In a sentence, that means single dollar signs: $x^2 + 1$ gives x2+1x^2 + 1. An equation on its own line goes in \[ ... \]. Outside maths mode, x^2 is an error, and LaTeX tells you so with "Missing $ inserted" (how to read that).
  2. ^ and _ apply to one character. Anything longer needs braces: x^{10} gives x10x^{10}, while x^10 gives x10x^10, and compiles without a word of complaint.
  3. Commands start with a backslash: \alpha, \times, \infty, \sin. Forgetting the backslash on a function name is the most common mistake in student LaTeX, because sin x is set as the variables ss, ii and nn multiplied by xx.
  4. Braces group things and do not print. \frac{a+b}{2} and \sqrt{x+1} use them to say what belongs together. To print a brace, write \{ or \}.
  5. Spaces you type in maths are ignored. LaTeX spaces maths by what each symbol is, so a relation like == gets more room than an operator like ++, and a=b comes out the same as a = b. To add space yourself, use \, for a thin gap or \quad for a wide one. The spacing guide has the full set.
  6. Words go in \text{}. \text{if } x > 0 keeps the word upright with its space. Without it, LaTeX reads "if" as ii times ff.

Here is a sentence of maths written with those rules, "the derivative of x squared sin x is 2x sin x plus x squared cos x":

LaTeX
\[ \frac{d}{dx}(x^2 \sin x) = 2x \sin x + x^2 \cos x \]
ddx(x2sin⁡x)=2xsin⁡x+x2cos⁡x\frac{d}{dx}(x^2 \sin x) = 2x \sin x + x^2 \cos x

Nearly everything on this page works in a bare LaTeX document. A few commands come from packages: amsmath gives you align, cases, the matrix environments, \text and \binom; amssymb gives you \mathbb and \varnothing; mathtools gives you \coloneqq. The document at the end loads all three.

Maths to LaTeX: examples to copy

The left column is the maths as it looks on a line of its own, the right column is what to type. Put the code inside $...$ in a sentence or \[ ... \] on its own line.

Fractions, powers and roots

MathsLaTeX
ab\displaystyle \frac{a}{b}\frac{a}{b}
12\tfrac{1}{2}\tfrac{1}{2}, a small fraction for a line of text
12\dfrac{1}{2}\dfrac{1}{2}, full size even in a line of text (it pushes the lines apart, see below)
11+1x\displaystyle \frac{1}{1 + \frac{1}{x}}\frac{1}{1 + \frac{1}{x}}
11+11+x\displaystyle \cfrac{1}{1 + \cfrac{1}{1 + x}}\cfrac{1}{1 + \cfrac{1}{1 + x}}, a continued fraction that stays full size as it nests
x2x^2x^2
xn+1x^{n+1}x^{n+1}
x1x_1x_1
xijx_{ij}x_{ij}
x12x_1^2x_1^2
e−x2e^{-x^2}e^{-x^2}
x−1/2x^{-1/2}x^{-1/2}
10−310^{-3}10^{-3}
x\sqrt{x}\sqrt{x}
x3\sqrt[3]{x}\sqrt[3]{x}
b2−4ac\sqrt{b^2 - 4ac}\sqrt{b^2 - 4ac}

More in the guides to fractions and square roots.

Greek letters

MathsLaTeX
α\alpha\alpha
β\beta\beta
γ\gamma, Γ\Gamma\gamma, \Gamma
δ\delta, Δ\Delta\delta, \Delta
ε\varepsilon, ϵ\epsilon\varepsilon, \epsilon (the first is the one most people write by hand)
θ\theta, ϑ\vartheta, Θ\Theta\theta, \vartheta, \Theta
λ\lambda, Λ\Lambda\lambda, \Lambda
μ\mu\mu
ν\nu\nu
π\pi, Π\Pi\pi, \Pi
ρ\rho\rho
σ\sigma, Σ\Sigma\sigma, \Sigma
τ\tau\tau
φ\varphi, ϕ\phi, Φ\Phi\varphi, \phi, \Phi (again, the first is the handwritten shape)
χ\chi\chi
ψ\psi, Ψ\Psi\psi, \Psi
ω\omega, Ω\Omega\omega, \Omega

Capital Greek letters that look like Latin ones have no command: a capital alpha is just A, a capital rho is P. There is no \omicron either; it is an o. The whole alphabet is in the Greek letters guide.

Operators and relations

MathsLaTeX
a×ba \times ba \times b
a⋅ba \cdot ba \cdot b
a÷ba \div ba \div b
±\pm, ∓\mp\pm, \mp
a≠ba \neq ba \neq b
a≤ba \leq b, a≥ba \geq ba \leq b, a \geq b
a≈ba \approx ba \approx b
a≡b(modn)a \equiv b \pmod{n}a \equiv b \pmod{n}
y∝xy \propto xy \propto x
a∼ba \sim ba \sim b
a≪ba \ll b, a≫ba \gg ba \ll b, a \gg b
x→∞x \to \inftyx \to \infty
x↦x2x \mapsto x^2x \mapsto x^2
f∘gf \circ gf \circ g
a≔ba \coloneqq ba \coloneqq b, "is defined as" (needs mathtools)

See the times, plus or minus, less than or equal to and proportional to guides.

Brackets and bars

MathsLaTeX
(ab)2\displaystyle \left( \frac{a}{b} \right)^2\left( \frac{a}{b} \right)^2
(a+b)\bigl( a + b \bigr)\bigl( a + b \bigr), a fixed size up from normal
{1,2,3}\{ 1, 2, 3 \}\{ 1, 2, 3 \}
∣x∣\lvert x \rvert\lvert x \rvert
∥v∥\lVert \mathbf{v} \rVert\lVert \mathbf{v} \rVert
⌊x⌋\lfloor x \rfloor, ⌈x⌉\lceil x \rceil\lfloor x \rfloor, \lceil x \rceil
⟨u,v⟩\langle u, v \rangle\langle u, v \rangle
dydx∣x=0\displaystyle \left. \frac{dy}{dx} \right\rvert_{x=0}\left. \frac{dy}{dx} \right\rvert_{x=0}, evaluated at a point

\left. is an invisible bracket, there because every \left needs a partner. More in the guides to brackets and absolute values.

Functions, logs and trigonometry

MathsLaTeX
sin⁡x\sin x, cos⁡x\cos x, tan⁡x\tan x\sin x, \cos x, \tan x
sec⁡x\sec x, csc⁡x\csc x, cot⁡x\cot x\sec x, \csc x, \cot x
cos⁡2θ\cos^2 \theta\cos^2 \theta
tan⁡−1x\tan^{-1} x\tan^{-1} x
arcsin⁡x\arcsin x\arcsin x
sinh⁡x\sinh x\sinh x
ln⁡x\ln x\ln x
log⁡10n\log_{10} n\log_{10} n
exp⁡(x)\exp(x)\exp(x)
gcd⁡(a,b)\gcd(a, b)\gcd(a, b)
f ⁣:A→Bf\colon A \to Bf\colon A \to B
max⁡x∈Sf(x)\displaystyle \max_{x \in S} f(x)\max_{x \in S} f(x)
sgn⁡(x)\operatorname{sgn}(x)\operatorname{sgn}(x)
arg max⁡xf(x)\displaystyle \operatorname*{arg\,max}_{x} f(x)\operatorname*{arg\,max}_{x} f(x)

\operatorname{} sets any name upright like the built-in functions, and the starred form puts limits underneath in display maths. See the trigonometric functions and logarithms guides.

Calculus

MathsLaTeX
lim⁡x→0sin⁡xx=1\displaystyle \lim_{x \to 0} \frac{\sin x}{x} = 1\lim_{x \to 0} \frac{\sin x}{x} = 1
lim⁡h→0f(x+h)−f(x)h\displaystyle \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}\lim_{h \to 0} \frac{f(x+h) - f(x)}{h}
lim⁡n→∞an\displaystyle \lim_{n \to \infty} a_n\lim_{n \to \infty} a_n
dydx\displaystyle \frac{dy}{dx}\frac{dy}{dx}
d2ydx2\displaystyle \frac{d^2 y}{dx^2}\frac{d^2 y}{dx^2}
f′(x)f'(x), f′′(x)f''(x)f'(x), f''(x)
x˙\dot{x}, x¨\ddot{x}\dot{x}, \ddot{x}
∂f∂x\displaystyle \frac{\partial f}{\partial x}\frac{\partial f}{\partial x}
∂2f∂x ∂y\displaystyle \frac{\partial^2 f}{\partial x \, \partial y}\frac{\partial^2 f}{\partial x \, \partial y}
∇f\nabla f\nabla f
∇⋅F\nabla \cdot \mathbf{F}, ∇×F\nabla \times \mathbf{F}\nabla \cdot \mathbf{F}, \nabla \times \mathbf{F}
∫f(x) dx\displaystyle \int f(x)\,dx\int f(x)\,dx
∫f(x) dx\displaystyle \int f(x)\,\mathrm{d}x\int f(x)\,\mathrm{d}x, with an upright d
∫abf(x) dx\displaystyle \int_a^b f(x)\,dx\int_a^b f(x)\,dx
∫0∞e−x dx=1\displaystyle \int_0^\infty e^{-x}\,dx = 1\int_0^\infty e^{-x}\,dx = 1
[F(x)]ab\Bigl[ F(x) \Bigr]_a^b\Bigl[ F(x) \Bigr]_a^b
∬Df dA\displaystyle \iint_D f\,dA\iint_D f\,dA
∮CF⋅dr\displaystyle \oint_C \mathbf{F} \cdot d\mathbf{r}\oint_C \mathbf{F} \cdot d\mathbf{r}

More in the guides to derivatives, integrals and the partial derivative symbol.

Sums, products and series

MathsLaTeX
∑i=1ni\displaystyle \sum_{i=1}^{n} i\sum_{i=1}^{n} i
∑n=0∞xnn!\displaystyle \sum_{n=0}^{\infty} \frac{x^n}{n!}\sum_{n=0}^{\infty} \frac{x^n}{n!}
∑1≤i≤ni oddai\displaystyle \sum_{\substack{1 \le i \le n \\ i \text{ odd}}} a_i\sum_{\substack{1 \le i \le n \\ i \text{ odd}}} a_i, two lines of conditions
∏k=1nk\displaystyle \prod_{k=1}^{n} k\prod_{k=1}^{n} k
n!n!n!
(nk)\displaystyle \binom{n}{k}\binom{n}{k}
a1+a2+⋯+ana_1 + a_2 + \dots + a_na_1 + a_2 + \dots + a_n
a1,a2,…,ana_1, a_2, \dots, a_na_1, a_2, \dots, a_n
∑i,jaij\displaystyle \sum_{i,j} a_{ij}\sum_{i,j} a_{ij}

In a line of text the limits of a sum sit beside it; on a line of its own they go above and below. See the sum and product guides and binomial coefficients.

Vectors and matrices

MathsLaTeX
v⃗\vec{v}\vec{v}
v\mathbf{v}\mathbf{v}
μ\boldsymbol{\mu}\boldsymbol{\mu}, for bold Greek letters
ı^\hat{\imath}, ȷ^\hat{\jmath}\hat{\imath}, \hat{\jmath}, with the dots removed
AB→\overrightarrow{AB}\overrightarrow{AB}
u⋅v\mathbf{u} \cdot \mathbf{v}\mathbf{u} \cdot \mathbf{v}
u×v\mathbf{u} \times \mathbf{v}\mathbf{u} \times \mathbf{v}
(abcd)\begin{pmatrix} a & b \\ c & d \end{pmatrix}\begin{pmatrix} a & b \\ c & d \end{pmatrix}
[1001]\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}
{abcd}\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}
∣abcd∣\begin{vmatrix} a & b \\ c & d \end{vmatrix}\begin{vmatrix} a & b \\ c & d \end{vmatrix}, a determinant
∥abcd∥\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}
(xyz)\begin{pmatrix} x \\ y \\ z \end{pmatrix}\begin{pmatrix} x \\ y \\ z \end{pmatrix}
(a11⋯a1n⋮⋱⋮am1⋯amn)\begin{pmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{m1} & \cdots & a_{mn} \end{pmatrix}\begin{pmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{m1} & \cdots & a_{mn} \end{pmatrix}
ATA^{\mathsf{T}}A^{\mathsf{T}}
A−1A^{-1}A^{-1}
det⁡(A)\det(A)\det(A)
tr⁡(A)\operatorname{tr}(A)\operatorname{tr}(A)

& separates columns and \\ ends a row, and the environment chooses the brackets. An augmented matrix, for row reduction, is an array with a | in its list of columns:

LaTeX
\left[ \begin{array}{cc|c} 1 & 2 & 5 \\ 3 & 4 & 6 \end{array} \right]
[125346]\left[ \begin{array}{cc|c} 1 & 2 & 5 \\ 3 & 4 & 6 \end{array} \right]

More in the matrices and vectors guides.

Sets and logic

MathsLaTeX
x∈Ax \in A, x∉Ax \notin Ax \in A, x \notin A
A⊆BA \subseteq B, A⊂BA \subset BA \subseteq B, A \subset B
A∪BA \cup B, A∩BA \cap BA \cup B, A \cap B
A∖BA \setminus BA \setminus B
AcA^c, A‾\overline{A}A^c, \overline{A}
A×BA \times BA \times B
∅\varnothing, ∅\emptyset\varnothing, \emptyset
R\mathbb{R}, N\mathbb{N}, Z\mathbb{Z}, Q\mathbb{Q}, C\mathbb{C}\mathbb{R}, \mathbb{N}, \mathbb{Z}, \mathbb{Q}, \mathbb{C}
Rn\mathbb{R}^n\mathbb{R}^n
{x∈R∣x>0}\{ x \in \mathbb{R} \mid x > 0 \}\{ x \in \mathbb{R} \mid x > 0 \}
∀x\forall x, ∃x\exists x\forall x, \exists x
∃! x\exists!\, x\exists!\, x
p  ⟹  qp \implies q, p  ⟺  qp \iff qp \implies q, p \iff q
¬p\neg p\neg p
p∧qp \land q, p∨qp \lor qp \land q, p \lor q
∴\therefore, ∵\because\therefore, \because

See the guides to element of, union, intersection, the empty set, real numbers, for all and implies.

Probability and statistics

MathsLaTeX
P(A∣B)P(A \mid B)P(A \mid B)
P(A∪B)=P(A)+P(B)−P(A∩B)P(A \cup B) = P(A) + P(B) - P(A \cap B)P(A \cup B) = P(A) + P(B) - P(A \cap B)
E[X]\mathbb{E}[X]\mathbb{E}[X]
Var⁡(X)\operatorname{Var}(X)\operatorname{Var}(X)
Cov⁡(X,Y)\operatorname{Cov}(X, Y)\operatorname{Cov}(X, Y)
xˉ\bar{x}\bar{x}
θ^\hat{\theta}\hat{\theta}
X∼N(μ,σ2)X \sim \mathcal{N}(\mu, \sigma^2)X \sim \mathcal{N}(\mu, \sigma^2)
(nk)pk(1−p)n−k\displaystyle \binom{n}{k} p^k (1-p)^{n-k}\binom{n}{k} p^k (1-p)^{n-k}
s=1n−1∑i=1n(xi−xˉ)2\displaystyle s = \sqrt{\frac{1}{n-1} \sum_{i=1}^{n} (x_i - \bar{x})^2}s = \sqrt{\frac{1}{n-1} \sum_{i=1}^{n} (x_i - \bar{x})^2}

Geometry

MathsLaTeX
90∘90^\circ90^\circ
∠ABC\angle ABC\angle ABC
△ABC\triangle ABC\triangle ABC
AB‾\overline{AB}\overline{AB}
AB∥CDAB \parallel CDAB \parallel CD
AB⊥CDAB \perp CDAB \perp CD
△ABC≅△DEF\triangle ABC \cong \triangle DEF\triangle ABC \cong \triangle DEF
△ABC∼△DEF\triangle ABC \sim \triangle DEF\triangle ABC \sim \triangle DEF

See the degree, angle, parallel and perpendicular guides.

Physics and units

MathsLaTeX
F=ma\mathbf{F} = m\mathbf{a}\mathbf{F} = m\mathbf{a}
E=hνE = h\nuE = h\nu
ℏ\hbar\hbar
Δx Δp≥ℏ2\displaystyle \Delta x \, \Delta p \geq \frac{\hbar}{2}\Delta x \, \Delta p \geq \frac{\hbar}{2}
⟨ψ∣ϕ⟩\langle \psi \vert \phi \rangle\langle \psi \vert \phi \rangle
g=9.81 m s−2g = 9.81\,\mathrm{m\,s^{-2}}g = 9.81\,\mathrm{m\,s^{-2}}
25 ∘C25\,^\circ\mathrm{C}25\,^\circ\mathrm{C}

Units are set upright with a thin space after the number. If you write a lot of them, the siunitx package does it for you: \qty{9.81}{\metre\per\second\squared}.

Details that make LaTeX maths look right

Everything in this section compiles either way. LaTeX will not warn you, and the difference only shows on the page, which is why these are the things that separate maths that looks typeset from maths that looks typed. Each pair below was typeset by pdflatex.

Pairs of LaTeX typeset by pdflatex, rough on the left and better on the right: sin and log without and with backslashes, a subscript max in italic and upright, brackets that do not and do grow around a fraction, an integral without and with a thin space before dx, absolute value bars with a spaced and an unspaced minus, a function colon with relation and punctuation spacing, set-builder notation with a cramped and a spaced bar, and angle brackets typed as less than and greater than signs and as proper angle brackets
Typeset by pdflatex. Each source is printed above its result.
  • Function names need their backslash. \sin, \log, \max, \det and the rest are set upright, as names. For one LaTeX does not know, use \operatorname{sgn}, or put \DeclareMathOperator{\sgn}{sgn} in the preamble once and write \sgn x from then on.
  • A subscript that is a word or a label, like max or eff, should be upright: x_{\text{max}}. A subscript that is a variable, like the ii in xix_i, stays italic. Inside a theorem, where the text is italic, \text turns italic with it, so \mathrm{max} is the safer choice there. More in text in maths mode.
  • \left( and \right) make brackets grow to fit what is inside. Use them around tall things such as fractions and sums, not everywhere: around a plain x they change nothing except to add a gap after a function name (\sin\left(x\right)), and a \left cannot be split from its \right across the lines of an align. For a fixed size, use \bigl( and \bigr), or \Bigl( and \Bigr) for larger.
  • \, before the dx gives the thin space printed books use. Some styles also set the d upright, \mathrm{d}x, as the ISO 80000-2 standard recommends; most English textbooks keep it italic. Either is fine if you are consistent.
  • A plain | is an ordinary symbol, so in |-x| LaTeX reads the minus as a subtraction and spaces it. \lvert and \rvert mark the bars as opening and closing, and the minus sits tight. Norms work the same way with \lVert and \rVert.
  • A plain colon is a relation, like an equals sign, so f: A \to B gets equal space either side of it. \colon is the punctuation colon used in function notation.
  • \mid is the bar in set-builder notation and in P(A∣B)P(A \mid B), with space on both sides. A typed | gets none. See the mid symbol guide.
  • < and > are less than and greater than. Angle brackets are \langle and \rangle.

A few more that do not show in the picture:

  • \varepsilon and \varphi are the shapes most people write by hand; \epsilon (ϵ\epsilon) and \phi (ϕ\phi) are the alternatives. Pick one of each and use it throughout. See epsilon and phi.
  • With amsmath, \dots chooses its own height from what follows it: centred in a_1 + \dots + a_n, on the line in a_1, \dots, a_n. To choose yourself, use \cdots or \ldots, and \vdots and \ddots in matrices. See the dots guide.
  • \mathbf{\mu} leaves a lowercase Greek letter as it was. Bold Greek needs \boldsymbol{\mu}, or \bm from the bm package. See bold and italic maths.
  • := sits its colon slightly low against the equals sign. \coloneqq from mathtools centres it.

Layouts: cases, working and numbered equations

Some maths is as much layout as symbols. These need an environment from amsmath, so they go on lines of their own.

A function defined in pieces uses cases. Each line is the value, then &, then the condition:

LaTeX
\[
  \lvert x \rvert =
  \begin{cases}
    x  & \text{if } x \geq 0, \\
    -x & \text{if } x < 0.
  \end{cases}
\]
∣x∣={xif x≥0,−xif x<0.\lvert x \rvert = \begin{cases} x & \text{if } x \geq 0, \\ -x & \text{if } x < 0. \end{cases}

Working over several lines uses align*, with & just before each equals sign so the signs line up:

LaTeX
\begin{align*}
  (x + 2)^2 &= (x + 2)(x + 2) \\
            &= x^2 + 2x + 2x + 4 \\
            &= x^2 + 4x + 4
\end{align*}
(x+2)2=(x+2)(x+2)=x2+2x+2x+4=x2+4x+4\begin{aligned} (x + 2)^2 &= (x + 2)(x + 2) \\ &= x^2 + 2x + 2x + 4 \\ &= x^2 + 4x + 4 \end{aligned}

Without the star, align numbers every line. If an old template or an AI answer gives you eqnarray instead, change it to align: eqnarray puts too much space around the equals signs, and l2tabu, the standard list of obsolete LaTeX, has warned against it for years.

An equation you want to refer back to goes in equation with a label. LaTeX numbers it and fills in the number wherever you write \eqref, so the references stay right when you add equations above it:

LaTeX
\begin{equation}
  e^{i\pi} + 1 = 0
  \label{eq:euler}
\end{equation}
Equation \eqref{eq:euler} links five constants.

Three more that come up often. A brace under part of an expression, 1+1+⋯+1⏟n times\underbrace{1 + 1 + \dots + 1}_{n \text{ times}}, is \underbrace{1 + 1 + \dots + 1}_{n \text{ times}} (see overbrace and underbrace). A symbol written over another, =def\overset{\text{def}}{=}, is \overset{\text{def}}{=}. A box round a final answer, x=3\boxed{x = 3}, is \boxed{x = 3}. Simultaneous equations have their own guide.

Handwritten maths to LaTeX

Retyping handwritten working is where most of the time goes, and where mistakes creep in: a minus sign dropped on line four survives all the way to the final answer. A converter does the typing, and your job becomes checking.

A worked example from handwritten lecture notes on integration by parts, solving the integral of e to the x times sin x by using parts twice, above the same working typeset in LaTeX
Handwritten working (top) and the LaTeX LatexNotes made from it (bottom). The aligned line and the boxed answer come through; the circles round the two I's do not.

For whole pages, a handwriting to LaTeX converter reads a photo or PDF of your notes and gives back one LaTeX document, with fractions, matrices and lines of working in shape. LatexNotes does this for full lecture notes and redraws hand-drawn graphs as TikZ code you can edit. On an iPad you can also write straight into a LatexNotes notebook with an Apple Pencil and convert any part of the page in place. Notes already in Goodnotes have their own route.

For a single equation inside Goodnotes, its own Math Conversion works: lasso the equation, choose Convert and then Math, and copy or share the result as LaTeX.

For one symbol whose name you do not know, draw it. The LatexNotes symbol finder and Detexify both name a symbol from a rough sketch.

The LatexNotes symbol finder with a proportional to sign drawn by mouse on the left, and its matches on the right: propto first, then varpropto and infty, each with its command and a Copy button
A rough mouse drawing of the proportional to sign. The symbol finder's first match is \propto.

What trips up a converter is what trips up anyone reading your notes: a ×\times that could be an xx, a ν\nu that could be a vv, a 11 that could be an ll or a bar, a superscript that touches the line above it, a scribble over a mistake. Dark ink, a little space between lines and one clean line through crossed-out work fix most of it. And read the typeset result against the page before you hand it in. A misread symbol usually still compiles, so nothing else will catch it.

A photo or screenshot of maths

A photo of a whiteboard, a textbook page or a screenshot of a lecture slide goes through photo to LaTeX or any other maths OCR tool (OCR, optical character recognition, is software that reads text from an image). Printed maths converts far more reliably than handwriting. Crop to the maths you want, so nothing nearby gets read as part of it. Shoot straight on rather than at an angle, which squashes fraction bars and subscripts. And if the maths is on a screen, take a screenshot rather than a photo of the screen. Maths OCR explains how the recognition works and where it struggles.

Maths in a PDF

Copying maths out of a PDF almost never works. A PDF records which character goes where on the page, not the LaTeX that put it there, so a pasted integral arrives as a scatter of symbols and numbers.

If the PDF is a paper on arXiv, get the authors' own LaTeX instead: the TeX Source link on the paper's abstract page downloads it. Lecturers will often share their source if you ask. Otherwise, convert the page as an image. PDF to LaTeX reads typed and handwritten PDFs page by page and gives back one document.

Word and Google Docs equations

Word for Microsoft 365 can show any equation as LaTeX:

  1. Click into the equation.
  2. On the Equation tab, choose LaTeX as the input format.
  3. Press Ctrl + Shift + = to switch the equation to linear format. It now reads as LaTeX code you can copy.
  4. Press Ctrl + = to turn it back.

If LaTeX is not on your Equation tab, your version of Word only has UnicodeMath, which looks similar but is not LaTeX.

For a whole Word document, the free command-line tool pandoc converts a .docx file to LaTeX, equations included:

bash
pandoc notes.docx -o notes.tex

Complicated layouts can need tidying afterwards, but it beats retyping a document.

Google Docs cannot export its equations as LaTeX. Take a screenshot and convert it as a photo, or retype it with the examples above. Its equation editor does accept LaTeX-style shortcuts such as \alpha and \frac, so typing them will already feel familiar.

Markdown, Obsidian and Notion

If your notes are in Markdown, the maths is probably LaTeX already. Obsidian and most Markdown editors put maths between dollar signs, $...$ in a line and $$...$$ on its own line, using LaTeX commands. Notion's equations are LaTeX too; click one to see its code. You can copy the maths across as it is. The one change for a LaTeX document is to swap $$...$$ for \[ ... \], for the reason below.

LaTeX from maths software

Computer algebra systems write their results as LaTeX directly, which saves copying a long expression by hand.

SoftwareHow to get LaTeX
MathematicaTeXForm[expr]
Maplelatex(expr)
MATLAB (Symbolic Math Toolbox)latex(S) for a symbolic expression S
Python with SymPylatex(expr)

The output is correct but written for a machine. Here is SymPy integrating x2sin⁡xx^2 \sin x:

python
from sympy import symbols, integrate, sin, latex

x = symbols("x")
print(latex(integrate(x**2 * sin(x), x)))
Output
- x^{2} \cos{\left(x \right)} + 2 x \sin{\left(x \right)} + 2 \cos{\left(x \right)}

Every function argument is wrapped in \left( and \right), and every power gets braces it does not need. It compiles, but it reads badly as source and the brackets add nothing. SymPy's fold_func_brackets=True option drops them, giving - x^{2} \cos {x} + 2 x \sin {x} + 2 \cos {x}, and a minute of tidying by hand gets you what you would have written yourself:

LaTeX
-x^2 \cos x + 2x \sin x + 2 \cos x

ChatGPT and other AI

Chatbots are good at LaTeX syntax. Where they go wrong is the maths. Asked to convert, they sometimes simplify, reorder or quietly correct it, and a changed sign or index looks perfectly reasonable in code. A few habits keep that from reaching your work:

  • Say exactly what you want: "Convert this to LaTeX exactly as written, without simplifying. Use amsmath, put the working in align*, and return only the code."
  • Render the answer and compare it with the original symbol by symbol. Reading the code is not enough.
  • Watch for things that work in a chat window but not in a LaTeX document. Pasted symbols such as π or ≤ stop pdflatex with "Unicode character not set up for use with LaTeX". $$...$$ and eqnarray work but are best replaced. Old plain TeX such as {a \over b} makes amsmath warn "Foreign command \over".
  • For a page of notes rather than one equation, use a converter built for documents. A chat answer tends to summarise or skip, where a converter keeps every line.

If you would rather describe maths in words than type commands, Text to LaTeX turns a description such as "integral from 0 to pi of sine x" into LaTeX, with a preview.

Reading LaTeX errors

Converted LaTeX is usually right, and when it is not, the error message says where. Here is what pdflatex printed for a sentence with a power typed outside maths mode:

Output
! Missing $ inserted.
<inserted text>
                $
l.4 The side is 3 metres, so the area is 3^
                                           2 = 9 square metres.

Every TeX error has this shape. The line starting with ! says what went wrong. The line starting l.4 is line 4 of your file, broken at the point where TeX gave up: just after the ^, which only means something in maths mode. TeX then reported a second "Missing $" on line 5, which was only a knock-on of the first, so always fix the first error and compile again before reading the rest.

An "Undefined control sequence" points at the command it does not know in the same way. Here it is \mathbb, used without \usepackage{amssymb}:

Output
! Undefined control sequence.
l.4 Let $f\colon \mathbb
                        {R} \to \mathbb{R}$ be continuous.

The ones you will meet most:

Error messageUsual causeFix
Missing $ insertedA maths command such as x^2 or \alpha outside maths modePut the maths in $...$
Undefined control sequenceA misspelt command, or one from a package that is not loadedCheck the spelling, or load amsmath or amssymb
Missing \right. insertedA \left with no matching \rightAdd the \right) it needs, or \right. for no bracket
Extra }, or forgotten $Unbalanced bracesCount the braces in the equation
Misplaced alignment tab character &An & outside align, cases or a matrixPut the lines in an environment
Unicode character not set up for use with LaTeXA pasted symbol such as π or ≤Replace it with \pi or \leq

To test one equation without setting up a document, paste it into the LaTeX equation editor and check the preview.

Inline or display maths, and a document that compiles

Maths inside a sentence goes in $...$, or the equivalent \( ... \). Maths on its own line goes in \[ ... \], or in equation if you want it numbered. The difference is more than position: inline maths is squeezed to fit the height of the line, and display maths gets full size.

A paragraph typeset by pdflatex: a sum written inline with its limits beside it, a full-size fraction in the middle of a line that pushes that line away from the one above, a small fraction and a slash that keep the spacing even, and the same sum displayed on its own line with its limits above and below
Typeset by pdflatex. The full-size fraction in the middle of the paragraph forces a wider gap above its line; the small fraction and the slash do not.

You will see $$...$$ used for display maths in Markdown and all over the web. It usually works in LaTeX too, but it is plain TeX rather than LaTeX: it ignores the fleqn option that sets equations flush left and can leave uneven space above an equation. In a LaTeX document, \[ ... \] is the right choice.

This document loads the three packages the examples on this page use. Paste any of them between \begin{document} and \end{document} and it will compile:

LaTeX
\documentclass{article}
\usepackage{amsmath, amssymb, mathtools}

\begin{document}

The roots of $ax^2 + bx + c = 0$ are
\[
  x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}.
\]

\end{document}

Open it in LatexNotes, Overleaf or any LaTeX editor. For whole documents rather than single equations, the LaTeX templates are set up for notes, homework and reports, and the LaTeX symbols list has every symbol on one page.

Frequently asked questions

How do I convert maths to LaTeX?

Write it in maths mode with LaTeX commands, such as \frac{a}{b} for a fraction and x^2 for a power, or use a converter: a maths OCR tool for handwriting, photos and PDFs, Word's LaTeX mode for Word equations, or the LaTeX export in software such as Mathematica or SymPy.

Is there a free maths to LaTeX converter?

Yes. LatexNotes' Text to LaTeX is free with no sign-up: type or describe an equation and copy the LaTeX. The LatexNotes symbol finder names any symbol you draw. Converting pages of handwritten notes needs a free account.

Can I convert handwritten maths to LaTeX?

Yes. Photograph or scan the page, or write on a tablet, and use a handwriting to LaTeX converter. Dark ink, space between lines and clearly different look-alike symbols (an x and a times sign, a v and a nu) make the result much more accurate. Check the typeset result against the page, because a misread symbol usually still compiles.

Why does my LaTeX maths compile but look wrong?

Usually a missing backslash on a function name (sin x instead of \sin x), a word typed straight into maths instead of \text{}, brackets that do not grow round a fraction (use \left( and \right)), or a typed | or < where \mid, \lvert or \langle was meant.

How do I get LaTeX from a Word equation?

In Word for Microsoft 365, click into the equation, choose LaTeX as the input format on the Equation tab, then press Ctrl + Shift + = to show the equation in linear format, which is its LaTeX code. For a whole document, pandoc converts a .docx file to LaTeX, equations included.

Can ChatGPT convert maths to LaTeX?

Yes, for single equations and short derivations, but it can change the maths while converting it. Always render the code and compare it with the original before you use it.

What is the difference between inline and display maths in LaTeX?

Inline maths, written between single dollar signs, sits inside a line of text. Display maths, written in \[ ... \], goes on its own line, centred and full size. Use the equation environment instead when you want the equation numbered.

Why does LaTeX say "Missing $ inserted"?

A maths command such as x^2 or \alpha is outside maths mode. Put the maths between dollar signs, or inside \[ ... \] on its own line.

Sources