TransWikia.com

How to symmetricize this nxn Identity matrix

TeX - LaTeX Asked by user232686 on June 28, 2021

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.

4 Answers

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

Correct answer by F. Pantigny on June 28, 2021

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}

Answered by gernot on June 28, 2021

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

Answered by Juan Castaño on June 28, 2021

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}

Answered by Zarko on June 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP