Imagine you’re working with some mathematical expressions in LaTeX, and suddenly you find yourself needing to show that an element is not part of a set. At this moment, the question pops up in your mind – “How do I write this ‘not in’ symbol in LaTeX?”
Don’t worry! I’m here to help you. Today, I’ll show you how to solve this problem easily using some small but very useful LaTeX commands.
Using the \notin command
The simplest and most commonly used way is with the \notin
command. This command creates the ∉ symbol quickly, which is widely used to show that an element is not in a set.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
This symbol in inline math mode: \(5 \notin \{1, 2, 3\} \)
\[ x \notin S \]
\end{document}
Output:
Here, \(5 \notin \{1, 2, 3\}\)
displays in inline mode, while [ x \notin S ]
displays in larger format in display mode. In short, this command is easy to use and covers most cases.
Using \not and \in together
If you want, you can use \not\in
instead of \notin
. This combines the \not
and \in
commands, where \not
adds a diagonal slash over the symbol. Here’s how the code looks:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ \notin \quad \not\in\]
\[ x \not\in S \]
\end{document}
Output:
This looks exactly like \notin
, but here \not
and \in
are written separately.
Using cancel command
Want to make it a bit more unique? Then you can use the cancel
package to add a diagonal strike through the \in
symbol.
This adds a visual effect and is especially useful for complex expressions.
\documentclass{article}
\usepackage{cancel}
\begin{document}
\[ x \,\cancel{\in} \,S \]
\[ 5 \,\cancel{\in} \, \{1, 2, 3\} \]
\end{document}
Output:
Here, x \cancel{\in} S
will produce the output with a strike-through on \in
, showing that x
is not a member of set S
.
Conclusion
In LaTeX, there are several ways to write the not in symbol. The simplest and most common way is using \notin
, which gives you the ∉ symbol directly.
Alternatively, you can use \not\in
or \cancel{\in}
to create variations that add a unique look to your document and make your expressions even more attractive.