Forum How do I...?

Is it possible to "bump" a float?

David J Prokopetz
This is probably going to be easier to demonstrate than to explain, so here we go:

http://www.penguinking.com/files/xml/example.xml
http://www.penguinking.com/files/xml/example.css
http://www.penguinking.com/files/xml/example.pdf

(I apologise for the somewhat messy CSS - it's a work in progress. :? )

What I'm trying to do is create a stylesheet whereby sidebars - of the type shown in the example PDF - won't break across multiple pages. If there's not enough room for them in the remainder of the current page, they should be bumped to the next page. It can be assumed that no sidebar will exceed a full page in length.

I can't figure out how to do it. If I use "page-break-inside: avoid", it bumps the sidebar to the next page as expected, but it also bumps everything following the sidebar as well (which is also to be expected, if I understand the rules that apply to these things correctly).

Is there a way to do what I'm looking for?

Thanks,

- Dave.
mikeday
That's a good question, and I think it's tricky and perhaps impossible to do right now, if you want the sidebar to float next to the text. You could achieve something like this with page floats, but they can only go at the top or bottom of the page. We've experimented with extending support for floats as described in the CSS3 Generated Content for Paged Media module, but it's still in an early stage. We'll work on this and see if we can come up with something for a future version of Prince.
howcome
David J Prokopetz wrote:
What I'm trying to do is create a stylesheet whereby sidebars - of the type shown in the example PDF - won't break across multiple pages. If there's not enough room for them in the remainder of the current page, they should be bumped to the next page. It can be assumed that no sidebar will exceed a full page in length.


There is a proposed value "unless-room" on the "float" property in GCPM. Here's what the code could look like:

  .sidebar { 
    width: 30%;
    float: right next page unless-room;
  }


Prince doesn't support this, but your example is a good use case so it's something we might consider.

The rules for how and when to combine the different keyword values on 'float' is also something that should be looked at. Comments welcome.
David J Prokopetz
mikeday wrote:
We've experimented with extending support for floats as described in the CSS3 Generated Content for Paged Media module, but it's still in an early stage. We'll work on this and see if we can come up with something for a future version of Prince.

That does look like exactly what I'm looking for. I assume that the bit about "using the page box as the containing block" would provide some sort of mechanism for preventing floats from breaking across pages.

Pity it's not yet supported. No matter, though - manually positioning the sidebars won't be difficult for small documents.
David J Prokopetz
Hmmm. Another stumbling block: I tried converting to a two-column layout to take advantage of column floats, to see if that might offer a way to solve the problem, only to discover that unlike page-break-after, column-break-after has no corresponding "avoid" value, so there's no way to avoid orphaned subheaders at the bottom of the left-hand column.

That's a bit disappointing.

Edited by David J Prokopetz

mikeday
Actually, page-break-after: avoid should work inside columns as well as pages. Let us know if it doesn't. :)
David J Prokopetz
Hey, that worked. Thanks! :D