2

I would like to create a matrix that consists of 9 blocks (3x3), and each block is 3x3 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?

1 Answer 1

2

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 :-)
2
  • Perfect! Once again, thank you for your super fast assistance! I'm glad I could show you the need for a command I didn't know existed ;).
    – Iris
    Jul 30, 2020 at 13:27
  • Very perfect! 😉
    – Sebastiano
    Jul 31, 2020 at 12:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .