How to write the equal or not equal symbol in LaTeX?

How to write the equal or not equal symbol in LaTeX?

This post may contain affiliate links that allow us to earn a commission at no expense to you. Learn more

This article aims to show you the simplest and easiest way to write the equal or not equal symbol in LaTeX.

A very common symbol used in mathematics and computer programming, with many more uses in spelling, linguistics and chemistry. Today you will learn how to insert it in your LaTeX document.

Equal or not Equal Symbols

Either called equal sign, equality sign, or equal symbol, is primarily used in mathematics to indicate an equality in a well-defined context, let’s say for example that two things are equivalent between them. It is represented by two horizontal parallel lines that place between the values,

Usually in math we used the equal sign in equations to denote that two things are equals. We can also call this equality, a relation between two values.

In case the equality is false -the two things are not equivalent- we used the not equal symbol/sign, it looks like the equal sign but instead of only two horizontal lines, it has a diagonal slash between the two lines.

Equal or not Equal Symbol in LaTeX

To write the equal symbol in LaTeX you don’t need any command, it is already written in your keyboard, using the “=” you get the desired symbol. Either in math mode or text mode, it works the same.

\documentclass{article}
\begin{document}
\begin{center}
Equal symbol in text mode: 1=1 \\
Equal symbol in math mode: $a=b$
\end{center}
\end{document}


Note: notice the difference in spacing between math mode and text mode.

Now regarding the not equal symbol, this time we don’t have such luck. The main difference between the “not equal to” and the “equal to” symbols is the former requires math mode, the latter does not.

To write it in LaTeX we have two commands we can use, either \neq or \ne, both work fine and generate the same symbol.

\documentclass{article}
\begin{document}
\begin{center}
Not equal symbol \verb|\neq|: $x \neq y$ %two variables are not equal \\
Not equal symbol \verb|\ne|: $42 \ne 41$ %two numbers are not equal
\end{center}
\end{document}


Going the extra mile, sometimes you may need to write the equal sign but with some add on above or below the parallel lines; to do so you need to load the amssymb package. You can see the generated symbols in the following example,

\documentclass{article}
\usepackage{amssymb}
\begin{document}
Some variations can be \\
- A dot above: $a \doteq b$ \\
- A triangle above: $a \triangleq b$ \\
- A circle above: $a \circeq b$
\end{document}


Now you have the knowledge to write these useful and super common symbols in your documents with multiple methods and options. In case you wonder whether some variation of this symbol exists, look in the amssymb documentation or on the internet, don’t be shy to ask.

I hope this post was helpful, by writing you gain more confidence and get more experience, practice makes perfect. Keep writing in LaTeX and until next time.

All images were created in LaTeX by the author.