1

I have a large output currently in grids which I need to export to .pdf, with the grid centered on the page, as well as break over multiple pages. Ideally I am looking to have 3 or 4 rows on each page.

Essence of the code is:

Grid[Partition[Table[i, {i, 0, 50}], 4], Spacings -> {3, 2}, Frame -> All]

and

GraphicsGrid[Partition[Table[Plot[x^i, {x, -2, 2}], {i, 1, 24}], 3], Spacings -> {3, 2}, Frame -> All]

Edit: I have managed to get the output working, but still need help on breaking the grid so that only three rows appear on one page.

myGrid = Grid[Partition[Table[Style[i, 24, "Times"], {i, 0, 80}], 4], Spacings -> {5, 5}, Frame -> All];
mynb = CreateDocument[{}, TextAlignment -> Center];    
Paste[myGrid];
NotebookWrite[mynb, Cell["", "PageBreak", PageBreakWithin -> True]];
Export["myGrid.pdf", mynb];
NotebookClose[mynb];
Clear[mynb];
Michael E2
  • 235,386
  • 17
  • 334
  • 747
jamie
  • 107
  • 1
  • 7

1 Answers1

1

partition1 is the original data:

partition1 = Partition[Table[Style[i, 24, "Times"], {i, 0, 80}], 4];

Because Length@partition1==20, UpTo needs to be used to further Partition the data properly; then Grid is applied and finally it's Riffled with a PageBreakBelow:

myGrid2 = Grid[#, Spacings -> {5, 5}, Frame -> All] & /@ Partition[partition1, UpTo@3, 3];
myGrid3 = Riffle[myGrid2, Cell["", "PageBreak", PageBreakBelow -> True]];

Then, with Paste /@ myGrid3 instead of Paste[myGrid3]:

mynb = CreateDocument[{}, TextAlignment -> Center];
Paste /@ myGrid3;
NotebookWrite[mynb, Cell["", "PageBreak", PageBreakBelow -> True]];
Export["myGrid.pdf", mynb];
NotebookClose[mynb];
Clear[mynb];

yields

enter image description here

corey979
  • 23,947
  • 7
  • 58
  • 101