4
$\begingroup$

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.

$\endgroup$
9
  • $\begingroup$ Something like Grid[{{"kkkkkkkk"}, {"mmmmmm"}}, Frame -> All, ItemSize -> 10]? $\endgroup$ Sep 19, 2013 at 22:20
  • $\begingroup$ I just updated the question. what you say works for a grid, but this thing I think is a GridBox and it doesnt have ItemSize $\endgroup$ Sep 19, 2013 at 22:35
  • $\begingroup$ your grid // Grid[#, ItemSize -> 5] & $\endgroup$
    – Kuba
    Sep 19, 2013 at 22:36
  • $\begingroup$ 2D input is handy but you have less control, please take a look at links in this Q&A $\endgroup$
    – Kuba
    Sep 19, 2013 at 22:38
  • $\begingroup$ @Kuba, Its a text cell, so I can't execute it? $\endgroup$ Sep 19, 2013 at 22:40

2 Answers 2

2
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ OP is not using Grid, but grid with Ctrl+Enter/Ctrl+, then it just an array formated to GridBox. $\endgroup$
    – Kuba
    Sep 20, 2013 at 1:15
3
$\begingroup$

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.

$\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.