%% test-latex.tex
%% ==============
%% Typesetting test for pdfLaTeX/LuaLaTeX/XeLaTeX (socket-based kernel):
%% a long footnote near the page bottom is moved to the next page as a
%% whole.
%%
%%   pdflatex test-latex.tex   (or lualatex / xelatex)
%%
%% The number of filler lines is set by \FILLN (default 72, which
%% triggers the phenomenon on TeX Live 2026; scan nearby values if the
%% layout changes with your TeX distribution):
%%   pdflatex -jobname=test-latex-n74 "\def\FILLN{74}\input test-latex.tex"
%% For a control build without the package (only
%% \interfootnotelinepenalty=10000):
%%   pdflatex -jobname=test-latex-off "\def\NOPKG{1}\input test-latex.tex"
%%
%% What to check:
%%   * The ordinary footnote (page 1) is typeset as usual.
%%   * At the trigger boundary the long footnote moves to the next page;
%%     in the control build the original page ends with a lone
%%     \footnoterule (no footnote text below it), while with the package
%%     the lone rule disappears.
%%
%% The phenomenon requires \raggedbottom (or bottom glue with stretch)
%% and an \@makefntext that starts with vertical material (a leading
%% \kern), as in many book-production classes.
\documentclass{book}
\ifdefined\NOPKG
  \interfootnotelinepenalty=10000
\else
  \usepackage{footnotenosplit}
  \footnotetopkern=2pt
\fi
\raggedbottom
\makeatletter
\renewcommand\@makefntext[1]{%
  \kern 2\p@
  \parindent 1em\noindent
  \hb@xt@1.8em{\hss\@makefnmark}#1}
\makeatother
\ifdefined\FILLN\else\def\FILLN{72}\fi
\begin{document}
\chapter{Test}
Start of the test\footnote{An ordinary footnote that fits on the same page.}.
\newcount\mycount \mycount=0
\loop
  \advance\mycount by 1
  This is a filler line of plain English text to fill the page.\par
\ifnum\mycount<\FILLN \repeat
REFLINE is the reference line at the very bottom of this page\footnote{LONGNOTE: this footnote is quite long, so it cannot fit on the current page and should move to the next page as a whole. This footnote is quite long, so it cannot fit on the current page and should move to the next page as a whole.}.

Text on the next page.
\end{document}
