Cardinality in LaTeX (|A|)
- LaTeX command
|A|- Package
- No package needed: built into LaTeX
- Mode
- Text and math mode
Where it is used
Vertical bars around a set, giving its cardinality: the number of elements it contains.
For finite sets |A| counts elements, as in the inclusion-exclusion formula |A \cup B| = |A| + |B| - |A \cap B|; for infinite sets it is the cardinal number. The same notation means absolute value for numbers and determinant for matrices, so context decides. Alternatives include \#A and \operatorname{card}(A). For spacing that knows left from right, write \lvert A \rvert, and use \left| ... \right| around tall contents like \mathcal{P}(\mathbb{N}). In combinatorics, |A| = |B| for finite sets is often proved by exhibiting a bijection.
Also listed under: Aljabar Linear, Kombinatorika
Minimal compilable example
Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.
\documentclass{article}
\begin{document}
Cardinality: $|A|$
\[ |A \cup B| = |A| + |B| - |A \cap B| \]
\end{document}Related symbols
- Aleph
\aleph - Power Set
\mathcal{P} - Complex Numbers
\mathbb{C} - Real Numbers
\mathbb{R} - Rational Numbers
\mathbb{Q} - Integers
\mathbb{Z}
Frequently asked questions
- How do I write Cardinality in LaTeX?
- Type |A| in math mode, for example $|A \cup B| = |A| + |B| - |A \cap B|$. It works in plain LaTeX without loading any package.
- Which package do I need for |A|?
- None. |A| is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
- Can I use |A| in text mode, or only in math mode?
- Both. |A| compiles in running text as well as inside $...$; in a formula keep it in math mode so it gets math fonts and spacing.
Editor LaTeX AI Terbaik, Alternatif Overleaf
Octree membantu peneliti dari 15+ universitas menulis makalah penelitian lebih cepat menggunakan AI
- Hasilkan diagram TikZ yang indah menggunakan AI
- Unggah gambar dan konversi ke LaTeX dengan mulus
- Dapatkan bantuan instan untuk menulis dan memformat makalah penelitian