TransWikia.com

Problem with rowcolor command in nicematrix package

TeX - LaTeX Asked on August 11, 2021

I am having problems with the rowcolor command in nicematrix package. Here is a MWE.

documentclass{article}
usepackage{nicematrix}
begin{document}
We define the product (AB) by 
%Example 1
begin{equation}
    begin{bNiceMatrix}
        CodeBefore
        code-before=rowcolor{blue}{4}
        Body
        a_{11}&a_{12}&cdots&a_{1n}
        a_{21}&a_{22}&cdots&a_{2n}
        vdots&vdots&vdots&vdots
        a_{i1}&a_{i2}&vdots&a_{in}
        vdots&vdots&vdots&vdots
        a_{m1}&a_{m2}&cdots&a_{mn}
    end{bNiceMatrix}
end{equation}
%Example 2
$begin{pNiceMatrix}[r,margin]
    CodeBefore
    chessboardcolors{red!15}{blue!15}
    Body
    1 & -1 & 1 
    -1 & 1 & -1 
    1 & -1 & 1
end{pNiceMatrix}$

%Example 3
$begin{NiceArray}{lll}[hvlines]
    CodeBefore
    code-before = rowcolor{red!15}{1,3-5,8-}
    Body
    a_1 & b_1 & c_1 
    a_2 & b_2 & c_2 
    a_3 & b_3 & c_3 
    a_4 & b_4 & c_4 
    a_5 & b_5 & c_5 
    a_6 & b_6 & c_6 
    a_7 & b_7 & c_7 
    a_8 & b_8 & c_8 
    a_9 & b_9 & c_9 
    a_{10} & b_{10} & c_{10} 
    end{NiceArray}$
end{document}

First, I tried to compile the first example. I had texlive2020. It said the command CodeBefore is unknown. Then, I saw that nicematrix package date was July 15, 2021. So, I updated my texlive to 2021. The example compiles, but the output is not correct.

enter image description here

I tried some of the examples in the documentation in page 13. The chessboard example gives the correct output. But the NiceArray example does not give the correct output as seen in the figure. What could be the reason?

One Answer

In your first environement {bNiceMatrix}, you have written:

CodeBefore
   code-before=rowcolor{blue}{4}
Body

You should write

CodeBefore
   rowcolor{blue}{4}
Body

The construction CodeBefore - Body will put all its contents as value for the key code-before.

Correct answer by F. Pantigny on August 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP