[Tex/LaTex] Any way to change color of \not

amsmathcolormath-operators

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.

Best Answer

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

\documentclass{article}
\usepackage{xcolor}
\usepackage{cancel}
\newcommand\crossout[3][black]{\renewcommand\CancelColor{\color{#1}}\cancelto{#2}{#3}}
\begin{document}
  $\crossout[red]{\infty}{a^2} +   \crossout[blue]{0}{b^2}  =   \crossout[green]{\infty}{c^2} $
\end{document}

result