Set \widowpenalty only in main text, not for footnotes

page-breakingwidows-orphans

I have made sort of the opposite experience than described in an older question and the same as this question without replies.
I would like to prevent widows in the main text, but I don't mind them in the footnote area when splitting of footnotes occurs. Setting \widowpenalty=1500 patches some page breaking nicely, but due to some footnotes, unwanted white spaces appear. Is there a way to set a global option or do I have to go through my document manually?

Best Answer

LaTeX has a mechanism for changing \interlinepenalty inside footnotes, but not for \widowpenalty.

You may try

\usepackage{etoolbox}

\makeatletter
\patchcmd{\@footnotetext}
  {\interlinepenalty}
  {\widowpenalty 150 \interlinepenalty}
  {}{}
\makeatother

that would reset \widowpenalty to the usual value only inside footnotes, by hooking in the same place where \interlinepenalty is changed.

The relevant definition in latex.ltx is

\long\def\@footnotetext#1{\insert\footins{%
    \reset@font\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
    \def\@currentcounter{footnote}%
    \protected@edef\@currentlabel{%
       \csname p@footnote\endcsname\@thefnmark
    }%
    \color@begingroup
      \@makefntext{%
        \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
    \par
    \color@endgroup}}%

and doing something like

\let\oldfootnote\footnote
\renewcommand{\footnote}{\widowpenalty150\oldfootnote}

will not work, because it doesn't set \widowpenalty at the right place, that is, after \insert\footins{, which is what my code does.

Note that the material for \insert is processed in a group, so the value of \widowpenalty will be restored as soon as the matching } is scanned.