How to put a different background color for different terms in one single equation. Below is the example I tried. I need boxed term in the equation to have a background of green, the second term with magenta, and the last term to be a yellow background. how to achieve this. The expected result looks like the last equation.
\documentclass{article}
\pagestyle{empty}
\usepackage{amsmath}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\documentclass{article}
\pagestyle{empty}
\usepackage{amsmath}
\usepackage{empheq}
\usepackage{xcolor}
\definecolor{lightgreen}{HTML}{90EE90}
\newcommand{\boxedeq}[2]{\begin{empheq}[box={\fboxsep=6pt\fbox}]{align}\label{#1}#2\end{empheq}}
\newcommand{\coloredeq}[2]{\begin{empheq}[box=\colorbox{lightgreen}]{align}\label{#1}#2\end{empheq}}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\begin{document}
\begin{subequations}
\begin{align}
\mathcal{\bar{L}}&=\boxed{\textcolor{red}{\frac{\beta^4}{2}\left(\int_{0}^{1}\,\hspace{-0.05in} \left( \psi(\eta)\right)^2 \diff\eta + \sum_{j=1}^{n} \gamma_{j}^3\, \int_{0}^{\gamma_{j}} \hspace{-0.05in} \left( \chi_{j}(\xi)\right)^2 \diff\xi \right)}}-\nonumber \\ &\quad \textcolor{blue}{\frac{1}{2}\,\left(\int_{0}^{1} \hspace{-0.05in} \left(\frac{\partial^2\psi(\eta)}{\partial \eta^2}\right)^2 \diff\eta +\sum_{j=1}^{n}\alpha_{j}\, \int_{0}^{\gamma_{j}}\left(\frac{\partial \chi_{j}(\xi)}{\partial \xi}\right)^2 \diff\xi \right)}+\nonumber \\ &\quad \sum_{j=1}^{n}\lambda_{j}^{*}\left(\psi(\zeta_{j})-\chi_{j}(\gamma)\right) \nonumber
\end{align}
\end{subequations}
\coloredeq{eq:second}{c_i = \langle\psi|\phi\rangle}
\end{document}