[Tex/LaTex] Highlighting in tabular environment

highlightingmatricestables

I am trying highlight a row of matrices in a tabular environment. However, the left brackets of the matrices are gone. And I don't know how to fix this.

In addition, how can I highlight 2 elements within a matrix, i.e. highlight "… & \vec{v}_n" ? How can this be done ? picture

\documentclass{article}

\usepackage{amsmath, colortbl}

\begin{document}
\begin{center}
\setlength{\tabcolsep}{0pt}
\begin{tabular}{c c c c c}
\rowcolor{yellow}
$A$
&
$\begin{bmatrix}
&&&&\\
\vec{v}_1 &\cdots &\vec{v}_r & \cdots & \vec{v}_n\\
&&&&
\end{bmatrix}
$
&
$=$
&
$\begin{bmatrix}
&&&&\\
\vec{u}_1 &\cdots & \vec{u}_r & \cdots& \vec{u}_m\\
&&
\end{bmatrix}$
&
$
\begin{bmatrix}
\sigma_1 &&&\\
&\ddots&&\\
&& \sigma_r&\\
&&&
\end{bmatrix}
$\\
$(m \times n)$
&
$(n \times n)$
&
&
$(m \times n)$
&
$(m \times n)$
\end{tabular}
\end{center}
\end{document}

Best Answer

That's an interesting feature.....

\cellcolor works better (and by using \cellcolor on just some of the cells you can highlight smaller parts of the display)

enter image description here

\documentclass{article}

\usepackage{amsmath, colortbl}

\begin{document}
\begin{center}
\setlength{\tabcolsep}{0pt}
\begin{tabular}{c c c c c}
\cellcolor{yellow}
$A$
&
\cellcolor{yellow}
$\begin{bmatrix}
&&&&\\
\vec{v}_1 &\cdots &\vec{v}_r & \cdots & \vec{v}_n\\
&&&&
\end{bmatrix}
$
&
\cellcolor{yellow}
$=$
&
\cellcolor{yellow}
$\begin{bmatrix}
&&&&\\
\vec{u}_1 &\cdots & \vec{u}_r & \cdots& \vec{u}_m\\
&&
\end{bmatrix}$
&
\cellcolor{yellow}
$
\begin{bmatrix}
\sigma_1 &&&\\
&\ddots&&\\
&& \sigma_r&\\
&&&
\end{bmatrix}
$\\
$(m \times n)$
&
$(n \times n)$
&
&
$(m \times n)$
&
$(m \times n)$
\end{tabular}
\end{center}
\end{document}

You can use \cellcolor also on the nested matrix:

&
\cellcolor{yellow}
$\begin{bmatrix}
&&&&\\
\vec{u}_1 &\cdots &\cellcolor{blue} \vec{u}_r & \cdots& \vec{u}_m\\
&&
\end{bmatrix}$
&
Related Question