Forum How do I...?

select the last page of every chapter?

eluikaplan
My designer wants to have a specific graphic for the background image of the last page of every chapter. That last page may be blank or may have content, depending. How can I select for that page without knowing what content is flowing onto it in each instance?

I tried adding a <div> with a unique class and setting that as a named page, but that inserts a page break and prints the background image on the new blank page.
mikeday
You can't do this at the moment, there is no :last page selector.

You can put content at the end of the chapter, eg. with the ::after pseudo-element.

However, does it make sense to have a background image on the last page when you don't know how much content the last page will have on it? Does the background image cover the whole page area, or does it just appear in part of the page?
eluikaplan
The background image only covers the bottom of the page, outside the content area.
eluikaplan
I should mention, there is an existing background image that covers the footer area, from the default @page settings.
mn4367
If you can put an image (or a container for the image) manually at the end of of each chapter maybe this is possible, please see the example attached for a first start. If it is impossible to do this manually it could easily be done with a litte JavaScript that inserts the image before the start of a new chapter.
  1. test.zip23.8 kB
mikeday
Yes you can do this, you can also used CSS pseudo-elements, eg. if you have <div class="chapter"> you can put something at the end of it with div.chapter::after { content: ... }
christin
Are you planing to add a :last page-selector in the future?
mikeday
It would be nice, but can be technically challenging due to the ability to create circular definitions. Maybe one day.