Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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. Line break before cell

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:

Line break within cell

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.

  1. Highlight the cell that needs a page break.
  2. Press Ctrl+shift+O to open the Option Inspector, and in the dropdown menu for "Show option values", choose Selection.
  3. 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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Add

Cell[StyleData["Input"],
 PageBreakWithin->True]

to your stylesheet (Format -> Edit Stylesheet...)

share|improve this answer
    
Works like a charm, thank you!! –  Anthony Vella Sep 12 '13 at 2:35

Your Answer

 
discard

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.