Updated 2026-11-25
The basic command: \div
In LaTeX the division sign ÷ is \div, and it only works in math mode:
$12 \div 3 = 4$ → 12 ÷ 3 = 4
\div is a binary operator, so LaTeX adds the right amount of space on each side; do not add \, or extra spaces yourself. No package is needed. Outside math mode, writing \div causes a "Missing $ inserted" error. If you really need ÷ in running text, use \textdiv (from textcomp, which modern LaTeX loads automatically) or simply write $\div$.
With XeLaTeX or LuaLaTeX and the unicode-math package you can also type the character ÷ directly in math mode; it is mapped to \div. Copy it here:
All the ways to write division in LaTeX
| You write | Result | Package | Use for |
|---|---|---|---|
a \div b | a ÷ b | none | Arithmetic, primary-school style |
a / b | a/b | none | Inline division in text |
\frac{a}{b} | ab | none | Display fractions |
\dfrac{a}{b}, \tfrac{a}{b} | large / small fraction | amsmath | Force display or text size |
{a \over b} | ab | plain TeX | Legacy; prefer \frac |
\nicefrac{1}{2} / \sfrac{1}{2} | slanted ½ | nicefrac / xfrac | Small fractions in text |
a : b or a \mathbin{:} b | a : b | none | Ratio, or European-style division |
\divideontimes | ⋇ | amssymb | Rare "division times" operator |
\oslash | ⊘ | none | Circled slash operator |
Rule of thumb: in algebra and beyond use \frac or a slash; reserve \div for arithmetic worksheets. Why the international standard discourages ÷ is covered in ÷ vs / vs the fraction bar.
Divides and does not divide: \mid and \nmid
In number theory, "3 divides 12" is written $3 \mid 12$ → 3 ∣ 12, and "5 does not divide 12" is $5 \nmid 12$ → 5 ∤ 12 (\nmid needs amssymb). Use \mid rather than the keyboard |, which LaTeX spaces as an ordinary symbol, so 3|12 comes out cramped. The meaning is explained on the divides symbol page.
Long division in LaTeX
Several CTAN packages draw the full long division layout for you:
- longdivision by Hood Chatham:
\longdivision{127}{3}works out and typesets every step, continuing into decimals until the remainder is zero or repeats;\intlongdivision{127}{3}stops at the whole-number quotient and shows the remainder. The dividend must be a positive decimal number and the divisor a positive integer. Included in TeX Live and MiKTeX. - longdiv by Donald Arseneau:
\longdiv{127}{3}prints an integer long division with the remainder at the bottom; it is plain TeX and works in any format. - xlop:
\opdiv{127}{3}typesets division and other written arithmetic, with many layout options. - polynom:
\polylongdiv{x^3-2x^2+3x-4}{x-2}typesets polynomial long division. To check the algebra first, use the polynomial long division calculator.
A minimal document:
\documentclass{article}
\usepackage{longdivision}
\begin{document}
\intlongdivision{127}{3} % 42 remainder 1
\longdivision{22}{7} % 3.142857... with steps
\end{document}
Our own long division calculator shows the same layout in the browser if you just need to check an answer.
MathJax and KaTeX on websites
\div, \frac, \mid and \nmid all work in MathJax and KaTeX. For the long division bracket, MathJax has the enclose extension:
\require{enclose}
\begin{array}{r}
42 \\[-3pt]
3 \enclose{longdiv}{127}
\end{array}
The LaTeX packages above (longdivision, longdiv, xlop) do not run in MathJax. With unicode-math, the character ⟌ is mapped to a command also named \longdivision, which clashes with the longdivision package, so do not load both. For HTML codes rather than LaTeX, see the division symbol HTML code page.
Frequently asked questions
What is the LaTeX command for the division symbol?
Use \div in math mode: $12 \div 3$ gives 12 ÷ 3. No package is needed.
Why does \div give "Missing $ inserted"?
\div is a math-mode command. Put it between dollar signs, or use \textdiv for ÷ in normal text.
How do I write a fraction instead of ÷ in LaTeX?
Use \frac{a}{b} for a stacked fraction or a/b inline. With amsmath, \dfrac and \tfrac force large or small sizes.
How do I write long division in LaTeX?
Load the longdivision package and write \longdivision{127}{3} or \intlongdivision{127}{3}. The longdiv and xlop packages are alternatives; in MathJax use \enclose{longdiv}.
What is the LaTeX symbol for "divides"?
Use \mid for ∣ (a divides b) and \nmid from amssymb for ∤ (does not divide).