Aligning figures in ePUB

The proposed solution to this one is going to be very similar to the one that would allow for multiple inline images. Here is an example compile Format that mainly demonstrates the structure being applied, although there is a little sample CSS as well:

ebook-right_float.scrformat (119.8 KB)

To give it a test, create a paragraph style called “Right Float”, and a character style called “Inline Caption”. The formatting for either is completely arbitrary, as the compile format is going to be treating these as raw HTML, and creating the classed figure itself. Here is the target HTML:

<figure class="right-float">
    <img .../>
    <figcaption>This is optional...</figcaption>
</figure>

Since you will be using a character style instead of a paragraph style for the caption, both the image line and the caption line would be assigned to the Right Float style. It will be the thing wrapping the two lines in the classed figure. If an image doesn’t have a caption, that is fine, it will just print an img in a figure.

For some of them, I would like to align them right and flush with the top of the preceding paragraph…

I might be reading this wrong, but I interpreted that as a float rather than right-alignment—where there would be empty space all the way to the left of the image. It will combine with the following paragraph(s), given how floats work. I don’t think there is a good way of getting a float flush top with the preceding paragraph, but this is easy to solve by where you put the image in the editor.

2 Likes