Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am regularly annoyed by the fact, that a neatly arranged Print statement gets ruined by a large piece of data, which - instead of linewrapping "in place" - is pushed below the preceding label. See example:

  "test line 1...............: ", {1, 2, 3}, "\n",
  "test line 2...............: ", 
  Pane[Table["testestestestestestestestest", {10}], 800], "\n",
  "test line 3...............: ", {1, 2, 3}

which produces the following output:

Mathematica graphics


Is it possible to tell the Pane object to wrap its content in a way that does not force the Table to shift to the next line, but is linewrapped in-place (i.e. right next to "test line 2")? Of course I can specify an explicit width for Pane, but since I don't know how big is my screen (user's screen), how large in pixels is the label text ("test line 2"), and many other factors, it just seems useless to give a magic number that should cover all situations. Full and All does not work either. Any idea?

share|improve this question
up vote 5 down vote accepted

The option ImageSize with the value Scaled should give better results, and it will adapt to the size of the notebook window. You will still need to define the value of Scaled to allow for likely widths of the label in the first column.

Print["test line 1...............: ", {1, 2, 3}, "\n", 
  "test line 2...............: ", 
  Pane[Table["testestestestestestestestest", {10}], 
   ImageSize -> Scaled[0.5]], "\n", 
  "test line 3...............: ", {1, 2, 3}];

enter image description here

I agree that Grid is a better option here. But if you stick with Print, for example because you want to keep this output as a side effect of evaluation, you might also want to consider wrapping that long table output in TableForm.

share|improve this answer
Exactly what I was looking for, thanks. – István Zachar Jan 19 '12 at 10:01

Just realized, that the simplest method would be to use Grid instead of Print. Still it would be nice to solve this by using Print and Pane.

  {"test line 1...............: ", {1, 2, 3}},
  {"test line 2...............: ", 
   Pane[Table["testestestestestestestestest", {10}], 800]},
  {"test line 3...............: ", {1, 2, 3}}
  }, Alignment -> {Left, Center}, Spacings -> {.5, 1}]


Mathematica graphics

share|improve this answer

Your Answer


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.