4
$\begingroup$

How to make each cell of Grid being a square?

Style[Grid[Partition[ToUpperCase[Alphabet[][[1 ;; 25]]], 5], 
  Frame -> All, Alignment -> {Center, Center}], 40]

enter image description here

$\endgroup$
1
  • 4
    $\begingroup$ ItemSize->{1,1} $\endgroup$ Sep 1, 2022 at 19:26

1 Answer 1

1
$\begingroup$

Jus for curiosity (I was not aware of ItemSize->{1,1} suggested by @Jean-Pierre) - a brute force method :-D.

It depends on increment of i, how precise you want to be. I chose 0.1 so probably not exact squares.

Clear[i]
grid=Style[Grid[Partition[ToUpperCase[Alphabet[][[1;;25]]],5],Frame->All,Alignment->{Center,Center},Spacings->{i,Automatic}],40];
i=0;
While[#[[1]]/#[[2]]&@ImageDimensions[Rasterize[grid]]<1,i=i+0.1]
i
grid
Clear[grid,i]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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