How do I avoid splitting footnote on multiple pages?

It appears, that the default behavior of footnotes are that they are split on multiple pages, if the other page content becomes to long. Here is a minimal example to reproduce it:

= A
#lorem(200)
#footnote[#text(red)[#lorem(800)]]
#lorem(200)
= B
#lorem(200)
#lorem(200)
#lorem(200)

In itself, there is room for the footnote to be displayed on a single page, but since the text prior to the display of the footnote together with the footnote itself takes up more than one page, the footnote is split over two pages. How do I delay the displaying of the footnote to the next page, such that it fits on one page and is not split into multiple pages?

In principle, block(breakable: false)[content] prevents any content from being split, so the following would work…

#footnote(block(breakable: false, text(red)[#lorem(800)]))

However, it would end up separating your text from the footnote number, as a block triggers a paragraph break. In the case of really long text, they can end up in separate pages. Using a box instead (which is unbreakable and stays in the same paragraph) helps:

#footnote(box(text(red)[#lorem(800)]))

But there will still be a linebreak between the footnote number and its body. If that would be undesirable, the best solution then is

// At the TOP of your document:
#show footnote.entry: block.with(breakable: false)

#footnote(text(red)[#lorem(800)])

which doesn’t affect the text in the entry and instead ensures the entry as a whole is unbreakable.


Note that the solution above will force all entries to be unbreakable. Here’s one way to only pick a few of them.

#show footnote.entry: it => if it.note.at("label", default: none) == <unbreakable> { block(breakable: false, it) } else { it }

= A
#lorem(200)
#footnote(text(red)[#lorem(800)])<unbreakable>
#lorem(200)
= B
#lorem(200)
// This one will be breakable
#footnote(text(blue)[#lorem(800)])
#lorem(200)
Results

3 Likes