# Highlighting in tabular environment

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 ?

\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}


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)

\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}$
&

• What about adding a different color onto specific elements of a matrix ? Jan 21 '14 at 17:21
• feature, you say? :-) Jan 21 '14 at 17:21
• Jan 21 '14 at 17:22
• @asd just use \cellcolor again. I added an example to the end of my answer. Jan 21 '14 at 17:24