# How to symmetricize this nxn Identity matrix

Consider the following code :


I=
\begin{bmatrix}
1 & 0 & 0 & \cdots & 0 & 0 \\
0 & 1 & 0 & \ddots & & \vdots \\
\vdots & \ddots & \ddots & \ddots & 0 & 0 \\
0 & \cdots & 0 & 1 & 0 & \vdots \\
\vdots & & & \ddots & \ddots & 0 \\
0 & \cdots & 0 & \cdots & 0 & 1
\end{bmatrix}


Which outputs this nxn Identity matrix :

The issue I have is that this matrix doesn't look quite symmetrical as I thought it should be, I hope someone can help me out fix this tiny issue that I have.

With nicematrix:

\documentclass{article}
\usepackage{nicematrix}

\begin{document}
$\begin{pNiceMatrix}[nullify-dots,xdots/shorten=4pt] 1 & 0 & & \Cdots & & 0 \\ 0 & 1 & \Ddots & & & \Vdots \\ \Vdots & \Ddots & \Ddots \\ \\ & & & & & 0 \\ 0 & \Cdots & & & 0 & 1 \end{pNiceMatrix}$
\end{document}


You need several compilations (because nicematrix uses PGF/Tikz nodes).

• Well noted! thank you – user232686 Jan 10 at 18:32
• I suppose that in answer you already use the version 5.9 ;-) . Your tempo of package development is incredible ... +1! – Zarko Jan 10 at 18:59
• @Zarko: Yes, I use version 5.9... (but for this answer, v. 3.13 is enough). – F. Pantigny Jan 10 at 20:02

One more with nicematrix:

\documentclass[12pt]{article}
\usepackage{nicematrix}

\begin{document}
$\mathbf{I} = \begin{bNiceMatrix} 1 & & \Block{2-3}<\huge>{0} \\ & 1 & & & \\ & & 1 & & \\ \Block{2-3}<\huge>{0} & & & \Ddots & \\ & & & & 1 \\ \end{bNiceMatrix}$
\end{document}

• I really love this package, I find it more aesthetic than the default matrices. – user232686 Jan 10 at 18:37

The problem is probably some package (or newcommand) you are using. You have too many dots in \cdots, \vdots and \ddots, and because that the symmetry is lost. In the following code I have your matrix (I_1, with just 3 dots per command) and another matrix I_2. The latter is what I'd do.

\documentclass{article}
\usepackage   {amsmath}

\begin{document}
$I_1=\begin{bmatrix} 1 & 0 & 0 & \cdots & 0 & 0 \\ 0 & 1 & 0 & \ddots & & \vdots \\ \vdots & \ddots & \ddots & \ddots & 0 & 0 \\ 0 & \cdots & 0 & 1 & 0 & \vdots \\ \vdots & & & \ddots & \ddots & 0 \\ 0 & \cdots & 0 & \cdots & 0 & 1 \end{bmatrix},\quad I_2=\begin{bmatrix} 1 & 0 & 0 & \cdots & 0 & 0 \\ 0 & 1 & 0 & \cdots & 0 & 0 \\ 0 & 0 & 1 & \cdots & 0 & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots\\ 0 & 0 & 0 & \cdots & 1 & 0 \\ 0 & 0 & 0 & \cdots & 0 & 1 \end{bmatrix}.$
\end{document}


It looks like this:

• I will take note, thank you very much for your answer sir! – user232686 Jan 10 at 18:32

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$I= \begin{bmatrix} 1 & 0 & 0 & \cdots & 0 \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots& & & \ddots & \\ 0 & 0 & 0 & \cdots & 1 \end{bmatrix}$
\end{document}

• thank you very much sir! – user232686 Jan 10 at 18:33