[Tex/LaTex] Matrix change row or column background

backgroundscolorcolortblmatrices

I have a matrix shown below. I would like to have the whole row green rather than only the cells.

How can I do that?



The output is:

You can use \rowcolor, \columncolor, and \cellcolor from the colortbl package, loaded in my example through the xcolor package:

\documentclass{article}
\usepackage{amsmath}
\usepackage[table]{xcolor}

\newcommand\x{\times}
\newcommand\y{\cellcolor{green!10}}

\begin{document}

$$\label{eq:appendrow} \left(\begin{array}{cccc} \rowcolor{red!20} \x & \x & \x & \x \\ 0 & \x & \x & \x \\ \rowcolor{blue!20} 0 & 0 & \x & \x \\ 0 & 0 & 0 & \x \\ \y a & b & \y c & d\\ \end{array}\right)$$

$$\left(\begin{array}{>{\columncolor{olive!20}}cc>{\columncolor{yellow!20}}cc} \x & \x & \x & \x \\ 0 & \x & \x & \x \\ 0 & 0 & \x & \x \\ 0 & 0 & 0 & \x \\ a & b & c & d \\ \end{array}\right)$$

\end{document}