Set notation in LaTeX is a handful of commands used together: escaped braces for the set itself, \mid for set-builder notation, \in for membership and \cup, \cap and \setminus to combine sets. Each symbol has its own page with variants; this page shows how they fit together.
All ways to write it
\{ 1, 2, 3 \}braces must be escaped, a bare { } only groupsNo package needed\{ x \in A \mid x > 0 \}set-builder notation, \mid is the bar read as "such that"No package needed\in \notinelement of, not an element ofNo package needed\subseteq \subset \supseteqsubset, proper subset, supersetNo package needed\cup \cap \setminusunion, intersection, differenceNo package neededA^ccomplement; some authors write \overline{A} or A'No package needed\emptyset \varnothingempty set; \varnothing is the rounder glyphPackage: amssymb\mathcal{P}(A)power setNo package needed|A|cardinality, the number of elementsNo package neededA \times BCartesian productNo package needed\mathbb{N} \mathbb{Z} \mathbb{Q} \mathbb{R}number setsPackage: amssymb
Commands marked with a package need that \usepackage line in a LaTeX document.
Example
A \setminus B = \{ x \in A \mid x \notin B \}The difference of two sets, written in set-builder notation.
Questions
Why do my braces disappear?
In LaTeX a bare { } groups things and prints nothing. Write \{ and \} (or \lbrace and \rbrace) to get visible braces.
How do I write set-builder notation?
Write \{ x \in \mathbb{R} \mid x > 0 \}. \mid gives the bar the right spacing; a plain | sits too close to its neighbours. A colon works too: \{ x : x > 0 \}.
How do I make the braces grow with tall content?
Use \left\{ ... \middle| ... \right\}. The braces and the bar then scale to the height of what is inside, for example a fraction.
How do I write set difference and complement?
\setminus prints the backslash-style minus (A ∖ B). For the complement, A^c is the most common; \complement (amssymb) prints ∁ for those who prefer it.
Using set notation in Confluence
Confluence Cloud has no built-in LaTeX. With LaTeX Math for Confluence you add a math macro to any page, type \{ 1, 2, 3 \} and it renders inline or as a block, with a live preview while you edit. Every command on this page renders there without extra packages.