Glad to hear you managed to get most everything done with the available tools! The following depends upon modern approaches, with KF8 and ePub3 source—I’m not sure if the techniques will even work in older formats, and may even invalide them if the CSS codes are not recognised.
Have you tried using the CSS controls for managing page breaks, both for suppression between elements, and to cause them to be inserted before elements? I would say in most cases that forcing the issue with structure and hoping ePub readers display that structural approach the way you want isn’t going to be a solid approach, particularly if the reader doesn’t even use a page break in the first place for section breaks, or uses section breaks for something you might not be anticipating, like chapter skipping navigation or overview navigation tools.
Although written for a specific method of production in Scrivener you likely are not using (Pandoc Markdown to ePub conversion), this forum post goes over some techniques for handling layout as formatting (as opposed to structure as layout).
As in most things that involve layout, CSS is the best approach for doing so. And the best way to figure out how to employ CSS to achieve a look you want is to get a feel for the HTML Scrivener produces itself. This is easily done, and with a result that can be loaded into your preferred HTML/CSS editor (although if prefer editing epubs directly with an editor like Calibre’s or Sigil, feel free to take that route instead):
- Compile your project, setting the Save source files in a folder with exported ePub file setting.
- Navigate into the compile folder, drilling down into the source/bookname/OPS subfolder, and open one of the section files that contains an image.
You should see something like the following, if you see something different, my specific strategy here may not work, so you’ll need to adapt it acccordingly:
<figure>
<img src="images/testing.png" alt="This is the caption" id="testing" style="height:111px;width:110px;" />
<figcaption>This is the caption</figcaption>
</figure>
So there are a few different approaches here that we could employ:
- Ultimately we want captions to stick with images if at all possible.
- Failing that, we want images to cut to a new page so that the above happens naturally.
For the first goal, we can see that the image comes within a figure element, which contains both the image and the caption. So one potential approach is this CSS:
figure { page-break-inside: avoid; }
This is kind of like the “Keep With Next” code in the word processing world, but it is a block level directive instead of per paragraph. To test, put that at the top of the ebook’s CSS file (in source/OPS/css/stylesheet.css), save it, and run the “make-epub” script in the source folder. Test the .epub file that will be created into the source folder (the one at the same level that was compiled by Scrivener won’t be updated by this script). In my testing, this method works in iBooks and Adobe Digital Editions and Kindle for Mac (so probably other modern Kindle viewers & devices as well). But if in your testing it does not work well everyone, you can try adding a page break instead:
figure { page-break-before: always; }
In case you are unaware of where to put this code, edit your compile Format, and in the CSS pane you can set it to use custom CSS (it does by default, and provides some stuff based on your styles and other option choices). You can paste either of these directives into the left side and compile another test to make sure it all works the same as the source folder test.