I'm taking the next step in my learning of LaTeX and starting to explore the possibility of creating custom environments; however, the resources I've consulted don't mention how to create an environment like the bmatrix environment that does not have a pre-defined number of arguments.
In particular, I'd like to define a variant of bmatrix (and similar) that allows me to colour the rows / columns.
Ideally, I'd like to figure out a way to define the environment so that I can:
- specify the colour of each row / column at the opening of the environment (or at the first element of the row / column). E.g. if
\ca,\cband\ccare macros for different colours, then something like\begin{cbmatrix}{\ca \ca \cb}would start abmatrixenvironment where the entries in the first row will each be wrapped in\ca, similarly for the second row, and the entries of the third row would be wrapped incb,
i.e. the desired output would be equivalent to:
\begin{bmatrix} \ca{e1} & \ca{e2} & \ca{e3} & \ca{e4} \\ \ca{e5} & \ca{e6} & \ca{e7} & \ca{e8} \\ \cb{e9}& \cb{e10} & \cb{e11} & \cb{e12} \\ e13 & e14 & e15 & e16 \end{bmatrix} - easily switch between applying the colour command to rows or columns (perhaps with a starred version of the environment)?
I realize this is a very specific end-result, but I'm generally curious to know where to begin to be able to define this type of environment, where the number of inputs / arguments isn't predefined?

\begin{array}{*{10}{c}}\rowstylethat takes the cell contents as an argument.bmatrixwas limited to 10 (never had a larger array, I guess). So it just ignores unused columns?