Another problem with footnotes not appearing on right page
I've read a few threads on this where the conclusion seems to be that it's just what Prince does when a footnote reference appears near the bottom of the page and there's no room left on the current page for the footnote content. However, in our scenario it's worse because we're using counter-reset on each page, and Prince's output gets confusing. I've taken mikkelricky's example from
http://www.princexml.com/bb/viewtopic.php?f=3&t=22045, expanded the text a little and added in a counter-reset in the @page css.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>Footnotes</title>
<style type="text/css">
@page {
size: 12cm;
margin: 1cm 1.5cm;
counter-reset: footnote;
}
* {
font-family: monospace;
font-size: .5cm;
line-height: 1cm;
}
.footnote {
font-style: normal;
float: footnote;
}
.footnote::footnote-call {
content: counter(footnote);
vertical-align: super;
}
.footnote::footnote-marker {
content: counter(footnote) ".";
padding-right: .25em;
}
/* Highlight the second footnote */
.footnote ~ .footnote::footnote-call,
.footnote ~ .footnote::footnote-marker {
background: #f77;
}
</style>
</head>
<body>
<h1>Footnotes</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore. Sed blandit porttitor viverra.
Lorem ipsum dolor sit amet, consectetur adipisicing elit.<span class="footnote">The first footnote.</span>
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore.<span class="footnote">The second footnote.</span>
</p>
</body>
</html>
If you take a look at the output, you'll see that they both end up being called footnote #1 because the original locations are on different pages, even though the definitions end up being next to each other.
I've tried adding counter-reset: footnote into a @footnotes section in the hope that it would only reset the counter whenever a footnotes section was actually created, but it seemed to have no effect (unless I was doing it wrong?).
Thanks for any help.
Tricky! How do you think we can fix this? Would it be sufficient for the footnote on the second page to be numbered 2.? It's a bit difficult to formalize though; basically the counter-reset would have to not apply if there were some footnotes from earlier pages that have not yet been displayed.
Alternatively, what about reserving more space for the footnotes area, so that footnotes are more likely to display in full? This would waste some space on pages that don't need it, though.
There's a couple of options I guess:
* As I said in the OP, if counter-reset could be applied whenever the footnotes are output (in @footnotes?) rather than at the end of each page, then I think that would be a lot clearer. The footnote values might build up over two pages, but the definition section would always have contiguous non-repeated numbers which would then start again from 1 on the next page.
* I guess the wider issue is to make sure that footnotes are always on the page with the reference. It seems to be footnote references that fall near the bottom of the page that trip Prince up, suggesting that it's a linear process and by the time Prince realises that the footnote definition won't fit on the current page, it's too late to go 'back up' the current page and move the footnote reference section onto the next page. Perhaps Prince needs to do multiple passes of the document to ascertain the sizes of all the footnote definitions in advance so that it can page more intelligently to fit them in.
Hi Mike,
I'm a colleague of Andy Turner. I'm having a look at the same issue (in some cases footnotes overflow onto a subsequent blank page). I've upgraded to the latest version of Prince XML (8.1r4) in case the issue had been fixed but there's been no change in behaviour.
As far as I can see there's two possible solutions:
1. Calculate the total height of the area needed for footnote text and perhaps override the bottom page margin, or insert a page break, to reserve enough space for this footnote area. There's one gotcha here in that it is possible that after this is done the text that contains the footnote call in question is no longer on that page, meaning that more space has now been reserved for footnotes than is actually required. This would still be preferable to having too little space reserved for footnotes on a page, though.
2. We switch to using endnotes instead of footnotes in our documents. This would certainly avoid the problem but its a workaround, and we would prefer to use footnotes rather than endnotes in our documents.
Let me know what you think.
End notes are the easiest short term workaround. We can try implementing a super-strict footnote layout that prefers to leave gaps at the bottom of pages instead of separating a footnote call from the footnote body, but it will need to wait a couple of months until we can take care of some other roadmap items.
I have worked on typesetting Bibles. The fix that I have when using Prince is to adjust the paragraph tracking (tighter/looser) on paragraphs that end with just one word on a line. By doing this we can assure that the footnote caller and footnote are both on the same page without forcing large white space at bottom of the page. If this solution is of interest you may contact me through Mike Day.
Jim Albright
Wycliffe Bible Translators
I would imagine it's hard to come up with an automated solution that will always work. We've had footnotes that take up more than half a page. We had one eight-page chapter that had 19 footnotes, many of them a quarter or a third of a page.
I've found it very helpful to move the footnote text around in the source file to help Prince come up with a reasonable solution.
The NET Bible has 75% of each page in footnote on average. Fortunately it is many different footnotes so it doesn't look too bad.
Jim Albright
Wycliffe Bible Translators
Regarding:
"We can try implementing a super-strict footnote layout that prefers to leave gaps at the bottom of pages instead of separating a footnote call from the footnote body, but it will need to wait a couple of months until we can take care of some other roadmap items."
Has this been implemented? If not could you keep it on your todo list? Many thanks.
Yes, we have implemented this with a new CSS property:
prince-footnote-policy: auto | keep-with-line | keep-with-block
It will be available in the next release of Prince, due shortly.
Prince 9 is now available, and includes the prince-footnote-policy that can push footnote calls to subsequent pages to keep them on the same page as the footnote body.
Hi, I've upgraded to Prince 9 in the hope of using the new prince-footnote-policy but it doesn't seem to make any difference. I'm quite new to Prince so it is likely i'm trying to add it to the wrong place in the css. Could you provide an example?
...
<div>
Some text that needs a footnote<a href="#footnote1"></a>
<span id="footnote1" class="footnote">
The footnote
</span>
The rest of the text
</div>
...
The pdf output I get consistently puts the footnote on the next page if the page is full of text no matter which prince-footnote-policy I use, I've tried adding it to various places in the css and am at a loss as to what to do next.
What CSS are you applying? Are you using "float: footnote"?
Thanks for replying. Am using:
.footnote{
float: footnote;
prince-footnote-policy: keep-with-line;
}
Actually the prince-footnote-policy needs to be applied to the block or paragraph containing the footnote, not the footnote itself. Unfortunately the documentation is unclear on this point.
Hi, am still having difficulties with this.
I have attached a file containing (simplified) xhtml that is being sent to Prince.
There are 4 footnotes in the document, the first 3 are being displayed a page too late and the fourth works correctly.
I was wondering if a page break occurring in the middle of an unordered list could cause the footnotes to be moved to the following page?
- footnote-problems.txt 7.5 kB
Chunter, could you supply your CSS? I'm not able to reproduce your problem using your HTML and just adding CSS for the footnote.
Thanks,
Dave
A colleague has just shown me how to create pdfs on the command line instead of using our main code that runs docmonkey and i'm getting this output:
"cannot fit footnotes on page 5" (& page 7 etc)
So I guess that's why they are appearing on the next page.
Will get some cut down css sorted.
I've attached an example with css which I've been running on the command line using Prince 9. As far as I can see from the footnote documentation and your answers on here, I've included the correct footnote css. Would really appreciate it if you could work out why it isn't rendering correctly.
- example2.zip 2.9 kB
I think this is caused by the text being inside a table, as there seems to be some kind of interaction between tables and the new prince-footnote-policy property. We will need to investigate this further.
Hi, did you have chance to investigate this issue further?
Not yet sorry, we have been preoccupied with the release of Prince 9 rev 5.
Hi again, I noticed that revision 5 is now out. Can you find the time to take a look at this issue please? We have a product that really needs this fix.
After investigating this issue, it turns out not to be specific to the footnote policy property, it actually affects all footnotes inside long table cells.
Basically, Prince can only reserve space for footnotes at the end of each row. If the current row ends close to the bottom of the page, or if the cell spans multiple pages, then the footnote body will not be able to be packed on the same page. Changing this behaviour is difficult, and will take time.
One way to workaround this problem would be to split the tables into shorter rows, or not to use tables at all. In particular, if the table only has one column, then it doesn't need to be a table.
Can I just confirm with you that you will fix this issue for us over time? Its a massive blocker to our project and unfortunately, due to the way the document content is created by external users, we cannot implement the suggested workaround easily either.
It is difficult to give a timetable for this work at present, as it will be very involved.
If you cannot change the input document, one possibility is to use JavaScript to modify the document structure within Prince, before formatting.
Has there been any progress on this? I have footnotes that appear correctly except that they always create a new page instead of taking up space at the bottom. Even when the page before has space left on it.
Also the documentation on footnotes seems a bit thin, or maybe i have not found the correct page, do you have a link to the lates documentation?
- Screen Shot 2016-08-03 at 19.08.37.png 100.2 kB
- Screen Shot 2016-08-03 at 19.08.52.png 42.1 kB
Any news on this? It's been years now.