2
$\begingroup$

In a previous question I asked how to align a couple of graphics, each of which had three columns.

img1 = First[
Import["https://en.wikipedia.org/wiki/Georges_Cuvier#/media/File:\
Georges_Cuvier.png",  "Images"]];
text1a = Text[
Style[ToString["Jean Léopold Nicolas Frédéric Cuvier"], Bold, 22]];
text1b = Text[
Style[ToString["(23 August 1769 - 13 May 1832)"], Bold, 16]];
col1 = Column[{
img1,
text1a, text1b}, Center]; disk = 
Graphics[{Black, Disk[{0, 0}, {5, 8}]}]; img2 = 
First[Import[
"https://en.wikipedia.org/wiki/Achille_Valenciennes#/media/File:\
Achille_Valenciennes01.jpg", "Images"]];
text2a = Text[Style[ToString["Achille Valenciennes"], Bold, 22]];
text2b = Text[
Style[ToString["(9 August 1794 - 13 April 1865)"], Bold, 16]];  

To which MarcoB kindly added the following suggestion that I was able to use to bring the images and text into alignment.

 Grid[
 Transpose@{
 {ImageResize[img1, 500], text1a, text1b}, 
 {ImageResize[img2, 500], text2a, text2b}},
 ItemSize -> {30, Automatic}
 ]

Unfortunately, short of generating two or three separate Grid commands like the one above to place in a second row of similar figures and text, I can not seem to find the correct formulation of grouping constructs (ie {}) to bring a create a table of 4 or perhaps 6 similar figures (ie. for this code assume that Cuvier and Valenciennes have instead figures and data for someone else in a row below the first row).

Not sure if I need multiple Transpose statements for each line or the correct structure of list configuration using {}'s. Tried multiple possibilities but none seem to permit me to place a 2x2 or 2x3 grid of {image,text,text} elements with a single command. Placing in a single command is essential so that the entire code block can be made invisible within a slide show so that only the output is visible. There must be a similar simple solution, but I must be overlooking something in attempting to construct it.

Again thanks in advance for the tutelage. More complex examples within the grid command documentation would be of help.

$\endgroup$
1
$\begingroup$

This is clumsy, but it works in a pinch. I'm thinking ArrayReshape might be your friend here, but I've gotta run to class.

Grid[
 Partition[#, 2] &@ (* 2 is number of desired columns *)
  (
   Column[#, Alignment -> Center] & /@
    {{ImageResize[img2, 500], text2a, text2b}, 
     {ImageResize[img2, 500], text2a, text2b}, 
     {ImageResize[img2, 500], text2a, text2b}, 
     {ImageResize[img2, 500], text2a, text2b}}
   )
 ]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Being in a pinch. I'll run with this and explore ArrayReshape later. If you have additional thoughts this would be great. Not sure why simply embedding the previous @Transpose[etc] construct within {} doesn't work. Thanks again. $\endgroup$ – Stuart Poss Nov 15 '16 at 0:27

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.