Notation field note

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

This guide to the not equal latex symbol covers the \neq command, the \not prefix, and when each approach best suits your mathematical or set-based expressions.

LaTeX provides two ways to typeset the not-equal symbol, which are both used for different reasons. The first is the \neq command, and the second is the \not prefix.

According to Mathnasium, the mathematical inequality sign “≠” means that the two values or expressions on either side of it are not the same. For example, 1 ≠ 2 means one is not equal to two. In other words, you can say this as “one is not equal to two.”

In a programming context, we often use an exclamation mark to denote that something is not true, like the != operator in C, which evaluates to true if the values on either side of the expression are not equal. Similarly, in pseudocode, we can write an assignment such as x ≠ y, where the statement will evaluate to true if x is not equal to y.

Two Ways to Create the Not-Equal Symbol

To create a not-equal symbol using LaTeX, we have two choices:

Use the \neq command. This creates a single slash across the equals sign, similar to how a question mark is created by placing a slash through the letter “n.” We can also add additional symbols using the \not command (discussed below) to modify how the stroke looks. As such, \neq is the primary method to produce the not-equal symbol.

Use the \not command to negate another relation when LaTeX does not already provide the symbol you need. For an equals sign, \not= produces a not-equal relation, although \neq is the conventional and clearer command.

When to Use \not

The \not command overlays a negation slash on the following relation. Do not write \not\neq as an alternative form of “not equal”: that attempts to negate an already-negated relation and can render a double or misplaced slash. Use \neq in ordinary work, and use \not with a positive relation only when the required negated symbol is otherwise unavailable.