Currently, Paged.js doesn't have a selector for the last page like :last
.
From your question, I understand you intend to target the last page that has content.
Your named page method doesn't work because named pages rely on a class to call them, and that class has to be added on an element or section which would be on a different page layout. You would have to manually see how much of the text is on the last page and put it in a div
with a named page class for this approach to work.
I suspect the only other way to do it for now is to generate the book, manually see how many pages there are and type it in the @page :nth()
pseudoclass.
Context: I attempted to set a rule with @page :nth(counter(pages))
but the counter seems to work only inside curly braces. This caused paged.js to fail.