TransWikia.com

How to get my Vdots, Cdots and Ddots right with NiceMatrix

TeX - LaTeX Asked on June 23, 2021

I would like to create a matrix that consists of 9 blocks (3×3), and each block is 3×3 too. Within and between the blocks I need a lot of dots. Each block has Cdots, Vdots and Ddots, and these are also in the ‘middle’ blocks. I hope my example below will make this more clear. I have a MWE with an image of the output it creates, and an image on which I’ve highlighted how I’d expect the lines to be given my input.

documentclass{article}
usepackage{nicematrix}

begin{document}
begin{equation*}
tilde{Sigma}_w = begin{bNiceMatrix}
C[w_1,w_1] & Cdots & C[w_1,w_n] & & & & C[w_1,w_1^{(p)}] & Cdots & C[w_1,w_n^{(p)}] 
Vdots & Ddots & Vdots & Cdots & Cdots & Cdots & Vdots & Ddots & Vdots  
C[w_n,w_1] & Cdots & C[w_n,w_n] & & & & C[w_n,w_1^{(p)}] & Cdots & C[w_n,w_n^{(p)}] 
& Vdots && Ddots &&&& Vdots & 
& Vdots &&& Ddots &&& Vdots & 
& Vdots &&&& Ddots && Vdots & 
C[w_1^{(p)},w_1] & Cdots & C[w_1^{(p)},w_n] & & & & C[w_1^{(p)},w_1^{(p)}] & Cdots & C[w_1^{(p)},w_n^{(p)}] 
Vdots & Ddots & Vdots & Cdots & Cdots & Cdots & Vdots & Ddots & Vdots  
C[w_n^{(p)},w_1] & Cdots & C[w_n^{(p)},w_n] & & & & C[w_n^{(p)},w_1^{(p)}] & Cdots & C[w_n^{(p)},w_n^{(p)}]
end{bNiceMatrix}
end{equation*}
end{document}

Current output

Expected output. Red is wrong, green is missing:

Expected output

What am I doing wrong?

One Answer

Here is a solution.

documentclass{article}
usepackage{nicematrix}

begin{document}
begin{equation*}
tilde{Sigma}_w = begin{bNiceMatrix}
C[w_1,w_1] & Cdots & C[w_1,w_n] & & & & C[w_1,w_1^{(p)}] & Cdots & C[w_1,w_n^{(p)}] 
Vdots & Ddots & Vdots & Cdots & Cdots & Cdots & Vdots & Ddots & Vdots  
C[w_n,w_1] & Cdots & C[w_n,w_n] & & & & C[w_n,w_1^{(p)}] & Cdots & C[w_n,w_n^{(p)}] 
& Vdotsfor{3} & & & & & & Vdotsfor{3} 
& & & & Ddots & & & 

C[w_1^{(p)},w_1] & Cdots & C[w_1^{(p)},w_n] & & & & C[w_1^{(p)},w_1^{(p)}] & Cdots & C[w_1^{(p)},w_n^{(p)}] 
Vdots & Ddots & Vdots & Cdots & Cdots & Cdots & Vdots & Ddots & Vdots  
C[w_n^{(p)},w_1] & Cdots & C[w_n^{(p)},w_n] & & & & C[w_n^{(p)},w_1^{(p)}] & Cdots & C[w_n^{(p)},w_n^{(p)}]
end{bNiceMatrix}
end{equation*}
end{document}

Output of the above code

Remarks:

  • Unfortunately, the environments of nicematrix can't be nested (which would be useful in this situation). Maybe in a future version.
  • The dotted line drawn by Codts, Vdots, etc. are drawn between non-empty cells or the borders of the array. That's why it's difficult to draw the vertical dotted lines belonging to the main matrix.
  • However, there is a command Vdotsfor similar to Hdotsfor perfect for that job. In fact, as of now, this command was not documented in nicematrix because I was not sure of its utility. Now, I will documente it and it will remain in the future versions of the package :-)

Correct answer by F. Pantigny on June 23, 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