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 poweredAI로 LaTeX 작성

최고의 AI LaTeX 편집기, Overleaf 대안

Octree는 15개 이상의 대학의 연구자들이 AI를 사용하여 논문을 더 빠르게 작성하도록 도움

  • AI로 아름다운 TikZ 다이어그램 생성
  • 이미지를 업로드하고 LaTeX로 원활하게 변환
  • 논문 작성 및 서식에 대한 즉각적인 지원 받기