4

If I create a simple grid with Ctrl+, and paste a long piece of text outside the boxes (I'm sure you can find some yourself), then that text does not break at the width of the window in Mathematica. Instead, you have to scroll through it with a newly appeared scroll bar at the bottom.

How can this be fixed?

As an example, you can see bellow here how the word 'also' is getting cut off. I am typing this in, it is not the output of a cell:

try1

Really, my goal is to put text besides a picture.

So thanks to Kuba, here is an attempt to first create a Row which should WordWrap, and then turn that output cell into a text and TraditionalForm cell, and fill it in with my content: try2 However, you can see that this breaks the text indeed, but on a new line bellow the picture, I would like to get it alongside the picture.

Zlatko-Minev
  • 677
  • 4
  • 14

2 Answers2

3

I don't know any easy way to do what ask for, but a not-so-easy way is to edit to open the raw cell with Ctrl+Shift+E and, in the GridBox expression you find there, add the option GridBoxItemSize.

Cell[BoxData[
  GridBox[{
    {
     RowBox[{
     "The", " ", "quick", " ", "brown", " ", "fox", " ", "jumped", " ", "over", " ", "the", 
      " ", "lazy", " ", "dog"}], 
     RowBox[{
     "The", " ", "quick", " ", "brown", " ", "fox", " ", "jumped", " ", "over", " ", "the",
      " ", "lazy", " ", "dog"}]},
    {
     RowBox[{
     "The", " ", "quick", " ", "brown", " ", "fox", " ", "jumped", " ", "over", " ", "the", 
      " ", "lazy", " ", "dog"}], 
     RowBox[{
     "The", " ", "quick", " ", "brown", " ", "fox", " ", "jumped", " ", "over", " ", "the", 
     " ", "lazy", " ",  "dog"}]}
   }, 
     GridBoxDividers->{"Rows"->{{True}},"Columns"->{{True}}},
     GridBoxItemSize->{"Columns"->{{15}}}]], 
  "Text"]//DisplayForm

grid.png

Note 1: the postfix // DisplayForm is only there because I found it convenient to work this out in an input cell. Don't use it when you editing the raw cell.

Note 2: In your case, you probably want GridBoxItemSize -> {"Columns" -> {Automatic, 15}}. At least, that is the setting I would try as a first approximation.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
2

I don't understand exactly what you want, but Grid does wrap. Here is an example:

longtext = StringJoin@RandomChoice[CharacterRange[" ", "z"], 500];
img = ImageResize[ExampleData[{"TestImage", "Lena"}], 200];
Grid[
 {{Image[img, ImageSize -> All], longtext}},
 Alignment -> {Center, Top}
]

The ImageSize->All ensures that the image doesn't get resized.

output

ssch
  • 16,590
  • 2
  • 53
  • 88
  • OP is not using Grid, but grid with Ctrl+Enter/Ctrl+, then it just an array formated to GridBox. – Kuba Sep 20 '13 at 01:15