4

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 : enter image description here

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.

2

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).

Output of the above code

3
  • 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
2

One more with nicematrix:

enter image description here

\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}
1
  • I really love this package, I find it more aesthetic than the default matrices. – user232686 Jan 10 at 18:37
1

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: enter image description here

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

enter image description here

\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}
1
  • thank you very much sir! – user232686 Jan 10 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.