4
$\begingroup$

If I create a Notebook that includes multiple pages I know that I can show/hide page breaks by using menu item File ► Printing Settings ► Show Page Breaks. I can manually create my own (non-default) page break by going to menu Insert ► Page Break. But these manual page breaks are not being toggled on and off by the same show/hide page break button. I would like this control.

Is there a way to control ALL page breaks, including the ones I manually create? I am including a gif to illustrate that my manually created page break does not disappear.

enter image description here

$\endgroup$
2

1 Answer 1

5
$\begingroup$

The name of the menu item Insert ► Page Break is a bit misleading. According to the Documentation page for ShowPageBreaks, manual page breaking is controlled via the PageBreakAbove and PageBreakBelow options of Cell. This conclusions is further supported from the fact that when you use Insert ► Page Break menu item you actually insert the following Cell at the insertion point:

Cell["", "PageBreak",
 PageBreakBelow->True]

But why this Cell is displayed even when you set ShowPageBreaks -> False? It is because in the "Core.nb" basic stylesheet the following definition is given for the "PageBreak" style:

Cell[StyleData["PageBreak"],
 Editable->False,
 CellFrame->1,
 CellMargins->{{0, 0}, {1, 1}},
 CellElementSpacings->{"CellMinHeight"->1,
 "ClosedCellHeight"->1},
 CellOpen->False,
 PageBreakBelow->True,
 CellFrameMargins->0,
 CellSize->{Inherited, 2},
 Background->GrayLevel[0.5]]

Note that under this you can find more specific definition which is used only in the "Printout" style environment and which makes Cells with this style completely invisible when you switch to the "Print Preview..." mode (which by default uses the "Printout" style environment):

Cell[StyleData["PageBreak", "Printout"],
 CellFrame->0,
 ShowCellBracket->False,
 Background->None]

So the conclusion is that what is displayed is NOT a page break but the inserted Cell which contains information about it and this display differs substantially from what you see as page breaks when you set ShowPageBreaks -> True or use the File ► Printing Settings ► Show Page Breaks menu item. So what can be made? First of all, you can set private style definition for the "PageBreak" style which will affect your Notebook only. If you did not added any private styles into your Notebook, you can evaluate the following code which will make all Cells with this style completely transparent (if you did, existing private style definitions will be overwritten):

SetOptions[EvaluationNotebook[], 
 StyleDefinitions -> 
  Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], 
    Cell[StyleData["PageBreak"], FrontEnd`CellFrameStyle -> Opacity[0]]}, 
   StyleDefinitions -> "PrivateStylesheetFormatting.nb"]]

Evaluate this to return to the defaults:

SetOptions[EvaluationNotebook[], StyleDefinitions -> "Default.nb"]

With this solution the File ► Printing Settings ► Show Page Breaks menu item and the ShowPageBreaks option will still show/hide the page breaks defined in the Cells added via Insert ► Page Break menu item but these Cells themselves will be invisible.

$\endgroup$
1
  • $\begingroup$ Awesome! Yes... I came to same conclusion after looking a little deeper at your first solution. I decide to zero out the cell margins and graylevel in the stylesheet so that the only thing visible is a little mark for the cell bracket. Interestingly, when use File ► Printing Settings ► Show Page Breaks it now toggles both types of page breaks ( as far as their visibility on the screen is concerned), so this works. Thank you for the solution. It's been bugging me for a while. +100 $\endgroup$
    – B flat
    Commented Jan 18, 2016 at 7:57

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.