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
\neqNot equal ≠;
\neis identical.\not=The same sign built by overlaying a slash;
\neqis preferred.\not\equivNot equivalent / not congruent ≢.
\notinNot an element of ∉.
\ncongNot isomorphic / not congruent (amssymb).
\nsubseteqNot a subset of or equal to (amssymb).
\nleqNot less than or equal to (amssymb).
\not\approxNot 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.
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.
Condition
LaTeXf(x) = \frac{1}{x}, \quad x \neq 0Non-trivial solution
LaTeX\mathbf{v} \neq \mathbf{0}Not congruent
LaTeX7 \not\equiv 1 \pmod{4}Not an element
LaTeX\sqrt{2} \notin \mathbb{Q}Not isomorphic
LaTeX\mathbb{Z}_4 \ncong \mathbb{Z}_2 \times \mathbb{Z}_2Distinct points
LaTeXx_i \neq x_j \quad \text{for } i \neq j
\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 ofa != bWritea \neq b\not\inplaces the slash awkwardly;\notinis the purpose-made symbol.Instead of\not\inWrite\notinThere is no standard
\nequivcommand. Negate\equivwith\not.Instead of\nequivWrite\not\equiv
In Overleaf, MathJax and Word
Overleaf and pdfLaTeX
\neq,\ne,\notand\notinare built in.\ncong,\nleqand\nsubseteqneed\usepackage{amssymb}.MathJax and KaTeX
MathJax and KaTeX render every command on this page without configuration.
Microsoft Word
In a Word equation,
\neqfollowed 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
\neqor\nein math mode:$x \neq y$. - How do I write not equivalent (≢)?
- Use
\not\equiv, for examplea \not\equiv b \pmod{n}. - What is the difference between \neq and \not=?
- In practice none: both print ≠.
\neqis a single symbol and is easier to read in the source. - How do I write "not an element of"?
- Use
\notin:x \notin A.
Related LaTeX reference
- Greater Than or Equal to in LaTeXGreater than or equal to (\geq), less than or equal to (\leq), plain < and >, much less than, slanted and negated forms.
- Approximately Equal in LaTeX\approx for ≈, plus \sim, \simeq, \cong and \equiv, with what each symbol means.
- Element of Symbol (∈) in LaTeX\in for ∈, \notin for ∉, \ni for ∋, and how ∈ differs from the Greek letter epsilon.
- LaTeX equation editorSymbol panel, live preview, and PNG, SVG, MathML or Word export.
- All LaTeX reference pagesSymbols, math structures and text formatting in one list.
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