1
$\begingroup$

Writing:

list = ConstantArray[0, {2, 35}];
doc = 
  CreateDocument[ExpressionCell[TableForm[list, TableSpacing -> {2, 2}], "Output"]];
Export["test.pdf", doc];

I get the following pdf document:

enter image description here

where it is evident that it does not automatically go to the end, but cuts part of the table.

Any suggestions for automatic line wrapping?

$\endgroup$

1 Answer 1

1
$\begingroup$

Use TableSpacing -> {2, 1} to shrink the width.

Alternatively, to line wrap after 24 items.

doc = CreateDocument[ExpressionCell[TableForm[
    Flatten[Partition[#, UpTo[24]] & /@ list, 1],
    TableSpacing -> {2, 2}], "Output"]]

Edit

To automatically adjust

cellsize[n_] := ImageDimensions[Rasterize[
   cell = ExpressionCell[TableForm[
      Flatten[Partition[#, UpTo[n]] & /@ list, 1],
      TableSpacing -> {2, 2}], "Output"]]]

list = ConstantArray[0, {2, 35}];

x = 24;

cellsize[24]

{582, 80}

582 is the minimum width. Now making a list with larger items.

list = ConstantArray[1234, {2, 35}];

cellsize[24]

{1086, 80}

While[First[cellsize[x]] > 582, --x]
doc = CreateDocument[cell];
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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