The most-used relation symbol in mathematics has an author, and he wrote down his reason. Robert Recorde first set = in type in The Whetstone of Witte (1557), choosing a pair of parallel lines — his “Gemowe”, or twin, lines — because, as he put it, no two things can be more equal. In LaTeX that sign heads a family: =, \neq, \leq, \approx and \equiv are all relations, and what matters about them is less their shape than their class. TeX bundles them into a single class and hands every member the same deliberately wide space, wider than a binary operator gets. This page follows the family — equality and its near-misses, the ordering signs, negation, and how to promote a symbol of your own into a relation — around one idea: meaning is a matter of convention, but spacing is declared in your source, and you can declare it yourself.
Why = gets more room than +
Because TeX chooses the space by class, not by shape. Every symbol in a formula belongs to one of a handful of classes — ordinary, binary operator, relation, opening, closing, punctuation, inner — and the gap between two neighbours is looked up from a table of class pairs. A binary operator such as + is padded with \medmuskip, which plain TeX sets to 4mu plus 2mu minus 4mu; a relation such as = is padded with \thickmuskip, set to 5mu plus 5mu. So the equals sign starts out wider and, unlike the plus, keeps room to stretch when a line has to be filled. None of this is anything you type. Write a+b=c with no spaces at all and the output is spaced correctly.
The cleanest proof that class does the work, and not shape, is a pair of commands that draw the identical character. In fontmath.ltx, the file where LaTeX declares its math symbols, | is \DeclareMathDelimiter{|}{\mathord}…{symbols}{"6A} while \mid is \DeclareMathSymbol{\mid}{\mathrel}{symbols}{"6A} — slot "6A of the same font in both cases, one declared ordinary and the other declared a relation. Set a | b beside a \mid b and it is the same bar with a different amount of air around it. The same pairing exists for \| and \parallel, both at slot "6B: \parallel (∥) is a relation and can assert “is parallel to”, whereas \| is an ordinary delimiter meant for norms like \|x\|. Picking the wrong one of a pair is the commonest way to get spacing that looks subtly off and refuses to explain itself.
% same glyph, different class: | is ordinary, \mid is a relation
\[ a | b \qquad a \mid b \]
% a bare letter is ordinary; \mathrel promotes it
\[ A R B \qquad A \mathrel{R} B \]
% the colon trap: ":" is a relation, \colon is punctuation
\[ f : A \to B \qquad f\colon A \to B \]So the practical move is to declare the class yourself. \mathrel{...} makes its contents a relation and \mathbin{...} makes them a binary operator; both are standard LaTeX. A bare letter is an ordinary symbol, so A R B sets the R tight against its neighbours, while A \mathrel{R} B gives it the spacing of =. The trap in the other direction is the colon. LaTeX declares the character : as a relation, so f : A \to B puts full relation space on both sides of a colon that is really punctuation; \colon exists as a \mathpunct for exactly this case, which is why f\colon A \to B is the recommended form. Arrows belong to the relation class as well — that is why \to insists on math mode — but they have a page of their own.
Choosing between \approx, \sim, \simeq and \cong
A serviceable rule: \approx (≈) for numbers that are nearly equal, \sim (∼) for an equivalence relation or “same order of magnitude”, \simeq (≃) for asymptotic equality and homeomorphism, and \cong (≅) for congruence in geometry and isomorphism in algebra. All four are plain LaTeX; none needs a package. They resemble one another on purpose — each is the equals sign with its rigidity relaxed by a different amount — and that is exactly why readers go by the command name rather than the picture. Around them sit \equiv (≡) for identity and for congruence modulo n, \propto (∝) for proportionality, \asymp (≍) for “of the same order”, and \doteq (≐), whose Unicode name is “approaches the limit” but which plenty of authors read as “is defined as”. Because \doteq and \asymp are read differently in different fields, say what you mean at first use.
| Command | Glyph | Meaning / use |
|---|---|---|
= | = | equality; type it directly — relation class |
\neq | ≠ | not equal; \ne is the same — plain LaTeX |
\equiv | ≡ | identically equal; congruence a \equiv b \pmod n |
\approx | ≈ | approximately equal; numeric \pi \approx 3.14 |
\sim | ∼ | equivalence relation, or “same order of magnitude” |
\simeq | ≃ | asymptotically equal; homeomorphic |
\cong | ≅ | congruent; isomorphic — built as \sim stacked on = |
\propto | ∝ | is proportional to |
\asymp | ≍ | of the same order (analysis, number theory) |
\doteq | ≐ | a dot over =; “approaches the limit” or “is defined as” |
Three of the symbols just listed do not exist in any font. Open fontmath.ltx and \cong turns out to be \mathrel{\mathpalette\@vereq\sim} — a \sim stacked on an = — while \doteq is \buildrel\textstyle.\over=, a period built over an equals sign, and \notin is \in with a slash overprinted. Knuth's Computer Modern simply did not contain those glyphs, so LaTeX assembles them at typesetting time. The trivia has a practical edge: assembled symbols shift slightly when you change math fonts, and they are not real characters in the PDF, so they do not survive copy-and-paste. If that matters — for accessibility, or for text readers will lift out — compiling with LuaLaTeX or XeLaTeX plus unicode-math and an OpenType math font turns \cong into the genuine character U+2245 and \doteq into U+2250.
\leq vs \leqslant: which shape of ≤ to use
They mean exactly the same thing; the difference is house style, and \leqslant costs you a package. \leq (≤) and \geq (≥) are plain LaTeX, and the short aliases \le and \ge point at the very same character. \leqslant (⩽) and \geqslant (⩾) come from amssymb, and draw the lower stroke slanted so that it runs parallel to the angle above it. Unicode treats the two shapes as separate code points — U+2264 “less-than or equal to” and U+2A7D “less-than or slanted equal to” — rather than as one character in two fonts, which tells you the preference is a real convention and not a whim. So decide once, for the whole document. On the same page, ≤ mixed with ⩽ simply reads as a typo.
For “much less than” and “much greater than” there are \ll (≪) and \gg (≫), also plain LaTeX. Each is a single symbol, not two < characters, so do not build them by hand. < and > you simply type — but only inside math mode. Write A<B>C in running text with the default OT1 font encoding and what comes out is A¡B¿C, because OT1 keeps an inverted exclamation and question mark at those two positions. When the order you mean is not numerical size — a partial order, a precedence, a refinement — the prec/succ family is the conventional choice: \prec (≺), \succ (≻) and the or-equal forms \preceq (⪯), \succeq (⪰), all standard. And if you have settled on slanted inequalities, do not retype them everywhere; one \let\leq\leqslant in the preamble converts the whole document and leaves your source readable.
| Command | Glyph | Meaning / use |
|---|---|---|
< | < | less than; type it directly in math mode |
> | > | greater than; in text mode it comes out as ¿ |
\leq | ≤ | less than or equal; \le is the same — plain LaTeX |
\geq | ≥ | greater than or equal; \ge is the same — plain LaTeX |
\ll | ≪ | much less than; a single symbol |
\gg | ≫ | much greater than; a single symbol |
\leqslant | ⩽ | slanted variant of ≤ — needs amssymb |
\geqslant | ⩾ | slanted variant of ≥ — needs amssymb |
\prec | ≺ | precedes; for an order that is not numerical size |
\preceq | ⪯ | precedes or equals; \succ ≻ and \succeq ⪰ mirror it |
\usepackage{amssymb} % \leqslant, \geqslant, \nleq, \nmid ...
% decide the shape once, in the preamble
\let\leq\leqslant
\let\geq\geqslant
\[ 0 \leq x \leq 1, \qquad n \ll N, \qquad a \prec b \preceq c \]Negating a relation: \neq, \not and amssymb
Use the dedicated command when one exists — \neq, \notin, and the amssymb family \nleq, \nmid, \nsubseteq — and fall back on \not only when none does. Here is the surprise, though: in standard LaTeX \neq is not a separate glyph at all. fontmath.ltx contains the line \DeclareRobustCommand\neq{\not=}, with \ne defined identically, so \not= and \neq produce byte-identical output. The familiar advice to “prefer \neq over \not=” is therefore about your source, not your PDF: \neq states the intent, survives a search, and is what a co-author expects to find. It also travels better to unicode-math, where \ne becomes the real character U+2260 instead of an overlay.
Where \not does fall down is on symbols it was never fitted to. It is a single character — slot "36 of the symbol font — laid over whatever follows at a fixed size, slope and position, tuned for signs about as wide as =. Over a wide relation the stroke falls short; over a tall or unusual one it cuts through the wrong part. Compare \not\leq with \nleq (≰), or \not\subseteq with \nsubseteq (⊈), and the purpose-drawn AMS glyphs win every time. \not stays genuinely useful for combinations nobody drew, though: there is no \nequiv, so x \not\equiv y \pmod p is the standard way to write a non-congruence. And note that \notin (∉) looks like an AMS symbol but needs no package at all.
| Command | Glyph | Meaning / package needed |
|---|---|---|
\neq | ≠ | not equal; plain LaTeX (it expands to \not=) |
\notin | ∉ | not a member; plain LaTeX (\in with a slash overprinted) |
\nleq | ≰ | not less than or equal; amssymb |
\ngeq | ≱ | not greater than or equal; amssymb |
\nsim | ≁ | not similar; amssymb |
\ncong | ≇ | not congruent / not isomorphic; amssymb |
\nsubseteq | ⊈ | not a subset; amssymb |
\nparallel | ∦ | not parallel; amssymb |
\nmid | ∤ | does not divide; amssymb |
\nprec | ⊀ | does not precede; amssymb |
Setting := properly and defining a relation of your own
For “is defined as”, load mathtools and write \coloneqq (≔) rather than typing :=. The trouble with the typed version is not spacing: LaTeX declares : as a relation and TeX puts nothing between two adjacent relations, so := comes out properly tight. The trouble is height. The character : is fetched from the text font, where its dots sit low, while = straddles the math axis — so the colon looks as though it slipped. mathtools supplies \coloneqq with the colon raised, its mirror \eqqcolon for =:, and a centercolon option that lifts every colon in the document. \coloneqq comes from mathtools, not from amssymb — when ! Undefined control sequence names \coloneqq, that mix-up is usually why.
To put something above a relation, \stackrel{\mathrm{def}}{=} is the classic. latex.ltx defines it as \mathrel{\mathop{#2}\limits^{#1}}, so whatever you stack, the result is a relation. amsmath's \overset does the same job but keeps the class of the base symbol instead of forcing a relation — which is what you want when the base is a binary operator; \underset handles the other side. And for any symbol you use more than twice, define it once and let the class travel with it: \newcommand{\divides}{\mathrel{|}} gives you a divides sign that always spaces correctly, and if you later change the glyph, every occurrence follows. That is this whole page in one line — never patch spacing with \, or \; at the point of use; declare the class and let TeX do the arithmetic.
\usepackage{mathtools} % \coloneqq and \eqqcolon (loads amsmath too)
\newcommand{\divides}{\mathrel{|}}
\[ f(x) \coloneqq x^2 + 1, \qquad y \eqqcolon g(t) \]
% \stackrel always yields a relation; \overset keeps the base class
\[ a \stackrel{\mathrm{def}}{=} b, \qquad a \overset{\mathrm{def}}{=} b \]
\[ 2 \divides 10, \qquad x \not\equiv y \pmod{p} \]