2

\begin{block}{|ccc|} is not working while using cellcolor

\documentclass[10pt,dvipsnames,svgnames]{beamer}
\setbeamertemplate{navigation symbols}{}
\usepackage{amsmath,mathtools}
\usepackage{colortbl}
\usepackage{blkarray}
\newcommand\y{\cellcolor{green!20}}

\begin{document}
%
\begin{frame}
%
\begin{align*}
\begin{blockarray}{ccc}
\begin{block}{|ccc|}
1 & 2 & 3 \\
1 & 2 & 3 \\
1 & 2 & 3 \\
\end{block}
C_1 & C_2 & C_3 \\
\end{blockarray}
%
=
%
\begin{blockarray}{ccc}
\begin{block}{|ccc|}
1 & \multicolumn{1}{c}{\cellcolor{blue!10}2} & 3 \\
1 & 2 & 3 \\
1 & \multicolumn{1}{c}{\y 2} & 3 \\
\end{block}
C_1 & C_2 & C_3 \\
\end{blockarray}
\end{align*}
%
\end{frame}
\end{document}

enter image description here

  • You could just replace the = by \begin{blockarray}{c} \begin{block}{c} \\ =\\ \\ \end{block} \\ \end{blockarray}. – user121799 Nov 30 '18 at 5:22
2

To answer the question: use \makecell. And I also added an ad hoc method to center the = sign.

\documentclass[10pt,dvipsnames,svgnames]{beamer}
\setbeamertemplate{navigation symbols}{}
\usepackage{amsmath,mathtools}
\usepackage{colortbl}
\usepackage{blkarray}
\usepackage{makecell}
\newcommand\y{\cellcolor{green!20}}

\begin{document}
%
\begin{frame}
%
\begin{align*}
\begin{blockarray}{ccc}
\begin{block}{|ccc|}
1 & 2 & 3 \\
1 & 2 & 3 \\
1 & 2 & 3 \\
\end{block}
C_1 & C_2 & C_3 \\
\end{blockarray}
%
\begin{blockarray}{c}
\begin{block}{c}
\\
=\\
\\
\end{block}
 \\
\end{blockarray}
%
\begin{blockarray}{ccc}
\begin{block}{|ccc|}
1 & \makecell{\cellcolor{blue!10}2} & 3 \\
1 & 2 & 3 \\
1 & \makecell{\y 2} & 3 \\
\end{block}
C_1 & C_2 & C_3 \\
\end{blockarray}
\end{align*}
%
\end{frame}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.