I'd like to color individual columns in a 3x3 matrix created using \blockarray. I wish to give one color to the first column, and a second color to the 2nd and 3rd column. I found the answers two this question helpful, however, they do not seem to solve my problem.

However, I somehow cannot get the first answer using \columncolor from the xcolor package to work in this environment:

\usepackage{blkarray} % blockarrays; 


            a &\cdots & b\\
            cd &\cdots&N_\textnormal e\\


It throws the following error message:

! Undefined control sequence.
\BA@.[10002,1]u ...\BA@bdollar \hfil \columncolor
l.19 \end{align*}

The second answer using the package hf-tikz and \tikzmark is also not solving the issue, as it fails for column entries of different lengths.

Can someone help me getting this to work in the \blockarray environment?


I don't know how to solve the problem with \blockarray, but I think you can reach your desired result with a TikZ matrix of math nodes.

\usepackage{blkarray} % blockarrays; 

\usetikzlibrary{matrix, positioning}

    \node (A) {$\oint_{S^\textnormal{rec}}$};
        below=-2pt of A,
        inner xsep=0pt,
        matrix of math nodes,
            text width=1.2em, 
            text height=1.4ex,
            text depth=.5ex, 
        left delimiter={(},right delimiter={)},
        column 1/.style={nodes={fill={olive!20}}}
        ] {
        a &[6pt]\cdots &[6pt] b\\
        cd &\cdots&N_\textnormal e\\

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.