Conditional in LaTeX (\mid)

∣\mid
LaTeX command
\mid
Package
No package needed: built into LaTeX
Mode
Math mode only
Copy the Unicode character
∣U+2223

Where it is used

Vertical bar with relation spacing, read as 'given', 'such that' or 'divides'.

Unlike a plain |, \mid adds space on both sides, which is exactly what conditional probability P(A \mid B), set-builder notation \{x \mid x > 0\} and divisibility 3 \mid 12 need. Use | or \vert for absolute values, where no extra space is wanted, and \lvert ... \rvert when the bar brackets something. In set-builder notation with tall content, \middle| between \left\{ and \right\} grows the bar to match. Its negation is \nmid, for does not divide. Many authors use a colon in set-builder notation instead, which avoids confusion when divisibility also appears.

Also listed under: نظرية الأعداد, المحددات الكمية, علوم الحاسوب

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

{x∈Z∣3∣x}\{x \in \mathbb{Z} \mid 3 \mid x\}
\documentclass{article}
\usepackage{amssymb}
\begin{document}
Conditional: $\mid$

\[ \{x \in \mathbb{Z} \mid 3 \mid x\} \]
\end{document}

Related symbols

All الاحتمالات والإحصاء →

Frequently asked questions

How do I write Conditional in LaTeX?
Type \mid in math mode, for example $\{x \in \mathbb{Z} \mid 3 \mid x\}$. It works in plain LaTeX without loading any package.
Which package do I need for \mid?
None. \mid is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use \mid in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\mid$ in running text. If you only need the glyph in text, paste the Unicode character ∣ instead (with XeLaTeX or LuaLaTeX and a font that has it).
Math poweredاكتب LaTeX باستخدام الذكاء الاصطناعي

أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf

يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي

  • أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
  • ارفع صورة وحولها إلى LaTeX بسلاسة
  • احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث