Update: How to fix the bug
I've found where the bug lives: it is the option CellGroupingRules -> {"SectionGrouping", 30}
of the built-in "Section"
style. Overriding this option with anything like CellGroupingRules -> Automatic
recovers the lost upper cell margin:
CreateDocument[
{ Cell["s1", "Section"
, Background -> LightBlue
, CellMargins -> 100 {{1, 1}, {1, 1}}
]
, Cell["s2", "Section"
, Background -> LightBlue
, CellMargins -> 100 {{1, 1}, {1, 1}}
, PageBreakAbove -> True
, CellGroupingRules -> Automatic
]
}
, ScreenStyleEnvironment -> "SlideShow"
]
I think that this fix proves that the behavior described in the question is a bug. Please report it to the support.
Original answer
Is this a bug?
Probably only the developer can give definitive answer, but there are high chances that this behavior is "by design" since (emphasis is mine):
CellMargins
is an option for Cell
that specifies the absolute margins in printer's points to leave around a cell.
PageBreakAbove
is an option for Cell
which specifies whether a page break should be made immediately above the cell if the notebook that contains the cell is printed.
From the above it is natural to expect that the page break immediately above the cell shouldn't be above the upper cell margin (which itself is immediately above the cell). So probably it isn't a bug (but still worth to ask the support).
What indeed looks like a bug is that if we add PageBreakBelow -> True
for the first cell (and remove PageBreakAbove -> True
from the second), we get exactly the same: the upper margin of the second cell is lost, but the bottom margin of the first cell is kept! So I recommend to file a bug report for PageBreakBelow
.
As a workaround one can use CellFrameMargins
(with appropriate setting for CellFrame
which should be turned on for the corresponding side of the cell) instead if CellMargins
because CellFrameMargins
doesn't exhibit the described behavior in conjunction with PageBreakAbove
. A drawback is that it changes the background filling (everything inside of the CellFrame
is filled by the Background
option).