Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I was wondering what the best way is to extend the cells in a GraphicsGrid so that my text fits without line breaks. My problem is illustrated by the graphic produced by the code below:

GraphicsGrid[{
  {Graphics[{Blue, Rectangle[{1, -1}]}], 
   Style["Antidisestablishmentarianism", FontSize -> 30], 
   SpanFromLeft},
  {Graphics[{Red, Rectangle[{1, -1}]}], 
   Style["Pneumonoultramicroscopicsilicovolcanoconiosis", FontSize -> 30],
   SpanFromLeft}}]`

enter image description here

I've been looking for ways to extend the cells on the right of the GraphicsGrid so that the text fits in on one line. In the code above, I've used SpanFromLeft to extend the cells a little. I would have to use many SpanFromLeft commands in order to fit the word next to the red square. So I was hoping that someone knew of a better way of doing this.

share|improve this question
    
yes, but then I can't control image size, and I need to do that –  Mas May 12 at 12:13
    
To clear things up, I meant the size of the whole Grid. Essentially what I want is for the cells on the right hand side to be wider; just wondering if there's a better way of doing this than repeated SpanFromLeft's –  Mas May 12 at 12:54

1 Answer 1

up vote 3 down vote accepted

Tell me if that fits you:

grid = Grid[
 {
  {Graphics[{Blue, Rectangle[{1, -1}]}, ImageSize -> 100], 
   Style["Antidisestablishmentarianism", FontSize -> 30], SpanFromLeft}, 
  {Graphics[{Red, Rectangle[{1, -1}]}, ImageSize -> 100], 
   Style["Pneumonoultramicroscopicsilicovolcanoconiosis", FontSize -> 30], SpanFromLeft}
 }, ItemSize -> {{10, 60}}]

Then taking that answer:

Show[First@
  ImportString[ExportString[#, "PDF"], "TextOutlines" -> True] &@ grid,
  ImageSize -> 100]

enter image description here

Then ImageSize can be used as will:

enter image description here

share|improve this answer
    
That would work. I was kind of hoping there was a simple autofit option –  Mas May 12 at 13:02
    
The text autofits with Grid. Using the Show[] part allows you to change the ImageSize. –  Öskå May 12 at 13:03
1  
@Öskå After applying ImportString[ExportString[#, "PDF"]] & you have no text: every glyph is outlined. It is the standard way to outline fonts in Mathematica. –  Alexey Popkov May 12 at 13:41
    
@AlexeyPopkov I don't get if this is a problem or not.. :) –  Öskå May 12 at 13:47
1  
@Max Check What should I do when someone answers my question? and Accepting Answers: How does it work? regarding accepting answers. That concerns your two last questions with valuable answers. –  Öskå May 12 at 23:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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