I am trying to print a notebook that begins with a lengthy piece of code that takes up almost an entire page. Because of my heading, it doesn't quite fit on Page 1, so Mathematica inserts a line break before the cell, leaving a ton of white space on Page 1, as shown below.
However, if I add a few lines, such that the input cell takes up more than one page, Mathematica is forced to insert a page break somewhere in the cell, so it does this:
This looks much nicer. I want to tell Mathematica to insert page breaks whenever a cell runs off the bottom of the page, rather than only inserting page breaks within cells when it is absolutely necessary.
My attempt at a solution:
I've tried to modify the Printout stylesheet with
Cell[StyleData[All, "Printout"], ShowAutoStyles->True, ShowSyntaxStyles->True, Magnification->0.8, PageBreakWithin->True]
(The second line is for colored syntax printing, irrelevant to my question.) This doesn't seem to change the default behavior.
I also tried, as a less-than-elegant solution, manually inserting a page break in the input cell. This is not a satisfactory solution since it splits the cell into two input cells.
EDIT (working solution, but not ideal): I have at least figured out how to do this on a cell-by-cell basis.
- Highlight the cell that needs a page break.
- Press Ctrl+shift+O to open the Option Inspector, and in the dropdown menu for "Show option values", choose Selection.
- Navigate to Cell Options->Page Breaking and set the PageBreakWithin option to True. Click Apply and close the Option Inspector.
By choosing the location of the next page break strategically, I can then achieve the behavior I want. However, I would still be interested in a more general solution (rather than repeating the above steps over and over) if one exists.