Set Notation in LaTeX: Braces, Membership and Operations

Braces need escaping, membership needs the right relation, and set-builder wants a braced vertical bar — the small syntax decisions that make or break a set.

Set notation is mostly a character-escape problem plus three symbol choices that are easy to confuse: \in against \epsilon, \subset against \subseteq, and \mid against a plain vertical bar. Braces in maths are grouping characters, so a literal one is always \{ — which is also why LaTeX reads a set and a Brackets pair as different things.

Which one to use

Situation Write this Because
Roster form
\{1,2,3\}
Escaped braces; they do not auto-size.
Set-builder notation
\{x \mid x>0\}
\mid, not a typed bar.
Membership
x \in A
\in, not the letter epsilon.
Subset
A \subseteq B
\subset and \subseteq differ.
Union and intersection
A \cup B, A \cap B
Big forms for families of sets.
The empty set
\varnothing
Reads better than \emptyset in most fonts.

The commands

What Type this Renders as
Roster form Backslash before each brace; the spaces around the content keep it legible in source.
A = \{ 1, 2, 3 \}
A = \{ 1, 2, 3 \}
Membership Relations, not letters. There is no ASCII equivalent.
2 \in A \quad 5 \notin A
2 \in A \quad 5 \notin A
Set builder The conditioned bar is \mid, sized and spaced for exactly this job.
\{ x \in \mathbb{R} \mid x > 0 \}
\{ x \in \mathbb{R} \mid x > 0 \}
Colon variant Some traditions use a colon instead of a bar; both parse, and a bare : spaces too tightly.
\{ x \in \mathbb{Z} : x^2 \le 4 \}
\{ x \in \mathbb{Z} : x^2 \le 4 \}
Union Lower-case cup. \bigcup is the version that carries indexed limits.
A \cup B
A \cup B
Intersection Cap; likewise \bigcap for indexed families.
A \cap B
A \cap B
Difference Upright slanted bar. A plain minus sign is a different object and reads as arithmetic.
A \setminus B
A \setminus B
Complement Superscript c or prime; \complement_S(A) is the explicit relative-complement command.
A^{c} \quad A^{\prime}
A^{c} \quad A^{\prime}
Empty set Two glyphs for one concept; the slashed form is European and TeX-standard.
\emptyset \quad \varnothing
\emptyset \quad \varnothing
Number systems Double-struck capitals via \mathbb, the only place it is genuinely needed.
\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R}
\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R}

Worked examples

Definition by property

E = \{ x \in \mathbb{R} : |x| \le 1 \}
E = \{ x \in \mathbb{R} : |x| \le 1 \}

Absolute bars inside a builder read as a condition, not as delimiters, because there is nothing to close.

Disjoint sets

A \cap B = \emptyset
A \cap B = \emptyset

The standard one-line way to state that two sets share nothing.

De Morgan

(A \cup B)^{c} = A^{c} \cap B^{c}
(A \cup B)^{c} = A^{c} \cap B^{c}

The complement binds to the whole bracketed group, which is why the parentheses are load-bearing.

Indexed family

\bigcup_{n=1}^{\infty} A_n = \{ x : x \in A_n \text{ for some } n \}
\bigcup_{n=1}^{\infty} A_n = \{ x : x \in A_n \text{ for some } n \}

The big-operator form takes bounds above and below; \cup with a subscript does not stack properly.

Common mistakes

  • Writing \{x : x > 0\} with an HTML entity for the greater-than sign. In a raw LaTeX file that is a table separator and breaks the layout.
  • Confusing \subset with \subseteq. One excludes equality, the other does not, and textbooks disagree about which the single symbol means.
  • Using \in for subsets (A \in B means A is an element of B) or \subset for elements.
  • Leaving braces unescaped. {1,2} is an invisible grouping token in LaTeX and prints as 1,2 with no braces at all.

Questions about this notation

How do I write curly braces in LaTeX math?
Escape both of them: \{ and \}. Unescaped braces are grouping operators and disappear from the output. Inside \left and \right you still need the backslash.
What is the difference between \emptyset and \varnothing?
Nothing in meaning, only in glyph: the first is the AMS rounded form, the second the slashed Nordic character. Pick one and stay with it across the document.
How do I write the power set?
\mathcal{P}(A) or 2^A. The calligraphic P is the common European spelling; the exponential form is standard in set theory and needs no command at all.
What is the difference between \mid, \colon and a plain colon?
\mid puts space on both sides, which is what a set builder wants: \{ x \mid x > 0 \}. \colon keeps the space after it tight, which is right for a mapping: f \colon A \to B. A bare keyboard colon gets neither spacing rule right, and it also loses the relation spacing that the rest of the line depends on.

Keep reading

Three ways into the same idea: the notation itself, the lesson that teaches it, and an article that applies it.