Contents | Start | End | Previous: KB0120: How do I resolve Lulu errors? | Next: KB0122: Can Jutoh handle diacritics?


KB0121: How do I keep a caption on the same page as its image?

See also:
Caption dialog in the Jutoh manual
How do I prevent headings being followed by a page break?

Often a caption will part company with its image (or table), and appear on the next page. There are various solutions to this problem:

  1. Insert a text box, manually or using the Caption command.

  2. Use paragraph styles.

  3. Use accessibility options to generate Epub 3 tags.

  4. Add text to the image.

  5. Sizing the image.

Currently there is no known way of avoiding page breaks between image and caption for Kindle, except to include text with the image. You can do this automatically by setting the configuration option Pre-render image captions to 'auto'. For more on this, please see Working with pictures in the Jutoh manual.

1. Insert a text box

You can create a text box containing the figure and caption: this method works for most ereaders, and also ODT, but not Kindle.

Manually: create a text box, move the figure (image or table) inside it, and set the figure width to 100% so it fills the text box. Set the text box width to a suitable value, for example 50% if floating the box left or right, or 100% if not. Add a caption paragraph after the figure, and set the text box advanced property "Page break inside" to "avoid".

Automatically: insert a caption with the menu command Format | Insert | Caption or by right-clicking/ctrl-clicking over an image or table and using the Insert Caption command. This lets you create a text box, and automatically sets the text box advanced property "Page break inside" to "avoid", and "Epub type" to "figure". It also takes care of moving size and floating attributes to the box.

This method works with the greatest number of readers, so is recommended.

2. Use paragraph styles

You can use special paragraph styles for the figure and the caption, e.g. "Figure", "Caption". In your "Figure" style, check Avoid page break after paragraph. Or, in your "Caption" style, check Avoid page break before paragraph. Alternatively, add the "Figure" style to the configuration option Styles suppressing page break after, or the "Caption" style to the configuration option Styles suppressing page break before.

This will work on Adobe Digital Editions and ereaders that use ADE-derived code. Unfortunately it doesn't work on Apple Books or Kindle. If you use Avoid page break after paragraph, it will work for ODT (there is no 'keep with previous paragraph' option in ODT).

3. Use accessibility options

You can use the Accessibility page in Project Properties to define how caption styles are mapped to figure/figcaption tags in Epub 3, or div tags in Epub 2, which should keep the caption with the image on most readers except Kindle.

You can combine this with the box approach: if the box's Epub type advanced option is set to figure, Jutoh will output the box as a figure, and will also add figcaption tags if possible.

4. Add caption text to the image

Another method is to put the text inside the image. This won't be accessible to disabled users, and the caption won't respond to font customisation. You can add captions to their images automatically by setting the configuration option Pre-render image captions to 'auto'. For more on this, please see Working with pictures in the Jutoh manual.

5. Sizing the image

You can also consider reducing the image size to make sure it doesn't take up the whole page, for example by setting a percentage width or height in the image properties. Maximum width and height are ignored on Kindle, unfortunately.

Another trick is to put a page break before the image to ensure the image and caption get the most amount of space possible; and you can consider putting the caption before the image so at least the user knows what's coming.

Keywords: captions, figure, figures


Contents | Start | End | Previous: KB0120: How do I resolve Lulu errors? | Next: KB0122: Can Jutoh handle diacritics?