Forum How do I...?

Class to define the height of a specific footnote

ixgal
Hi,
Is there a way to define the height (in cm or % of the page) of a specific footnote? (and leave unchanged the rest of the footnotes).
Maybe I can add a <span class="footnote_height"> around the footnote text? (in this case, I don't know which CSS property I should add for that particular class).
Thanks
mikeday
What does it mean to set the height of a footnote, should it add blank space around it?
ixgal
In my document, I am using:
@page {
@footnotes {
max-height: 40%;
}
}

Is it possible for a specific footnote to define for example: max-height: 30%; ? (while keeping the other footnotes with the default max-height at 40%).

Thanks
mikeday
Do you want to constraint the height of an individual footnote or the footnotes area for the page? If an individual footnote exceeds this height, what should happen?
ixgal
The problem I have is that in one specific page, a long footnote is not being split, and makes a big blank area to appear in the previous page, because Prince is forcing the footnote reference in the main text to stay in the same page of the footnote).
It would be great to set a max-height for that footnote area, without modifying the max-height of the other footnote areas.
By reducing the max-height, I guess I will be able to force the footnote text to split in two, and get part of its content move to the previous page, together with the footnote reference.
ixgal
Hi! Please let me know if there is a way. Thanks
pjrm
I'd be interested in why the footnote isn't already being split. Could we have a look at the document?
pjrm
For example, I wonder if the footnote has page-break-inside:avoid or a large value for 'widows' or 'orphans'. I would hope that there's a better solution than modifying the height of the footnote area on one page.
ixgal
Please find attached page 153 and page 154.
It's strange because I would imagine that part of footnote 8 could move to page 153, but it stays in page 154, leaving a big blank space in page 153.

The footnote has no page-break-inside:avoid property.

As for orphans and widows, these are the values:
orphans:3;
widows:3;

I don't think orphans/widows are the culprit in this case.
Please let me know. Thanks!!
  1. page153.png89.1 kB
    page 153
  2. page154.png199.8 kB
    page 154
pjrm
I haven't managed to reproduce this yet, and I can't see what could be forcing those lines to the next page: there's plenty of space for both the rest of the body paragraph and the whole of its footnote. Can you send the stylesheet you're using?

It looks like you're using an older version of Prince for Books, but I can't think of a change that would have affected this. Still, you might as well try using a current build to see if you still get the same problem.

I did manage to reproduce a somewhat similar gap, but that's where the footnote was called from the second- or third-last line of the paragraph, i.e. within the 'widow' lines but before the last line: whereas in your example, the footnote is called from the last line. I've made a change that might well help avoid similar problems in your document, but I can't see that it would help with the page you've attached.

I attach what I have so far.
  1. bk-p153.png274.1 kB
  2. bk-p154.png296.2 kB
pjrm
I wonder whether the max-height on the footnote area is part of the problem. You could try actually increasing (or indeed removing) that max-height limit, just to see whether that makes the problem not occur. If it does fix it, then consider applying prince-n-lines to one or both of those footnotes to reduce the number of lines in the footnote, which might have a similar effect to changing the @footnote max-height limit, in the sense of avoiding exceeding the limit.
pjrm
Answering the original question, you could try @page:nth(...) { @footnotes { max-height: ... } }
ixgal
Thank you very much!
Inside the parenthesis after nth(... I should add the specific number of the page where I would like to adjust the max-height?
I tried that but the result is that the max-height changes in all pages.
Please let me know.
pjrm
For me (and the simplistic stylesheet I'm using), it suffices to use
@page :nth(17) { @footnotes { max-height: 25%; background: yellow; } }

but there are some subtleties in what number to use (or what pages a given number will select), and that's why I suggest adding the "background:yellow" to the ruleset to make it clear what pages are being selected (to avoid confusion with any other rulesets that happen to be matching).

:nth() in Prince works the way :first does, in the sense that :nth(1) matches the same pages that :first does. So in many books, you'd need to give the page number relative to the start of the chapter rather than "153".

(Consequently, note that this would match the n'th page within each chapter; so you might want to use a special named page style that's used only for a single chapter, and change existing "@page chapter" selectors to "@page chapter, chapter3".)

Similarly, :nth() ignores changes to the 'page' counter, so even if you have the whole book in a single HTML file and aren't using named 'page' styles, you might still need to give a number other than 153 if your page numbering starts with roman numerals and resets to page 1 after the introductory matter.

Relatedly, if you've split your book content into several files, then you might find that :nth() doesn't count pages that aren't from the current file, even if you aren't using named page styles and page groups.

That's why I suggest adding "background: yellow;", to check that it's applying to the page you intend.

However, it would of course be better to find a better way of getting the pagination you want without the effort of manually adding and maintaining :nth() selectors. Maybe it's as simple as prince-footnote-policy getting applied somewhere, and (in conjunction with the limit on footnote area size) effectively forcing the footnote and its calling line (and hence the last three lines, given the value of 'widows') to the next page.

As I say, I do invite you to send me the stylesheet you're using, which makes it easier to understand its current behaviour and how to get the behaviour you want.
ixgal
Thanks!
I think targeting a specific chapter is a great idea.
My HTML code for that chapter is:
<div class="chapter" id="first-chapter" (etc...)
<div class="chapter" id="second-chapter" (etc...)

In this case, how can I target the chapter "second-chapter", without modifying the chapter "first-chapter"?
I tried with "@page #second-chapter" or with "@page chapter#second-chapter" but it doesn't work.
pjrm
What I was thinking of (if we really must use the hack of changing @footnote height on a specific page number) was:
.chapter {
  page: chapter;

  /* Let :first match the first page of each chapter. */
  prince-page-group: start;
}

#second-chapter { page: chapter2; }

/* Add a chapter2 version of each @page chapter ruleset. */
@page chapter:left, chapter2:left { @top-center { content: string(book-title); } }
@page chapter:right, chapter2:right { @top-center { content: string(chapter-title); } }
@page chapter:first, chapter2:first { @top-center { content: ""; } }
@page chapter, chapter2 { @footnote { max-height: 40% } }
/* ... */

/* Change footnote area height on 17th page of #second-chapter. */
@page chapter2:nth(17) { @footnote { max-height: 30% } }
ixgal
It works perfect, thanks!
Actually it worked without the need to add the "prince-page-group: start;" and the "chapter:first", etc.

I just used:
.chapter {
page: chapter;
}
#second-chapter { page: chapter2; }
@page chapter2:nth(3) { @footnotes { max-height: 30% } }</p>

And it worked fine ;)
ixgal
The only problem I find now is that with this method, the page number in each page of that chapter has disappeared. I don't understand why. 😮