LatexNotes

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

\neq

Not 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 \neq

Examples

$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

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.

See also