I want to display the following matrix (ignore the red box):
But all I can come up with is the following, which is not what I want beacuse of the diagonal and vertical dots:
I want the vertical dots to be more "centered" with no gap between the two segments, and the diagonal dots to be on the same line.
Here's the code for the matrix:
\begin{pmatrix}
2\al - 4u_{1}^{2} & -4u_{1}u_{2} & \cdots & -4u_{1}u_{n} & -4u_{1}(v+1)\\
-4u_{1}u_{2} & 2\al - 4u_{2}^{2} & \cdots & -4u_{2}u_{n} & -4u_{2}(v+1)\\
\vdots & \ddots & & \vdots & \vdots\\
\vdots & & \ddots & \vdots & \vdots\\
-4u_{1}u_{n-1} & \cdots & 2\al -4u_{n-1}^{2} & -4u_{n-1}u_{n} & -4u_{n-1}(v+1)\\
-4u_{1}u_{n} & \cdots & -4u_{n-1}u_{n} & 2\al - 4u_{n}^{2} & -4u_{n}(v+1)\\
-4u_{1}(v+1) & \cdots & -4u_{n-1}(v+1) & -4u_{n}(v+1) & -2\al + 4(v+1)^{2}
\end{pmatrix}
Thanks for your help!
Best Answer
This can be done with
nicematrix
. Note that you must compile twice.The commands
\Cdots
,\Vdots
and\Ddots
should replace\cdots
,\vdots
andddots
respectively. These commands will continue the dots through empty cells, so a few extra&
s are needed. Also, instead of a row of&
s to get the space in the middle, just use\\[<length>]
to end the previous row. I used a length of3ex
.