How to change colour within equation? [duplicate]

I’m using article class, and I want to change colour within the equation tag, multiple times. I found that using mathmode I can change colour, but I want to use equation tag instead. After having the multicolour equation I will link the file to a beamer for a presentation.

Is this possible (successfully linking changed colours from article to beamer as well)? If so, how?

So in my imagination it must be like in the visual. The visual is from

$\color{yellow} A = \textcolor{blue}{B} \mathbin{\textcolor{red}{-}} \textcolor{green}{C}$


However, I need for example below. This doesn’t work for me.

$$\color{red}A=\color{blue}B-\color{green}C$$


marked as duplicate by AboAmmar, Phelype Oleinik, Troy, Stefan Pinnow, SebastianoMay 21 '18 at 20:11

• colour is the same in inline math \$ and in a display equation so it isn't clear what your question is? – David Carlisle May 21 '18 at 19:32