Not equal (≠) in LaTeX
\neq produces the not-equal-to relation, stating that two expressions are different. It is written as a binary relation between them, and \ne is an identical shorthand.
LaTeX command
\neqNot the symbol you meant? Draw it to find the command →
The command \neq (or the alias \ne) renders the equals sign with a slash through it. Use it in conditions, definitions and set-builder notation, for example to exclude zero. The ASCII != from the keyboard does not work; it prints an exclamation mark followed by an equals sign.
Internally \neq is exactly \not=, the equals relation with \not layered on top. You can negate other relations the same way (\not\subset, \not<), but always prefer a dedicated command where one exists, such as \notin for the not-an-element sign or \nmid for does-not-divide.
Keep it distinct from other 'not' relations: 'not identical' negates \equiv (as \not\equiv), and approximately-not-equal lives in amssymb. \neq itself needs no package in either LaTeX or KaTeX.
Other forms
\nealias for \neqExamples
$a \neq b$a is not equal to b
$x \neq 0$excluding zero
$\{x \in \mathbb{R} : x \neq 0\}$set-builder with a restriction
$1 + 1 \neq 3$a false-arithmetic example
$f(x) \neq g(x)$two functions differ
Tips and common mistakes
- Use
\neqor\ne; do not type the ASCII != which renders with no relational spacing. \neqis literally\not=, so you can negate other relations with\not, e.g.\not\subset.- Prefer purpose-built negations where they exist:
\notinfor the not-element sign,\nmidfor does-not-divide. - Do not confuse not-equal with not-identical; the latter is
\not\equiv, since identity uses\equiv. - For other negated relations (not-congruent, not-approx) load amssymb, which adds
\ncongand friends.
Working from handwritten notes?
LatexNotes turns a photo or PDF of handwritten mathematics into clean, compilable LaTeX - graphs and all. Free to try, no sign-up.
Convert your maths to LaTeX →FAQ
How do I type the not equal sign in LaTeX?
Use \neq or \ne in math mode: . No package is required.
Is there a difference between \ne and \neq?
No. They are aliases producing the identical sign; use whichever you find clearer.
How do I negate other relation symbols?
Prefix them with \not, for example \not\subset or \not<, but use dedicated commands when they exist, such as \notin and \nmid.