If I want to make sure there is no page break in PDF output between a figure (typically a .png file) and its associated caption, which is the preferred method:
Wrapping caption and figure in a <div> that is styled with page-break-inside: avoid; or
Applying page-break-after: avoid; to the figure caption paragraph style (assuming caption is always above image, of course), or
Applying page-break-before: avoid; to the figure img style
Styling the figure caption paragraph seems more compact and simple to me, but the <div> has merit as well, really signifying what's meant to be kept together.
Thanks.
Keeping figure captions with figures
-
- Sr. Propeller Head
- Posts: 248
- Joined: Thu May 24, 2018 3:11 pm
- Location: Queensland, Australia
Re: Keeping figure captions with figures
If your figures are always in containing paragraphs and are always followed (or preceded) by a figure caption, I'd apply the relevant page-break/column-break styles to the paragraphs involved. It's sort of set-and-forget then. You don't have to remember to apply a separate DIV to the section. I do apply the relevant page-break parameter to both styles though to make sure it sticks.
For me, I don't always have a figure caption and sometimes don't have a containing paragraph for the image, so where there is potential for an issue I use the encapsulate-in-a-DIV method.
I guess it depends on your usage
Cheers,
Rob
For me, I don't always have a figure caption and sometimes don't have a containing paragraph for the image, so where there is potential for an issue I use the encapsulate-in-a-DIV method.
I guess it depends on your usage
Cheers,
Rob