Not Equal in LaTeX (\neq)

≠\neq
LaTeX command
\neq
Package
No package needed: built into LaTeX
Mode
Math mode only
Copy the Unicode character
≠U+2260

Where it is used

Says two quantities are not equal; the negation of the equals sign.

\neq and its short alias \ne produce the same slashed equals sign, and either can be used. It appears in conditions like x \neq 0, in distinctness claims i \neq j, and in programming-oriented papers as the inequality test. Writing \not= also works but the slash placement can differ slightly from the dedicated glyph. In computer science writing, avoid typing != in math mode; it prints as an exclamation mark followed by an equals sign. For "not equivalent" or "not congruent", use \not\equiv or \ncong rather than \neq.

Also listed under: Relations & Comparisons, Computer Science

Minimal compilable example

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

f(x)=1x,x≠0f(x) = \frac{1}{x}, \quad x \neq 0
\documentclass{article}
\begin{document}
Not Equal: $\neq$

\[ f(x) = \frac{1}{x}, \quad x \neq 0 \]
\end{document}

Related symbols

All Math Symbols →

Frequently asked questions

How do I write Not Equal in LaTeX?
Type \neq in math mode, for example $f(x) = \frac{1}{x}, \quad x \neq 0$. It works in plain LaTeX without loading any package.
Which package do I need for \neq?
None. \neq is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use \neq in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\neq$ 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 poweredWrite LaTeX using AI

Best AI LaTeX Editor, Overleaf Alternative

Octree helps researchers from 15+ universities write research papers faster using AI

  • Generate beautiful TikZ diagrams using AI
  • Upload image and convert it to LaTeX seamlessly
  • Get instant assistance with writing and formatting research papers