Dear Prince XML,
I'm trying to format a book with figures. Most of the time, the figures and captions are formatted correctly on the same page, with the caption below the image. However, when the image is too tall, the caption either floats on top of the image or gets moved to the next page. My question is: How can I make sure that the entire figure stays on the same page with the caption below the image, even when the image is tall? There must be some way to treat the figure+caption as a unit that automatically resizes itself to fit on the page, but I don't know how to do this.
Here's the HTML for the figures:
Here's my CSS code for the figures. I'm sure it can be simpler, but I'm new to CSS. Any suggestions for improvement/simplification would be appreciated!
I'm attaching two screenshots. The first one renders the figure correctly with the caption below the image. The second one renders the figure incorrectly with the caption floating on top of the image. Thank you!
I'm trying to format a book with figures. Most of the time, the figures and captions are formatted correctly on the same page, with the caption below the image. However, when the image is too tall, the caption either floats on top of the image or gets moved to the next page. My question is: How can I make sure that the entire figure stays on the same page with the caption below the image, even when the image is tall? There must be some way to treat the figure+caption as a unit that automatically resizes itself to fit on the page, but I don't know how to do this.
Here's the HTML for the figures:
<figure>
<img src="/images/jhfsadh.tif" alt="Caption text" /><figcaption aria-hidden="true">Caption text</figcaption>
</figure>
Here's my CSS code for the figures. I'm sure it can be simpler, but I'm new to CSS. Any suggestions for improvement/simplification would be appreciated!
figure {
-prince-float: page;
page-break-inside: avoid;
display: table;
margin-left: auto;
margin-right: auto;
}
figure img {
max-width: 95%;
display: table-row;
margin-left: auto;
margin-right: auto;
-prince-image-magic: convert-to-jpeg(95%);
}
figure figcaption {
font-style: italic;
text-align: center;
padding-top: 0.1in;
padding-bottom: 0.2in;
display: table-caption;
caption-side: bottom;
}
I'm attaching two screenshots. The first one renders the figure correctly with the caption below the image. The second one renders the figure incorrectly with the caption floating on top of the image. Thank you!