# Any way to change color of \not

I often use command \not just to cancel off symbols in my equations and i would need an advice on how to change the color of this command.

-
Have a look at the cancel package manual and the disclaimer in the end. – percusse Jun 3 '12 at 20:44
Related Question: Diagonal strikeout starting too low and ending too high. – Peter Grill Jun 4 '12 at 0:31

Some similar command for obtaining colored \cancelto (some math package is probably missing)

\documentclass{article}
\usepackage{xcolor}
\usepackage{cancel}
\begin{document}
$\crossout[red]{\infty}{a^2} + \crossout[blue]{0}{b^2} = \crossout[green]{\infty}{c^2}$
\end{document}


-

As mentioned by percusse in the comments, it is better to use cancel package since \not can not strike out more than one variable (say (x+y)). You can define a macro to change the color of strike line as your need:

\documentclass{article}
\usepackage{xcolor}
\usepackage[thicklines]{cancel}
% \renewcommand*{\CancelColor}{\color{red}}%%if only one color is enough
\begin{document}
$\mynot{red}{\in}$
$(\mynot{green}{x+y})(x-y)$
$\mynot{black}{x+y}$
\mynot{blue}{This}  is  cancelled  out. % \cancel works in text mode also.
\end{document}


-
The OP does not seem to ask about canceling complete expressions but about negating single relation symbols. For this purpose \not is quite sufficient. Furthermore the author of »cancel« explicitly discourages users from using the package (at the very end of its manual). – Thorsten Donig Jun 5 '12 at 18:52

A very simple method would be to temporarily change the text color and then switch back to black. This can be done by a new command.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}

\newcommand*{\cnot}[1][black]{\color{#1}\not\color{black}}

\begin{document}
$\cnot[red]\in$
\end{document}


The new command takes an arbitrary color as optional argument.

-
\newcommand*{\cnot}[1][black]{\mathrel{\color{#1}\not}} would avoid restating the current color. – egreg Jun 3 '12 at 20:55
Even more, the "current color" might not be black. – lockstep Jun 3 '12 at 21:00
do you need fontenc as part of the MWE? – cmhughes Jun 3 '12 at 21:55
@egreg: Hm, I always forget things like \mathrel. – Thorsten Donig Jun 5 '12 at 18:46
@ThorstenDonig A casual user might think that T1 and fontenc are essential for the solution. – egreg Jun 5 '12 at 19:21