0

I want to display the following matrix (ignore the red box): enter image description here But all I can come up with is the following, which is not what I want beacuse of the diagonal and vertical dots: enter image description here

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!

1

1 Answer 1

3

This can be done with nicematrix. Note that you must compile twice.

The commands \Cdots, \Vdots and \Ddots should replace \cdots, \vdots and ddots 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 of 3ex.

enter image description here

\documentclass{article}

\usepackage{nicematrix}

\begin{document}
\[\begin{pNiceMatrix}
    2\alpha - 4u_{1}^{2} & -4u_{1}u_{2} & \Cdots && -4u_{1}u_{n} & -4u_{1}(v+1)\\
    -4u_{1}u_{2} & 2\alpha - 4u_{2}^{2} & \Cdots && -4u_{2}u_{n} & -4u_{2}(v+1)\\
    \Vdots & & \Ddots && \Vdots & \Vdots\\[3ex]
     -4u_{1}u_{n-1} & \Cdots && 2\alpha -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\alpha - 4u_{n}^{2} & -4u_{n}(v+1)\\
    -4u_{1}(v+1) & \Cdots && -4u_{n-1}(v+1) & -4u_{n}(v+1) & -2\alpha + 4(v+1)^{2}
\end{pNiceMatrix}\]
\end{document}
1
  • exactly what I wanted, thanks for your time! Commented May 7, 2022 at 12:35

You must log in to answer this question.

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