Set Builder in LaTeX (\{ x \mid P(x) \})
- LaTeX command
\{ x \mid P(x) \}- Package
- No package needed: built into LaTeX
- Mode
- Math mode only
Where it is used
Set-builder notation: the set of all x for which the property P(x) holds, written with braces and a divider.
Braces must be escaped as \{ and \} in math mode, otherwise they only group and vanish from the output. \mid is a relation, so it gets proper space on both sides, unlike a bare | which is an ordinary symbol and crowds the letters. When the condition contains fractions or tall material, size everything together: \left\{ x \;\middle|\; \frac{x}{2} \in \mathbb{Z} \right\}. A colon works equally well as the separator and avoids confusion when the condition itself contains absolute values.
Minimal compilable example
Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.
\documentclass{article}
\usepackage{amssymb}
\begin{document}
Set Builder: $\{ x \mid P(x) \}$
\[ \{ x \in \mathbb{R} \mid x^2 - 1 < 0 \} = (-1, 1) \]
\end{document}Related symbols
- Quantified Statement
\forall x \exists y : P(x, y) - Such That (Colon)
: - Conditional
\mid - Exists in Set
\exists x \in A - For All in Set
\forall x \in A - Exists x
\exists x
Frequently asked questions
- How do I write Set Builder in LaTeX?
- Type \{ x \mid P(x) \} in math mode, for example $\{ x \in \mathbb{R} \mid x^2 - 1 < 0 \} = (-1, 1)$. It works in plain LaTeX without loading any package.
- Which package do I need for \{ x \mid P(x) \}?
- None. \{ x \mid P(x) \} is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
- Can I use \{ x \mid P(x) \} in text mode, or only in math mode?
- Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\{ x \mid P(x) \}$ in running text.
أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf
يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي
- أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
- ارفع صورة وحولها إلى LaTeX بسلاسة
- احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث