Divides / such that (∣) in LaTeX
\mid produces a single vertical bar (∣) used as a relation, most commonly for 'divides' in number theory and for 'such that' inside set-builder notation.
LaTeX command
\midNot the symbol you meant? Draw it to find the command →
Typing up handwritten notes? Convert a whole page of handwriting to LaTeX →
In number theory, means a divides b exactly, that is, b is an integer multiple of a. This is a statement about integers, entirely different from a fraction: is true, while 2/6 is a number. The negation is \nmid, giving .
Inside curly braces, \mid reads as 'such that': \{ > 0\} is the set of all x satisfying the condition after the bar. \mid is also the standard way to write the bar in conditional probability, P(), where it gets sensible spacing that a plain typed pipe does not.
\mid is a relation, so avoid it where you actually want a delimiter. Absolute value bars should be \lvert x \rvert (or plain | for quick notes), and a function restriction uses a bare bar with a subscript, f|_A, rather than \mid.
Other forms
\nmiddoes not divide (∤)Examples
$2 \mid 6$2 divides 6
$\{x \mid x > 0\}$set-builder notation, read as 'such that'
$P(A \mid B)$conditional probability, correctly spaced
$7 \nmid 15$7 does not divide 15
Tips and common mistakes
- Use
\mid, not a plain typed |, inside set-builder notation and conditional probability; the spacing is noticeably better in both directions. - For 'does not divide', use
\nmidrather than typing\midwith a slash on top; it needs the amssymb package. - If the set on either side of \{ \} needs to grow, wrap the braces in
\left\{...\right\}, and\midwill usually still sit correctly in the middle. - Don't reuse
\midfor absolute value bars; use\lvertx\rvertinstead, which pairs correctly and matches how mathematicians expect a delimiter to behave.
Working from handwritten notes?
LatexNotes turns a photo or PDF of handwritten mathematics into LaTeX, graphs and all. It is built with real pdflatex before you see it, and the .tex file is yours to edit or take to Overleaf. Free to try, no sign-up.
See how handwriting to LaTeX works, step by step, or go from GoodNotes to LaTeX if you write on an iPad (Notability works the same way).
Convert your maths to LaTeX →FAQ
What's the difference between \mid and | in LaTeX?
\mid is a relation with built-in spacing, suited to 'divides' and 'such that'. A plain | is just a character, commonly used as a quick absolute value delimiter but with no spacing logic of its own.
How do I write 'such that' in set notation?
Put \mid inside the braces: \{(x)\} reads as 'the set of x such that P(x) holds'.
How do I write 'does not divide' in LaTeX?
Use \nmid, which renders as ∤ and requires the amssymb package.
Should I use \mid for conditional probability?
Yes, P() is the standard, well-spaced way to typeset it, better than a plain vertical bar character.