Notation field note

Not Equal LaTeX Symbol: How to Typeset ≠ in Your Documents

This guide to the not equal LaTeX symbol explains how to use \neq and \not commands, plus typographic variants for customizing the ≠ appearance in your documents.

In mathematics, the not-equal symbol means that two values or expressions are not the same. The standard mathematical symbol for this is ≠, which can be typeset in a LaTeX document using either the \neq command or the \not command.

The \neq command typesets the not-equal symbol in a LaTeX document and is used to negate equality. In pseudocode, it serves as the equivalent of != in C. Pseudocode writers coming from programming backgrounds might prefer the \neq command over the \not prefix command to negate an equality expression. This Stack Exchange question addresses how to create a not-equal symbol with the LaTeX command.

Alternative constructions and typographic variants

While there’s no need to choose between these commands, you can also create not-equal variants by negating an equality symbol using the \not command, as described in the following article.

Typographically, the stroke-matched variant has advantages. It uses a vertical bar to match the slanted stroke of the equality symbol, but other options are possible, including a combination of \not and \varnothing. A Stack Exchange thread discusses the vertical-bar variant.

To use the \not command, place it before a relation symbol, such as =, <, >, etc., which will negate the symbol. You can use this alternative construction if the default \neq doesn’t satisfy your typographic requirements.

When and why would a writer choose one variant over another? According to a community-explored construction (the so-called “vertical-bar” variant), a typographer might want a symbol that visually matches the rest of the text, particularly when creating a custom symbol.