1
$\begingroup$

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];
$\endgroup$

1 Answer 1

1
$\begingroup$

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

$\endgroup$

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.