Not Equal in LaTeX

The not equal sign ≠ is \neq (or the shorter \ne) in math mode: $a \neq b$. To cross out another relation, put \not in front of it (\not\equiv gives ≢), or use a dedicated command such as \notin where one exists.

Not equal and other negations

  • \neq
    ≠

    Not equal ≠; \ne is identical.

  • \not=
    ≠

    The same sign built by overlaying a slash; \neq is preferred.

  • \not\equiv
    ≢

    Not equivalent / not congruent ≢.

  • \notin
    ∉

    Not an element of ∉.

  • \ncong
    ≇

    Not isomorphic / not congruent (amssymb).

  • \nsubseteq
    ⊈

    Not a subset of or equal to (amssymb).

  • \nleq
    ≰

    Not less than or equal to (amssymb).

  • \not\approx
    ≉

    Not approximately equal.

Try it live

Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.

Templates

Not equal sign examples

Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.

\neq, \ne or \not=?

All three print ≠. \neq and \ne are the same command; \not= builds the sign by placing a slash over =, which looks the same in the default font. Use \neq for readability.

\not works in front of any relation, but the slash is not always centered well. Where a dedicated negated symbol exists, it looks better: \notin rather than \not\in, and \nleq, \nsubseteq, \ncong from amssymb.

Not equal in code and on the web

Programming languages write "not equal" as != or <>, but in LaTeX those print as the literal characters. For a formula, always use \neq. When you need to show code itself, put it in \texttt{a != b} or a verbatim block.

Common mistakes

  • LaTeX prints != as an exclamation mark and an equals sign.

    Instead of
    a != b
    Write
    a \neq b
  • \not\in places the slash awkwardly; \notin is the purpose-made symbol.

    Instead of
    \not\in
    Write
    \notin
  • There is no standard \nequiv command. Negate \equiv with \not.

    Instead of
    \nequiv
    Write
    \not\equiv

In Overleaf, MathJax and Word

  • Overleaf and pdfLaTeX

    \neq, \ne, \not and \notin are built in. \ncong, \nleq and \nsubseteq need \usepackage{amssymb}.

  • MathJax and KaTeX

    MathJax and KaTeX render every command on this page without configuration.

  • Microsoft Word

    In a Word equation, \neq followed by Space inserts ≠ through Math AutoCorrect. Copy for Word from the editor here pastes whole formulas with the sign as an editable equation.

Not equal sign in LaTeX: questions

How do I write not equal to in LaTeX?
Use \neq or \ne in math mode: $x \neq y$.
How do I write not equivalent (≢)?
Use \not\equiv, for example a \not\equiv b \pmod{n}.
What is the difference between \neq and \not=?
In practice none: both print ≠. \neq is a single symbol and is easier to read in the source.
How do I write "not an element of"?
Use \notin: x \notin A.

Have the formula as a picture?

Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.

Convert an image to LaTeX