Set minus / difference (∖) in LaTeX
The set difference A ∖ B holds the elements of A that are not in B; in LaTeX write , which LaTeX spaces as an operation between two sets.
LaTeX command
A \setminus BNot the symbol you meant? Draw it to find the command →
Typing up handwritten notes? Convert a whole page of handwriting to LaTeX →
\setminus and \backslash print the same stroke, but \setminus is a binary operator, so it gets a space on each side: . \backslash is an ordinary symbol with no space, meant for other uses such as a quotient by a group action. For a set difference, always use \setminus.
amssymb adds \smallsetminus, a shorter stroke some writers prefer. A minus sign, A - B, is also seen, but it can be confused with subtraction when the sets hold numbers.
The complement of A, everything outside it, is written A^{c}, A^{\complement} (amssymb) or \overline{A}. The symmetric difference, the elements in exactly one of the two sets, is often written with a triangle; wrap it in \mathbin so it is spaced as an operation: A \mathbin{\triangle} B.
Other forms
\smallsetminusa smaller set minus, amssymbA^{c}complementA^{\complement}complement sign, amssymbA \mathbin{\triangle} Bsymmetric differenceExamples
$A \setminus B = \{x \in A : x \notin B\}$the definition
$\{1, 2, 3\} \setminus \{2\} = \{1, 3\}$a worked difference
$\mathbb{R} \setminus \{0\}$the real numbers without zero
$A^{c} = U \setminus A$the complement as a difference
$A \mathbin{\triangle} B = (A \setminus B) \cup (B \setminus A)$symmetric difference
Tips and common mistakes
- Use
\setminus, not\backslash: only\setminusis spaced as an operation. - Avoid A - B for sets of numbers, where it reads as subtraction.
\smallsetminusand\complementneed amssymb;\setminusis built in.- Escape braces in set notation: \{2\}, since plain { } only group in LaTeX.
- Wrap
\trianglein\mathbinfor a symmetric difference so it gets operator spacing.
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
How do I write set difference in LaTeX?
Write , which prints A ∖ B with operator spacing.
What is the difference between \setminus and \backslash?
They print the same stroke. \setminus is spaced as an operation between sets; \backslash has no spacing.
How do I write the complement of a set?
Write A^{c}, A^{\complement} with amssymb, or \overline{A}, following your course.
How do I write symmetric difference?
Write A \mathbin{\triangle} B, or in some texts.