summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/latex/bigfoot/bigfoot.drv5
-rw-r--r--Master/texmf-dist/source/latex/bigfoot/bigfoot.dtx944
-rw-r--r--Master/texmf-dist/source/latex/bigfoot/bigfoot.ins27
-rw-r--r--Master/texmf-dist/source/latex/bigfoot/perpage.drv17
-rw-r--r--Master/texmf-dist/source/latex/bigfoot/perpage.dtx156
-rw-r--r--Master/texmf-dist/source/latex/bigfoot/suffix.drv7
-rw-r--r--Master/texmf-dist/source/latex/bigfoot/suffix.dtx15
7 files changed, 760 insertions, 411 deletions
diff --git a/Master/texmf-dist/source/latex/bigfoot/bigfoot.drv b/Master/texmf-dist/source/latex/bigfoot/bigfoot.drv
index 1eed69b8ee1..84916b732f5 100644
--- a/Master/texmf-dist/source/latex/bigfoot/bigfoot.drv
+++ b/Master/texmf-dist/source/latex/bigfoot/bigfoot.drv
@@ -22,7 +22,10 @@
%% in the same archive or directory.)
%%
%% bigfoot is part of the bigfoot bundle for critical typesetting
-%% Copyright 2004, 05, 06 David Kastrup <dak@gnu.org>
+%% Copyright 2004--2014 David Kastrup <dak@gnu.org>
+%%
+%% The license notice and corresponding source code for this file are
+%% contained in bigfoot.dtx.
%%
\documentclass{ltxdoc}
\usepackage{bigfoot}
diff --git a/Master/texmf-dist/source/latex/bigfoot/bigfoot.dtx b/Master/texmf-dist/source/latex/bigfoot/bigfoot.dtx
index feaddf19929..be78a65452c 100644
--- a/Master/texmf-dist/source/latex/bigfoot/bigfoot.dtx
+++ b/Master/texmf-dist/source/latex/bigfoot/bigfoot.dtx
@@ -1,7 +1,10 @@
% \iffalse
%%
%% bigfoot is part of the bigfoot bundle for critical typesetting
-%% Copyright 2004, 05, 06 David Kastrup <dak@gnu.org>
+%% Copyright 2004--2014 David Kastrup <dak@gnu.org>
+%%
+%% The license notice and corresponding source code for this file are
+%% contained in bigfoot.dtx.
%%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
@@ -17,7 +20,7 @@
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
% \fi
-% \CheckSum{4157}
+% \CheckSum{4576}
% \GetFileInfo{bigfoot.sty}
% \title{The \texttt{bigfoot} package\\version \fileversion}
% \date{\filedate}
@@ -40,7 +43,7 @@
% long ``u'', but that's just obvious in spoken Latin.}}
% that is higher on the page.
% \item The last footnote in each apparatus may be broken to the next
-% page\footnote{This will probably be interesting for footnotes
+% page.\footnote{This will probably be interesting for footnotes
% that contain stuff like math equations\footnoteB+{Like
% \begin{equation}
% \label{eq:1}
@@ -64,7 +67,7 @@
% \item Footnotes can be formatted in separate paragraphs, or be run
% into a single paragraph. The choice is made per footnote
% apparatus, but can be overridden for single
-% footnotes.\footnote{Footnotes containing material like display
+% footnotes.\footnote{I.e., footnotes with display
% math\footnoteB{We had this already, right?} or list
% environments\footnoteB{And this looks familiar, too.} have to be
% done in vertical mode.}
@@ -148,9 +151,7 @@
% \begin{macrocode}
%<*style>
\NeedsTeXFormat{LaTeX2e}
-\def\FN@next $#1: #2 #3${#2}
-\ProvidesPackage{bigfoot}[\FN@next $Date: 2006/07/15 21:24:56 $
- \FN@next $Revision: 1.25 $ makes footnotes work]%}
+\ProvidesPackage{bigfoot}[2014/10/23 2.0 makes footnotes work]
\DeclareOption{para}{\PackageInfo{bigfoot}{Compatibility option `para'
has no effect:^^J%
@@ -165,6 +166,19 @@
\DeclareOption{ruled}{\PassOptionsToPackage{ruled}{manyfoot}}
% \end{macrocode}
+% The normal processing makes footnote text macros allow verbatim and
+% similar. We call this |robust| processing though it is not totally
+% accurate. This is the default. There is also an option |fragile|
+% which will not allow this, but may be required for some definitions
+% of \cmd{\@makefntext}. It turns out that most document classes work
+% with the `robust' option, but there might be some that fail, and
+% there might be some footnote-modifying packages that also can cause
+% failure.
+% \begin{macrocode}
+\DeclareOption{robust}{\def\FN@makefncall{\FN@makefnrobust}}
+\DeclareOption{fragile}{\def\FN@makefncall{\FN@makefnfragile}}
+\ExecuteOptions{robust}
+% \end{macrocode}
% The |verbose| option talks about changed labels at the end of a
% run. It is for debugging instable configurations that fail to
% converge after a number of \TeX\ runs. The output is probably
@@ -303,12 +317,13 @@
}%
}
-\def\MFL@minipage{%
- \ifinner\else
- \let\MFL@mpinsertsave\MFL@insert
- \MFL@reinsert \let\MFL@insert\MFL@mpinsert
- \fi
-}
+\def\FN@divert{%
+ \let\MFL@mpinsertsave\MFL@insert
+ \MFL@reinsert \let\MFL@insert\MFL@mpinsert}
+\def\FN@enddivert{{\let\@elt\MFL@mpreinsert \MFL@list}}
+
+\def\MFL@minipage{\ifinner\else \FN@divert\fi}
+\def\MFL@endminipage{\ifinner\else \FN@enddivert\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -343,7 +358,7 @@
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MFL@removevboxes}
-% The trick is like with \cmd{\removehboxes} in the \TeX book's
+% This trick works like \cmd{\removehboxes} in the \TeX book's
% appendix~D.
% \begin{macrocode}
\def\MFL@removevboxes{{\setbox\z@\lastbox
@@ -604,6 +619,21 @@
\iffalse}\fi}
% \end{macrocode}
%
+% \subsubsection{Continuation marks}
+%
+% We add a possibility of adding continuation marks. While the box is
+% assembled, immediately before the break, \cmd{\FN@beforebreak} gets
+% called, and \cmd{\FN@afterbreak} is called at the top of the
+% continuing box.
+% \begin{macrocode}
+\ifx\FN@beforebreak\@undefined
+ \let\FN@beforebreak\@empty
+\fi
+\ifx\FN@afterbreak\@undefined
+ \let\FN@afterbreak\@empty
+\fi
+% \end{macrocode}
+%
%
%\subsubsection{The works}
%
@@ -724,7 +754,7 @@
% \begin{macrocode}
\def\@makefnvtext#1{%
\FN@specific\FN@masterinsert\@makefntext{%
- \clubpenalties\tw@\@MM\clubpenalty
+ \clubpenalties\thr@@\@MM\clubpenalty\z@
\vadjust{\nobreak\vskip-\baselineskip}\nobreak\hfill\break#1}}
% \end{macrocode}
% \end{macro}
@@ -780,6 +810,9 @@
% \end{macro}
% \begin{macrocode}
\def\@makefnstartbox{%
+ \ifdefined\setspace@singlespace
+ \def\baselinestretch{\setspace@singlespace}%
+ \fi
\reset@font\footnotesize
\hsize\MFL@columnwidth \@parboxrestore
\interlinepenalty\FN@specific\FN@masterinsert\interfootnotelinepenalty
@@ -798,16 +831,16 @@
\finalfootnotewidowpenalty=4000
% \end{macrocode}
% \begin{macro}{\@makefnvbox}
-% This is the formatting code for a vertical mode footnote box. It
-% uses \cmd{\@makefnstartbox} for setting up the initial widow/club
-% penalties, and \cmd{\@makefnendbox} for preparing the final end. It
-% results in a vbox, but its argument, a stream of horizontal and
-% vertical material, is typeset in
+% This is the formatting code for a vertical mode footnote box from
+% already set horizontal material. It uses \cmd{\@makefnstartbox}
+% for setting up the initial widow/club penalties, and
+% \cmd{\@makefnendbox} for preparing the final end. It results in a
+% vbox.
% \begin{macrocode}
\ifx\@makefnvbox\@undefined
\def\@makefnvbox#1{\vbox{%
\@makefnstartbox
- \clubpenalties\tw@\@MM\clubpenalty
+ \clubpenalties\thr@@\@MM\clubpenalty\z@
\let\@thefnmark\@empty
\FN@specific\FN@masterinsert\@makefntext{\rule\z@\footnotesep
\nobreak
@@ -821,15 +854,12 @@
% Those parameters govern when a footnote block is going to be set
% completely in vertical mode. If a footnote block does not shrink
% to less than \cmd{\hfootfraction} its size when using in-paragraph
-% notes and, has at least \cmd{\vtypefraction} of forcedly vertical
+% notes or has at least \cmd{\vtypefraction} of forcedly vertical
% footnotes (specified as purely vertical, or vertical because of
% being large), it is set entirely in vertical mode.
-%
-% In addition, the ratio of purely vertical footnotes must not fall
-% below \cmd{\vtypefraction}.
% \begin{macrocode}
\def\hfootfraction{0.9}
-\def\vtypefraction{0.6}
+\def\vtypefraction{0.7}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -875,12 +905,13 @@
\setbox\z@\@makefnvbox{%
{\unhbox\FN@tempbox}%
\setbox\z@\lastbox\FN@joinhboxes}%
- \ifdim\FN@vfound>\dimexpr\vtypefraction\p@*\FN@found\relax
- \ifdim\dimexpr \ht\z@+\dp\z@>\hfootfraction\dimen@ii
- \global\setbox\FN@tempbox\box\tw@
- \setbox\z@\@makefnvbox{\let\@makefnbreak\FN@pseudofillbreak
- {\unhbox\FN@tempbox}\setbox\z@\lastbox\FN@joinhboxes}%
- \fi
+ \ifcase
+ \ifdim\FN@vfound>\dimexpr\vtypefraction\p@*\FN@found\relax \@ne\fi
+ \ifdim\dimexpr \ht\z@+\dp\z@>\hfootfraction\dimen@ii \@ne\fi \z@
+ \or
+ \global\setbox\FN@tempbox\box\tw@
+ \setbox\z@\@makefnvbox{\let\@makefnbreak\FN@pseudofillbreak
+ {\unhbox\FN@tempbox}\setbox\z@\lastbox\FN@joinhboxes}%
\fi
\setbox\tw@\box\voidb@x
\ht\z@\dimexpr \ht\z@+\dp\z@-\dimen@\relax
@@ -958,8 +989,8 @@
% calculation.
% \begin{macrocode}
\def\FN@pseudobreak{%
- {\parskip\z@skip\parfillskip\z@skip\parindent\z@\vadjust{}\par\noindent
- \vadjust{\nobreak\vskip-\baselineskip}\nobreak\hfill\break}}
+ {\parskip\z@skip\parfillskip\z@skip\parindent\z@\vadjust{}\par\noindent
+ \vadjust{\nobreak\vskip-\baselineskip}\nobreak\hfill\break}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\FN@pseudofillbreak}
@@ -967,7 +998,7 @@
% \begin{macrocode}
\def\FN@pseudofillbreak{\nobreak\hskip\parfillskip\FN@pseudobreak}
% \end{macrocode}
-%
+%
% \end{macro}
% \begin{macro}{\@makefnbreak}
% This calculates the glue for the standard horizontal footnotes.
@@ -1144,7 +1175,7 @@
% insertion level.
% \begin{macrocode}
\ifnum#2<\FN@masterinsert
- \FN@colorstackbgroup\MFL@minipage
+ \FN@colorstackbgroup\FN@divert
\FN@newslot\FN@masterslot
\count@\FN@id
% \end{macrocode}
@@ -1185,75 +1216,114 @@
\else \FN@specific{#2}\@preparefnhtext \normalcolor
\fi
% \end{macrocode}
-% After preparation, we now do the big bad trick for making
-% footnotes cooperate with \cmd{\verb} and other catcode changing
-% things: we call \cmd{\@makefntext} with an argument of
-% |\iffalse|. This kills off its expansion right at the point
-% where it would choose to place its argument.
+% Ok, now we do the call to \cmd{\@makefntext} which may occur in
+% one of several ways, depending on whether the `robust' or the
+% `fragile' package option got used.
% \begin{macrocode}
- \FN@specific{#2}\@makefntext
- \iffalse\fi
+ \expandafter \FN@makefncall
+ \else
+% \end{macrocode}
+% We still needed to cater for the error of badly anchored footnotes:
+% \begin{macrocode}
+ \PackageError{bigfoot}{#2 forbidden in \FN@masterinsert.}%
+ {Higher-placed footnotes can't be anchored in inferior ones.^^J%
+ I am not putting this text in a footnote. History:%
+\FN@errorstack}%
+ \rule{1em}{\ht\strutbox}%
+\fi}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\FN@makefnstart}
+% This is called in the start of \cmd{\@makefntext}.
+% \begin{macrocode}
+\providecommand{\FN@seitenobreak}{\nobreak}
+\def\FN@makefnstart{%
% \end{macrocode}
% Record the footnote specific dimensions. It is assumed that they
% don't change in the document, at least not before the footnote
% gets actually placed.
% \begin{macrocode}
- \expandafter\xdef\csname FN@ht\number#2\endcsname{\the\footnotesep}%
- \expandafter\xdef\csname FN@dp\number#2\endcsname{\the\dp\strutbox}%
+ \expandafter\xdef\csname FN@ht\number\FN@masterinsert\endcsname
+ {\the\footnotesep}%
+ \expandafter\xdef\csname FN@dp\number\FN@masterinsert\endcsname
+ {\the\dp\strutbox}%
+ \expandafter\xdef\csname FN@wd\number\FN@masterinsert\endcsname
+ {\the\hsize}%
% \end{macrocode}
% The footnote gets markers for identifying it and its starting block.
% \begin{macrocode}
- \marks\FN@master{\FN@masterslot}%
- \marks\FN@slave{\number\FN@id}%
- \nobreak
- \bgroup
- \aftergroup\FN@commonending
+ \marks\FN@master{\FN@masterslot}%
+ \marks\FN@slave{\number\FN@id}%
+ \nobreak
% \end{macrocode}
% \cmd{\FN@commonending} will intervene before any tokens that are
% shifted in due to switching back the color stack. Those will only
% be executed once we completely relinquish control.
% \begin{macrocode}
- \ifx\FN@boxtype\vbox
- \rule\z@\footnotesep
- \else
- \ifx\FN@par\par\else
- \let\FN@@par\par
- \let\FN@@noindent\noindent
- \let\FN@@indent\indent
- \fi
- \everyvbox\expandafter{\expandafter\everyvbox
- \expandafter{\the\everyvbox}%
- \let\par\FN@@par
- \let\noindent\FN@@noindent
- \let\indent\FN@@indent
- \the\everyvbox}%
- \let\par\FN@par
- \let\noindent\FN@noindent
- \let\indent\FN@indent
- \fi
- \afterassignment\ignorespaces
- \expandafter\FN@fnotecommonii
- \else
+ \ifx\FN@boxtype\vbox
+ \rule\z@\footnotesep
+ \else
+ \ifx\FN@par\par\else
+ \let\FN@@par\par
+ \let\FN@@noindent\noindent
+ \let\FN@@indent\indent
+ \fi
+ \everyvbox\expandafter{\expandafter\everyvbox
+ \expandafter{\the\everyvbox}%
+ \let\par\FN@@par
+ \let\noindent\FN@@noindent
+ \let\indent\FN@@indent
+ \the\everyvbox}%
+ \let\par\FN@par
+ \let\noindent\FN@noindent
+ \let\indent\FN@indent
+ \fi
+ \FN@seitenobreak
+ \afterassignment\ignorespaces}
% \end{macrocode}
-% We still needed to cater for the error of badly anchored footnotes:
+% \end{macro}
+% \begin{macro}{\FN@makefnrobust}
+% After preparation, we now do the big bad trick for making
+% footnotes cooperate with \cmd{\verb} and other catcode changing
+% things: we call \cmd{\@makefntext} with an argument of
+% |\iffalse|. This kills off its expansion right at the point
+% where it would choose to place its argument.
+%
+% Furthermore, this swallows the opening brace of the footnote text
+% and then lets the footnote text progress. The closing group will
+% then trigger the processing via \cmd{\aftergroup}.
% \begin{macrocode}
- \PackageError{bigfoot}{#2 forbidden in \FN@masterinsert.}%
- {Higher-placed footnotes can't be anchored in inferior ones.^^J%
- I am not putting this text in a footnote. History:%
-\FN@errorstack}%
- \rule{1em}{\ht\strutbox}%
-\fi}
+\def\FN@makefnrobust#{%
+ \FN@specific\FN@masterinsert\@makefntext
+ \iffalse\fi
+ \bgroup
+ \aftergroup\FN@robustending
+ \FN@makefnstart
+ \let\next}
% \end{macrocode}
% \end{macro}
-% \begin{macro}{\FN@fnotecommonii}
-% This just swallows the opening brace of the footnote text and then
-% lets the footnote text progress. The closing group will then
-% trigger the processing via \cmd{\aftergroup}.
+% \begin{macro}{\FN@robustending}
+% Here we put in the missing part of \cmd{\@makefntext}.
% \begin{macrocode}
-\def\FN@fnotecommonii#{\let\next}
-% \end{macrocode}
+\def\FN@robustending{%
+ \expandafter\expandafter\expandafter
+ \expandafter\expandafter\expandafter\expandafter
+ \iffalse \FN@specific\FN@masterinsert\@makefntext\fi
+ \FN@commonending}
+% \end{macrocode}
% \end{macro}
-% % Ok, color handling is a nuisance, to say the least. Split
+% \begin{macro}{\FN@makefnfragile}
+% This is the escape route when the robust variant does not work.
+% In that case, |\verb| and similar won't work in footnotes.
+% \begin{macrocode}
+\long\def\FN@makefnfragile#1{%
+ \FN@specific\FN@masterinsert\@makefntext
+ {\FN@makefnstart#1\FN@commonending}}
+% \end{macrocode}
+%
+% \end{macro}
+%
+% Ok, color handling is a nuisance, to say the least. Split
% footnotes need to close their color stack on the old page, and reopen
% it on the new one. So we record the color stack state at each time
% it changes in a marks register.
@@ -1271,8 +1341,8 @@
\let\reset@color\FN@reset@color
\let\color@begingroup\FN@color@begingroup}
-\def\FN@colorstackegroup{\egroup\ifx\FN@colorstack\@empty
- \global\let\FN@colorstack\FN@savecolorstack \fi}
+\def\FN@colorstackegroup{\egroup
+ \global\let\FN@colorstack\FN@savecolorstack}
\def\FN@colorstackfinish{\def\@elt##1##2{\FN@@reset@color##2}%
\FN@colorstack
@@ -1317,9 +1387,6 @@
% standard ones) happens to work.
% \begin{macrocode}
\def\FN@commonending{%
- \expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\expandafter
- \iffalse \FN@specific\FN@masterinsert\@makefntext\fi
\@makefnendbox
\ifx\FN@boxtype\vbox\@finalstrut\strutbox \else \unskip \fi
\FN@colorstackfinish
@@ -1359,9 +1426,12 @@
% footnotes belong to this one.
% \begin{macrocode}
\MFL@insert\FN@masterinsert{\nointerlineskip\box\z@}%
+ \ifdim\lastkern=\z@ \let\FN@next\@empty\else
+ \edef\FN@next{\kern\the\lastkern\relax}\unkern
+ \fi
\marks\FN@slave{\number\FN@id}%
- \MFL@endminipage
- \FN@colorstackegroup
+ \expandafter\FN@enddivert\expandafter\FN@colorstackegroup
+ \FN@next
}
% \end{macrocode}
% \end{macro}
@@ -1427,15 +1497,15 @@
\ifcase
\ifvoid\z@\m@ne\fi \FN@config\z@
%<trace> \if\foottrace8\message{^^J\string\FN@retaindelayed:
-%<trace> dropping box \FN@slotget{\number\dp\z@}}\fi
+%<trace> dropping Id \FN@slotget{\number\dp\z@}}\fi
%<trace> \if\foottrace{16}{\showboxdepth4 \showboxbreadth400
%<trace> \tracingonline=\@ne\showbox\z@}\fi
\ifnum\dp\z@=\count@\else \FN@freeslot{\number\dp\z@}\fi
%<trace> \ifnum\dp\z@<\@ne \errmessage{Unidentified box}\fi
- \FN@retaindelayed
+ \expandafter\FN@retaindelayed
\or
%<trace> \if\foottrace8\message{^^J\string\FN@retaindelayed:
-%<trace> retaining box \FN@slotget{\number\dp\z@}}\fi
+%<trace> retaining Id \FN@slotget{\number\dp\z@}}\fi
%<trace> \if\foottrace{16}{\showboxdepth4 \showboxbreadth400
%<trace> \tracingonline=\@ne\showbox\z@}\fi
{\FN@retaindelayed \nointerlineskip \box\z@}%
@@ -1681,8 +1751,9 @@
\expandafter\expandafter\expandafter\let\FN@cache\FN@savebox=\@cclv
-\expandafter\def\csname FN@ht\number\FN@savebox\endcsname{\topskip}%
+\expandafter\def\csname FN@ht\number\FN@savebox\endcsname{\z@skip}%
\expandafter\def\csname FN@dp\number\FN@savebox\endcsname{\maxdepth}
+\expandafter\def\csname FN@wd\number\FN@savebox\endcsname{\columnwidth}
\def\FN@list{\MFL@list\@elt{}\footins}
@@ -1705,7 +1776,8 @@
% \end{macrocode}
% \begin{macro}{\FN@removecheck}
% This returns |\@ne| if and only if the current slot master is strictly
-% inside of the specified interval.
+% inside of the specified open interval. In this case it is not to
+% appear on the current page.
% \begin{macrocode}
\def\FN@removecheck#1#2{%
\ifnum#1<\FN@slotget{\number\dp\z@} %
@@ -1806,7 +1878,8 @@
\def\FN@insertmarks{%
{\setbox\z@\copy\@cclv
\splittopskip-\maxdimen\relax
- \vbadness=\maxdimen
+ \vbadness=\@M
+ \vfuzz=\maxdimen
\loop
\ifvoid\z@\else
{\let\@elt\FN@pseudomarks
@@ -1827,7 +1900,10 @@
% a complicated expression if you want to, for example by checking
% the presence of particular footnotes.
% \begin{macrocode}
+\def\FootnoteMinimum{1sp}
\def\FootnoteMainMinimum{0pt}
+\expandafter\def\csname\string\FootnoteMinimum\number\FN@savebox
+\endcsname{\FootnoteMainMinimum}
% \end{macrocode}
% \end{macro}
%
@@ -1850,7 +1926,7 @@
% the next page). We then reinsert the remaining split insertions,
% any possibly split off page material and the penalty.
%
-% \TeX is rather monotonous in its page break processing. Increase
+% \TeX\ is rather monotonous in its page break processing. Increase
% the available page size, and the available page material will also
% increase. There is a singular exception to that rule, and that are
% split and floating insertions. However, we notice their presence by
@@ -1899,21 +1975,31 @@
% \item We are looking for missing insertions that may have floated.
% \end{enumerate}
%
-% In the situation where the page break has already been determined
-% (magic output penalty, looking for missing insertions), we are not
-% interested in `foreign' insertions like floating figures. The
-% current code does not cater for them.
+% We are trying to do bookkeeping on the effects of page size for
+% insertions that fall into the footnote class. While we do basic
+% bookkeeping for other insertions as well, this can only be
+% incomplete since we don't reinsert material. In consequence,
+% multiple material ending up in the same insertion might cause the
+% corresponding skip register to be accounted for several times.
+% \LaTeX\ does not really reuse insertions in that manner except for
+% footnotes, so we are mostly ok here.
+%
+% |bigfoot| usually does some lookahead in the main list in order to
+% obtain optimal breakpoints. It explicitly undoes the effect this
+% has on marks, but insertions are a different matter here. So floats
+% may appear on an earlier page than expected.
%
% If the output routine is invoked with a penalty of $-13750$, then
% the page content is merely used for setting the \cmd{\topmarks}
% array. In that case, we just clear out the output box and resume.
% We don't fiddle with \cmd{\deadcycles} in order to catch foulups.
+%
% Also we don't touch insertion boxes. There is a particular
% situation where there \emph{are} insertions, namely if we are
% collecting insertions after the last output routine has ended up
% with a non-zero value of \cmd{\insertpenalties}. In this case, all
% insertions we \emph{do} get are floating insertions, meaning that
-% the had a preceding insertion of the same class already on the last
+% they had a preceding insertion of the same class already on the last
% page, and thus we have zeroed its skip register already. We are
% assuming that a single pass with such a large \cmd{\vsize} is
% sufficient for pulling all insertions. If that happens to be
@@ -1921,12 +2007,15 @@
% are probably in big dodo with regard to page size accounting,
% anyway.
% \begin{macrocode}
+\newcount\FN@outputflag
+\FN@outputflag=3158345
\output{%
+ \let\@elt\relax
+ \ifvoid\@cclv \PackageError{bigfoot}{Empty box 255 in \output}\fi
%<trace> \if\foottrace8%
%<trace> \message{entering output with
%<trace> \outputpenalty=\the\outputpenalty:}%
-%<trace> \showbox\@cclv\fi
-% \ifnum\c@page=10 \traceon\fi
+%<trace> {\showboxdepth4\showboxbreadth\maxdimen\showbox\@cclv}\fi
\ifnum\outputpenalty=-13750
%<trace> \if\foottrace8%
%<trace> \message{Discarding box 255.}%
@@ -1937,7 +2026,7 @@
gather all floating insertions in a single pass.^^J%
Complain to the author if you consider this a bug}%
\fi
- \global\advance\FN@outervsize\dimexpr\ht\@cclv-\vsize\relax
+ \global\advance\FN@outervsize\dimexpr\ht\@cclv-\vsize
\global\setbox\@cclv\box\voidb@x
\else
% \end{macrocode}
@@ -1949,44 +2038,35 @@
\ifvoid\@holdpg
\FN@sweeptopmarks
\fi
- \ifvoid\@cclv
- \global\FN@outervsize\z@
- \else
- \global\FN@outervsize\ht\@cclv
- \global\setbox\@cclv\vbox{\unvbox\@cclv\boxmaxdepth\maxdepth}%
- \global\advance\FN@outervsize-\ht\@cclv\relax
- \fi
+ \FN@nest@iterate{\FN@insertouterspace\global\FN@outervsize
+ \dimexpr\z@}%
+ \global\advance\FN@outervsize\ht\@cclv
+ \global\setbox\@cclv\vbox{\unvbox\@cclv\boxmaxdepth\maxdepth}%
\global\let\FN@vsadjustlist\@empty
- \FN@normaloutput
% \end{macrocode}
-% \cmd{\FN@outervsize} now contains the amount of stretch that was put
-% into the output box in order to reach the goal size. So it is the
-% space we still have left available to fill given the current
-% \cmd{\vsize} and contents of insertions. Note that this can be
-% negative if shrinkability has been involved in getting at the value.
+% \cmd{\FN@outervsize} now contains the value of \cmd{\pagegoal} at
+% the time of output. It should be \cmd{\vsize} adjusted by the
+% natural size of insertions. Note that \cmd{\FN@normaloutput} is not
+% required to return with a sensible value of \cmd{\outputpenalty}.
% \begin{macrocode}
+ \FN@normaloutput
\else
% \end{macrocode}
% We now are in the situation that we already have collected material
-% previously. \cmd{\FN@outervsize} contains the overshoot according
-% to the difference of demanded and achieved space again. It remains
-% unchanged if we have inserted a special penalty ourselves: in this
-% case no page material has possibly been added. However, we can't be
-% sure that adding a special penalty does not take more than one
-% output routine call before delivery. For that reason, we don't rely
-% on special outputs being special and always subtract any
-% additionally demanded \cmd{\vspace} from \cmd{\FN@outervsize} before
-% calling a special output, so that we can afterwards compensate for
-% it.
-% \begin{macrocode}
- \ifvbox\@cclv
- \dimen@\ht\@cclv
- \global\setbox\@cclv\vbox{\unvbox\@cclv\boxmaxdepth\maxdepth}%
- \global\advance\FN@outervsize\dimexpr\dimen@-\ht\@cclv\relax
- \fi
+% previously. We can't be sure that adding a special penalty does not
+% take more than one output routine call before delivery. For that
+% reason, we don't rely on special outputs being special and always
+% subtract any additionally demanded \cmd{\vspace} from
+% \cmd{\FN@outervsize} before calling a special output, so that we can
+% afterwards compensate for it.
+% \begin{macrocode}
+ \FN@nest@iterate{\FN@insertouterspace\global\advance\FN@outervsize
+ \dimexpr\ht\@cclv}%
+ \global\setbox\@cclv\vbox{\unvbox\@cclv\boxmaxdepth\maxdepth}%
% \end{macrocode}
% Now we invalidate the cache boxes for all insertions that had
-% changed due to the recent additions to the page.
+% changed due to the recent additions to the page (this does
+% \emph{not} affect \cmd{\FN@vsize}).
% \begin{macrocode}
\FN@nest@iterate\FN@maybeinvalidatecache
% \end{macrocode}
@@ -2006,20 +2086,16 @@
\ifnum\FN@outputpenalty=-13749 \@ne\fi
\ifnum\FN@outputpenalty=-13751 \@ne\fi \tw@
\or
+% \end{macrocode}
+% \cmd{\outputpenalty} is restored to the original value before the
+% total page is glued together.
+% \begin{macrocode}
\FN@vsadjustlist
%<trace> \if\foottrace8\message{receiving special penalty
%<trace> \FN@outputpenalty, dissing box 255:}%
%<trace> {\showboxdepth4 \showboxbreadth400
%<trace> \tracingonline=\@ne\showbox\@cclv}\fi
% \end{macrocode}
-% We don't need to insert either discards or outputpenalties anywhere:
-% those are exclusively derived from our own inserted code.
-% Since the \cmd{\pagediscards} derive from our own insertion, we
-% clear them out. \cmd{\outputpenalty} is restored to the original
-% value before the total page is glued together.
-% \begin{macrocode}
- \global\setbox\@cclv\vbox{\pagediscards}%
-% \end{macrocode}
% This special penalty means that we have been collecting floated
% insertions right now. So |\box255| is actually empty except for
% filler material. We restore the old box into it.
@@ -2032,6 +2108,10 @@
\FN@normaloutput
\else
\the\FN@output
+ \@pageht-\vsize
+ \let\@currbox\footins
+ \@reinserts
+ \global\vsize-\@pageht
\fi
\else
\dimen@\topskip
@@ -2043,31 +2123,62 @@
% \end{macrocode}
% Ok, now we reconstruct the box from its parts. We add the material
% together, taking the previous output penalty and the current page
-% discards for glueing the stuff together. The previous output
+% discards (if it belongs between those boxes, otherwise we leave it
+% on the list) for glueing the stuff together. The previous output
% penalty then is irrelevant for further purposes and we replace it
% again. \cmd{\FN@outervsize} has been
% adjusted by the accumulated contributions of insertions to the page
% size. Fiddling with it would not appear necessary or even prudent.
% \begin{macrocode}
- \global\setbox\@cclv\vbox{\unvbox\z@
- \ifnum\outputpenalty<\@M \penalty\outputpenalty\fi
- \pagediscards
+%<trace>\if\foottrace8
+%<trace> \message{Box 255 before reglue
+%<trace> (outputpenalty=\the\outputpenalty):}%
+%<trace> {\showboxdepth4\showboxbreadth100\showbox\@cclv}\fi
+ \global\setbox\@cclv\vbox{%
% \end{macrocode}
% Now we might have had a \cmd{\topskip} value designed for requesting
% a given number of lines. We need to remove anything of that kind.
-% Splitting again achieves that.
+% Splitting again achieves that. If the current page was empty except
+% for insertions, this means that we gain a new breakpoint. But
+% insertions with discardable material before them would be unusual.
+%
+% The only exception to this may happen if the current page contained
+% only insertions: in this case \TeX\ has made a page break before the
+% actually inserted \cmd{\topskip} glue (which will then arrive one
+% page later).
+%
+% Note that the pagediscards contain material corresponding to the
+% last breakpoint chosen, so they will either start with a penalty
+% of~10000 (which is what an actual outputpenalty gets replaced with)
+% or will start with discardable material. We clean it for that
+% reason.
% \begin{macrocode}
- \ifvbox\@cclv
- \global\setbox\@cclv\vbox{\break\unvbox\@cclv}%
- {\splittopskip-\maxdimen \setbox\z@\vsplit\@cclv to\z@}%
- \unvbox\@cclv
+ \unvbox\z@
+ \global\setbox\@cclv\vbox{\break\unvbox\@cclv}%
+ {\splittopskip-\maxdimen \setbox\z@\vsplit\@cclv to\z@}
+ \ifnum\outputpenalty=\@M
+ \setbox\z@\vbox{\pagediscards
+ \FN@cleanpagepenalty}%
+ \unvbox\z@
+ \else
+ \penalty\outputpenalty
+ \pagediscards
\fi
+ \unvbox\@cclv
\boxmaxdepth\maxdepth}%
+%<trace>\if\foottrace8
+%<trace> \message{Box 255 reglued (outputpenalty=\FN@outputpenalty):}%
+%<trace> {\showboxdepth4\showboxbreadth100\showbox\@cclv}\fi
\global\outputpenalty\FN@outputpenalty\relax
% \end{macrocode}
% Ok, now if \cmd{\topskip} is actually \emph{positive}, we have been
% collecting material tentatively without having proper marks. We
-% then need to fill in the marks into the list and try again.
+% then need to fill in the marks into the list and try again. Note
+% that we are not reinserting anything in order to compensate for
+% \cmd{\outputpenalty} being replaced by a nobreak: this is the job of
+% \cmd{\FN@normaloutput} when it decides to place material back on the
+% page. That is: when code is written that will make use of
+% pagediscards, it has to cater for their proper structure.
% \begin{macrocode}
\ifdim\dimen@>\z@
%<trace> \if\foottrace8
@@ -2076,9 +2187,11 @@
\hrule\@height\z@\@depth\z@
\unvcopy\FN@topmarkbox
\penalty-13750
+ \penalty\FN@outputflag
\hrule\@height\z@\@depth\z@
\FN@insertmarks
\penalty-13749
+ \penalty\FN@outputflag
\FN@prepareoutput
\global\topskip-\maxdimen
\global\vsize0.5\maxdimen
@@ -2095,9 +2208,10 @@
% Now we have recovered a sensible state and glued everything together
% that has been necessary. All insertion parameters are at their
% standard values, and any insertions have been collected in the
-% respective boxes. If the whole exercise has been
+% respective boxes.
% \begin{macrocode}
\def\FN@normaloutput{%
+%<trace> \if\foottrace8\message{^^JEntering \string\FN@normaloutput:^^J}\fi
% \end{macrocode}
% \cmd{\FN@vsize} is now being set to the vertical size taken up by
% the insertions, according to \TeX. Note that this does not include
@@ -2107,23 +2221,28 @@
% size was taken from \cmd{\pagegoal}, and we reconstitute it in this
% manner.
% \begin{macrocode}
- \FN@nest@iterate{\FN@insertouterspace\global\FN@vsize\dimexpr\z@}%
+ \global\FN@vsize\FN@outervsize
+ \global\advance\FN@vsize-\ht\@cclv\relax\relax
% \end{macrocode}
% Now we sort the inserts and regenerate the cache.
% \begin{macrocode}
\FN@nest@iterate\FN@sortinsert
\FN@nest@iterate\FN@clearcache
- \xdef\FN@config{\noexpand\@elt{\number0\botmarks\FN@slave}%
+ \xdef\FN@config{\@elt{\number0\botmarks\FN@slave}%
{\number\maxdimen}}%
+%<trace> \if\foottrace8%
+%<trace> \message{\noexpand\FN@normaloutput start config: \FN@config^^J}%
+%<trace> \fi
\FN@nest@iterate\FN@reconfig
% \end{macrocode}
% Note that \cmd{\FN@reconfig} subtracts the \emph{actual} size of all
% insertions (after paragraphs have been combined and too early
% insertions moved to the next page) and also subtracts the flexible
% glues associated with the insertions' skip registers, so this
-% flexibility is typically negative.
+% flexibility is typically negative. Since the cache registers have
+% been explicitly cleared, \cmd{\FN@reconfig} starts from the state
+% where indeed no insertions are present.
% \begin{macrocode}
- \global\advance\FN@vsize\FN@outervsize\relax
\ifcase
\ifnum\insertpenalties>\z@ \@ne\fi
% \end{macrocode}
@@ -2150,53 +2269,71 @@
% \begin{macrocode}
\ifdim\FN@vsize<\glueshrink\FN@vsize \thr@@ \fi
% \end{macrocode}
-%
% page has appropriate size or we have special penalty. If we have
% come here not the first time, we might have arrived at a non-optimal
% break. So we attempt a split.
% \begin{macrocode}
\ifx\FN@vsadjustlist\@empty \else \thr@@\fi\z@
- \ifvbox\@cclv
- {\vbadness\maxdimen
- \global\setbox\@cclv\vbox
- spread\FN@vsize{\unvbox\@cclv\boxmaxdepth\maxdepth}}%
- \fi
+% \end{macrocode}
+% Ok, now we get the default case in our big routine: case~0. We just
+% pass the result onto the output routine.
+% \begin{macrocode}
+ {\vbadness\@M
+ \vfuzz\maxdimen
+ \global\setbox\@cclv\vbox
+ spread\FN@vsize{\unvbox\@cclv\boxmaxdepth\maxdepth}}%
\the\FN@output
+ \let\@currbox\footins
+ \@pageht-\vsize
+ \@reinserts
+ \global\vsize-\@pageht
\FN@nest@iterate\FN@clearcache
\or
% \end{macrocode}
-% Case 1: We just pull in remaining insertions and are done.
+% Case 1: We just pull in remaining insertions and are done. Note
+% that the special penalty here will get turned into an explicit
+% nobreak. So if we have no record of an actual outputpenalty, we
+% need to insert an artificial penalty of 0 here.
% \begin{macrocode}
\FN@restartoutput
\penalty -13749
+ \penalty \FN@outputflag
+ \or
% \end{macrocode}
-% Now we want to gather additional material. This is somewhat weird.
-% We first gather our material with a `normal' setting of topskip, and
-% then we'll have another go at the material using proper marks. We
-% can't actually insert anything right now in order not to introduce a
-% premature breakpoint.
+% Case 2: Now we want to gather additional material. This is somewhat
+% weird. We first gather our material with a `normal' setting of
+% topskip, and then we'll have another go at the material using proper
+% marks. We can't actually insert anything right now in order not to
+% introduce a premature breakpoint.
% \begin{macrocode}
- \or
\dimen@=\dimexpr\FN@vsize-\glueshrink\FN@vsize\relax
\FN@prepareoutput
\global\topskip \normalbaselineskip
- \global\vsize \dimen@
+ \global\vsize \dimen@
\global\advance\FN@outervsize-\vsize
\global\deadcycles\z@
\else
% \end{macrocode}
-% Fake our output box into something looking like a cache box
+% This is case 3: Fake our output box into something looking like a
+% cache box and do the optimal split routine. The output cache box
+% has a few deficiencies: its inner box is \emph{not} depth-extended
+% to some default measurement. That means that where page size
+% calculations are involved, one needs to \emph{disregard} its actual
+% depth and instead use \cmd{\maxdepth}. This is somewhat awkward and
+% prone to problems. One alternative might be to mark the box as
+% split, extend its depth in the split part and let it be followed by
+% nothing as lower part of the split. But we still would need to
+% account for the missing depth at the end.
% \begin{macrocode}
\edef\FN@masterid{\number\maxdimen}%
\def\FN@masterslot{-1}%
- \global\setbox\@cclv\vbox{%
- \box\@cclv}%
+ \global\setbox\@cclv\vbox{\box\@cclv}%
\xdef\FN@config{\noexpand\@elt{\number0\botmarks\FN@slave}%
{\number\maxdimen}}%
%<trace> \ifvoid\FN@savebox \else \PackageError{bigfoot}{\FN@savebox
%<trace> \space should be void!}{}\fi
\global\setbox\FN@savebox\vbox{}%
- \gdef\FN@badness{0}%
+ \gdef\FN@penalties{0}%
\edef\FN@defaultpenalty{\ifnum\outputpenalty<\@M
\number\outputpenalty
\else
@@ -2206,46 +2343,64 @@
\let\@elt\relax
%<trace> \if\foottrace8{\showboxdepth4\showboxbreadth100\showbox\@cclv}\fi
\global\setbox\FN@savebox\box\voidb@x
- \count@\vbadness
- \vbadness\maxdimen
- \global\setbox\@cclv\vbox spread\FN@vsize\bgroup
- \unvbox\@cclv
- \ifnum\lastpenalty>\z@
- \unpenalty
- \global\setbox\FN@tempbox\lastbox
- \else
- \global\setbox\FN@tempbox\box\voidb@x
- \fi
- \setbox\z@\lastbox
- \ifvoid\z@
- \ifvbox\FN@tempbox
- \ifnum\outputpenalty<\@M
- \global\setbox\FN@tempbox{\unvbox\FN@tempbox
- \penalty\outputpenalty}%
- \fi
- \global\outputpenalty=\@M
+ {%
+ \vbadness\@M
+ \vfuzz\maxdimen
+ \global\setbox\@cclv\vbox spread\FN@vsize{%
+ \unvbox\@cclv
+ \ifnum\lastpenalty>\z@
+ \unpenalty
+ \global\setbox\FN@tempbox\lastbox
+ \else
+ \global\setbox\FN@tempbox\box\voidb@x
\fi
- \egroup \global\setbox\@cclv\box\voidb@x
- \else
- \MFL@removevboxes
- \unvbox\z@
- \let\FN@defaultpenalty\@M
- \FN@getbreakpenalty
\setbox\z@\lastbox
- \ifcase
- \ifvbox\FN@tempbox \@ne\fi
- \ifvoid\z@ \else \@ne\fi \z@
- \or
- \global\setbox\FN@tempbox\vbox{\unvbox\z@
- \unvbox\FN@tempbox
+% \end{macrocode}
+% Now if a split has been done, |\box\FN@tempbox| contains the lower
+% part of the split. In either case, |\box\z@| contains the upper
+% part of the split (in a prepared form with the splitdiscards in a
+% box of their own). This may be void if there is no main text but
+% only footnotes. If we have carryover material, we add the current
+% outputpenalty there and set outputpenalty to a value indicating that
+% we have no outputpenalty to add at the end of the current list.
+% \begin{macrocode}
+ \ifvoid\z@
+ \ifvbox\FN@tempbox
\ifnum\outputpenalty<\@M
- \penalty\outputpenalty
- \fi}%
- \global\outputpenalty\FN@breakpenalty
+% The output penalty originally from below the split box gets appended
+% to the end of the split box.
+ \global\setbox\FN@tempbox{\unvbox\FN@tempbox
+ \penalty\outputpenalty}%
+ \fi
+ \global\outputpenalty=\@M
+ \fi
+ \else
+% \end{macrocode}
+% Ok, we have material to go to the next page. We unpack it and fish
+% out the break penalty from the last box. After checking it, put it in
+% box~0. A prospective current break penalty gets appended to the
+% carryover material. The fished-out break penalty becomes the new
+% value of outputpenalty.
+% \begin{macrocode}
+ \MFL@removevboxes
+ \unvbox\z@
+ \edef\FN@defaultpenalty{\number\@M}%
+ \FN@getbreakpenalty
+ \setbox\z@\lastbox
+ \global\setbox\FN@tempbox\vbox\bgroup\unvbox\z@
+ \unvbox\FN@tempbox
+ \ifnum\lastnodetype<\z@
+ \egroup\global\setbox\FN@tempbox\box\voidb@x
+ \else
+ \ifnum\outputpenalty<\@M
+ \penalty\outputpenalty
+ \fi
+ \egroup
+ \global\outputpenalty\FN@breakpenalty
+ \fi
\fi
- \boxmaxdepth\maxdepth\egroup
- \fi
- \vbadness\count@
+ \boxmaxdepth\maxdepth}%
+ }%
\setbox\z@\box\FN@tempbox
\let\@elt\relax
% \end{macrocode}
@@ -2259,25 +2414,32 @@
% general, we assume that if box~0 is nonvoid, we take the resulting
% split. Otherwise, if the page appears underfull, we pull in more
% material. If the page is not underfull, we can pass it to the
-% output routine.
+% output routine. If box~0 is void, the break was chosen at the
+% ultimate end of the vertical list. If it was not a forced break,
+% and if it is not an overfull case already, we pull in more material
+% in order to avoid widows in the main text.
% \begin{macrocode}
\dimen@=\dimexpr\FN@vsize-\glueshrink\FN@vsize\relax
\ifcase
- \ifvoid\z@ \else\thr@@\fi
+ \ifvoid\z@ \ifnum\outputpenalty>-\@M
+ \ifdim\dimen@<\z@ \else \@ne \fi
+ \fi
+ \else \thr@@
+ \fi
\ifdim\ht\@cclv<\normalbaselineskip \@ne\fi
\ifdim\dimen@<\normalbaselineskip \tw@\fi \@ne
\or
\FN@prepareoutput
\global\topskip \normalbaselineskip
\ifdim\dimen@<\normalbaselineskip \dimen@=2\baselineskip\fi
- \global\vsize \dimen@
+ \global\vsize \dimen@
\global\advance\FN@outervsize-\vsize
\global\deadcycles\z@
\or
%<trace> \if\foottrace8%
%<trace> \message{^^JOutput: config is \FN@config...}\fi
- \setbox\tw@\vbox{%
- \the\FN@output
+ \setbox\tw@\vbox{%
+ \the\FN@output
%<trace> \if\foottrace8%
%<trace> \ifnum\lastnodetype=\m@ne
%<trace> \message{^^JOutput: end without carryover^^J}%
@@ -2287,16 +2449,27 @@
%<trace> \tracingonline=\@ne\showbox\tw@
%<trace> \fi
%<trace> \fi
- }%
- \unvbox\tw@
- \unvbox\z@
- \FN@nest@iterate\FN@clearcache
- \or
+ }%
+ \unvbox\tw@
+ \unvbox\z@
+ \let\@currbox\footins
+ \@pageht-\vsize
+ \@reinserts
+ \global\vsize-\@pageht
+ \FN@nest@iterate\FN@clearcache
+ \or
\FN@restartoutput
\penalty -13751
+ \penalty\FN@outputflag
\unvbox\z@
+ \ifnum\outputpenalty>\@M
+ \else \penalty
+ \ifnum\outputpenalty=\@M \z@ \else\outputpenalty\fi
+ \fi
+ \fi
\fi
- \fi}
+%<trace> \if\foottrace8\message{^^JExiting \string\FN@normaloutput^^J}\fi
+}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\FN@prepareoutput}
@@ -2313,7 +2486,7 @@
% distance, we might have a problem here. There is no obvious way
% to avoid it, though.
% \begin{macrocode}
-\def\FN@prepareoutput{%
+\def\FN@prepareoutput{%
{\let\@elt\FN@recordinsertparam
\xdef\FN@vsadjustlist{%
\global\vsize=\the\vsize
@@ -2348,6 +2521,7 @@
\hrule\@height\z@\@depth\z@
\unvcopy\FN@topmarkbox
\penalty -13750
+ \penalty\FN@outputflag
\hrule\@height\z@\@depth\z@
\FN@insertmarks
\FN@prepareoutput
@@ -2452,11 +2626,11 @@
\nointerlineskip\copy\z@
\setbox\z@
\vbox{\unvbox\z@
- \count@\FN@defaultpenalty\relax
+ \count@\@M
\FN@getbreakpenaltyii
\xdef\FN@tempinfo{\edef\noexpand\FN@breakpenalty{%
- \number\ifnum\count@>-\@M \count@
- \else -\@M \fi}}}}%
+ \number\ifnum\count@=\@M \FN@defaultpenalty \else \count@\fi
+ }}}}%
\FN@tempinfo}
\def\FN@getbreakpenaltyii{%
@@ -2477,6 +2651,38 @@
\fi}
% \end{macrocode}
% \end{macro}
+% \begin{macro}{\FN@cleanpagepenalty}
+% This is used for removing initial infinite penalties from the
+% pagediscards: those are artifacts of the page break routine.
+% \begin{macrocode}
+\def\FN@cleanpagepenalty{%
+ \ifcase
+ \ifnum\lastnodetype<\z@ \m@ne\fi
+ \ifnum\lastnodetype<11 \@ne\fi
+ \ifnum\lastnodetype>13 \@ne\fi
+ \numexpr\lastnodetype-9\relax
+ \or
+ \PackageError{bigfoot}{Illegal node type}{This can't happen}%
+ \or
+ \skip@=\lastskip \unskip
+ \expandafter \FN@cleanpagepenalty \expandafter\vskip\the
+ \expandafter\skip@
+ \or
+ \dimen@=\lastkern \unkern
+ \expandafter \FN@cleanpagepenalty \expandafter\kern\the
+ \expandafter\dimen@
+ \or
+ \count@\lastpenalty \unpenalty
+ \ifnum\count@=\FN@outputflag
+ \unpenalty\expandafter\expandafter\expandafter\FN@cleanpagepenalty
+ \else
+ \expandafter\FN@cleanpagepenalty\expandafter
+ \penalty\the\expandafter\expandafter\expandafter\count@
+ \fi
+ \fi
+ \relax}
+% \end{macrocode}
+% \end{macro}
% \begin{macro}{\FN@mainsplitreturn}
% This is merely an argument delimiting control sequence to make it
% possible to figure out which recursion levels still need visiting.
@@ -2505,7 +2711,7 @@
% the remaining space.
% \begin{macrocode}
\def\FN@getbadness#1{%
- {\hfuzz\maxdimen\hbadness\maxdimen\setbox\z@\hbox to\z@{\hskip-#1}}}
+ {\hfuzz\maxdimen\hbadness\@M\setbox\z@\hbox to\z@{\hskip-#1}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\FN@newlevel}
@@ -2513,38 +2719,73 @@
% footnote level, recursing if necessary. The level list is
% delimited with \cmd{\FN@mainsplitreturn}. The whole thing is
% looped through while the splits are being optimized. While
-% recursing, \cmd{\FN@badness} contains the badness of the current
-% split configuration: a penalty of $10000$ for any split, plus the
-% penalty at the split points. \cmd{\FN@ebadness} is the same, but
-% also counting in the stretch badness for one particular
-% configuration. Ebadness does not make sense to evaluate more than
-% temporarily: it is not passed through the levels. Since
-% \cmd{\FN@badness} is globally tampered with, its value at entry is
-% saved in \cmd{\FN@entrybadness}.
+% recursing, \cmd{\FN@penalties} contains the accumulated penalities
+% of the current split configuration: a penalty of $10000$ for any
+% split (except the main list), plus the penalty at the split points
+% plus a `hangover' badness for the percentage of material carried
+% over to the following pages. If nothing is carried over, this
+% is~0, if more is carried over, we get a penalty according to the
+% proportion of carryover material, raised to the third power.
+% \begin{macro}{\footnotecarryratio}
+% The fractional variable \cmd{\footnotecarryratio} is used for
+% scaling the leftover material dimensions. After scaling with
+% \cmd{\footnotecarryratio}, the carried material is treated like
+% missing material in a glue calculation, while the stretchability
+% for this calculation is given by the total size of material before
+% breaking. So with a setting of~1, there should always be enough
+% stretchability, causing at most a penalty of~100. That's not very
+% effective, so we scale this up.
+%
+% The default value of~2 seems to provide a reasonable penalty for
+% leftover material. The actual purpose for this component of the
+% scoring is to penalize footnote blocks that seem to carry over
+% disproportionally much material to later pages.
+% \begin{macrocode}
+\providecommand\footnotecarryratio{2}
+% \end{macrocode}
+% \end{macro}
+% \cmd{\FN@ebadness} is an augmented value, but also counting in the
+% stretch badness for one particular configuration. Ebadness does
+% not make sense to evaluate more than temporarily: it is not passed
+% through the levels. Since \cmd{\FN@penalties} is globally
+% tampered with, its value at entry is saved in
+% \cmd{\FN@entrypenalties}. Whenever we recurse or return,
+% \cmd{\FN@vsize} contains the full information about the available
+% space on the page, even though locally we use \cmd{\FN@myvsize}, a
+% local value, to keep track of the locally reserved space. The
+% only time when we need to save \cmd{\FN@myvsize} should be when we
+% temporarily leave boxes in order to save the current
+% configuration.
% \begin{macrocode}
\def\FN@newlevel#1#2#3\FN@mainsplitreturn{%
\count@\FN@cache#2%
\ifvoid\count@
%<trace> \if\foottrace1\message{Page=\thepage #2 is empty, recursing with
%<trace> \the\FN@vsize^^J}%
-%<trace> \message{Config=\FN@config^^J}\fi
+%<trace> \message{Config=\unexpanded\expandafter{\FN@config}^^J}\fi
#3\FN@mainsplitreturn
%<trace> \if\foottrace1%
-%<trace> \message{Page=\thepage #2 was empty, returning with \the\FN@vsize^^J}%
-%<trace> \message{Config=\FN@config^^J}\fi
+%<trace> \message{Page=\thepage #2 was empty,
+%<trace> returning with \the\FN@vsize^^J}%
+%<trace> \message{Config=\unexpanded\expandafter{\FN@config}^^J}\fi
\else
-%<trace> \if\foottrace1\message{Entering #2 with \FN@badness}\fi
+%<trace> \if\foottrace1\message{Entering #2 with \FN@penalties,
+%<trace> \FN@vsize=\the\FN@vsize,^^J%
+%<trace> Config=\unexpanded\expandafter{\FN@config}^^J}\fi
{\def\FN@currentinsertion{#2}%
\def\FN@currentrecursion{#3}%
\let\FN@entryconfig\FN@config
- \let\FN@entrybadness\FN@badness
+ \let\FN@entrypenalties\FN@penalties
\splittopskip\csname FN@ht\number#2\endcsname\relax
\splitmaxdepth\csname FN@dp\number#2\endcsname\relax
- \vbadness=\maxdimen
+ \hsize\csname FN@wd\number#2\endcsname\relax
+ \vbadness=\@M
\vfuzz\maxdimen
\let\@elt\relax
\expandafter\FN@newleveli\expandafter}%
-%<trace> \if\foottrace1\message{Exiting #2 with \FN@badness}\fi
+%<trace> \if\foottrace1\message{Exiting #2 with \FN@penalties,
+%<trace> \FN@vsize=\the\FN@vsize,^^J%
+%<trace> Config=\unexpanded\expandafter{\FN@config}^^J}\fi
\fi}
% \end{macrocode}
% \end{macro}
@@ -2559,7 +2800,12 @@
% insertion, so we just subtract the whole insertion-related
% content. We'll add stuff into it when recursing.
% \begin{macrocode}
- \dimen@\dimexpr\ht\count@+\dp\count@\relax
+ \dimen@\dimexpr\ht\count@
+ \ifnum\FN@currentinsertion=\FN@savebox
+ +\maxdepth
+ \else
+ +\dp\count@
+ \fi\relax
\global\advance\FN@vsize\dimexpr \dimen@
*\count\FN@currentinsertion/\@m\relax\relax
% \end{macrocode}
@@ -2573,7 +2819,7 @@
% meaning of boxes on the various levels are:\par\noindent
% \begin{tabularx}{\linewidth}{ll@{:\hskip\tabcolsep}X}
% 0&box0&where stuff gets collected as tentative material to be
-% unboxed with |\FN@removevboxes| once the insertion gets readied
+% unboxed with \cmd{\FN@removevboxes} once the insertion gets readied
% for shipout\\
% 0&box2&the previous best split that was found\\\hline
% 1&box0&the material that gets worked off, the tail of the split\\
@@ -2595,12 +2841,20 @@
\ifnum\lastpenalty=\z@
\setbox\tw@\box\voidb@x
\setbox\z@\lastbox
- \FN@myvsize=\dimexpr\dimen@-\ht\z@-\dp\z@\relax
+ \FN@myvsize=\ifnum\lastnodetype<\z@
+ \z@
+ \else
+ \dimexpr\dimen@-\ht\z@-\dp\z@\relax
+ \fi
\else
% \end{macrocode}
% Now if the box has been split previously, we glue it back together
-% again.
+% again. Since the lower part of the split has been \emph{subtracted}
+% from the total in \cmd{\dimen@}, we need to put it back into the
+% equation here. \cmd{\dimen@} contains the size of the box after
+% padding split material has been added.
% \begin{macrocode}
+%<trace> \if\foottrace1\message{Regluing box 2}\fi
\unpenalty
\setbox\tw@\lastbox
\setbox\z@\lastbox
@@ -2618,10 +2872,14 @@
% these definitions here are made in \emph{inner} level, so they can't
% make it outside as the result of the optimization. If we drop out
% of here without superceding them, something's completely rotten.
+% ^^A Fixme: Alpha pruning could be implemented by calling with
+% ^^A \FN@bestcost already set at entry to the best badness at
+% ^^A the respective level.
% \begin{macrocode}
- \edef\FN@bestebadness{\number\maxdimen}%
+ \edef\FN@bestcost{\number\maxdimen}%
+ \let\FN@bestbadness\FN@bestcost
\let\FN@bestconfig\@undefined
- \let\FN@bestvsize\z@skip
+ \def\FN@bestvsize{-\maxdimen}%
\let\FN@splitcolors\@empty
% \end{macrocode}
% Ok, first attempt. One interesting feature is that we will never
@@ -2631,13 +2889,16 @@
% bother about contributing too much. What we put in the box here
% can stay.
%
-% First we split to the remaining size. After having done so, we
-% continue splitting until we get the necessary mark of the last
-% footnote into our grasp: we can't split before that.
+% First we split to the remaining size. Since we still have all
+% subordinate footnotes considered fully, we need at least this split
+% size (in case of a configuration change, we will need more). After
+% having done the initial split, we continue splitting until we get
+% the necessary mark of the last footnote into our grasp: we can't
+% split before that.
% \begin{macrocode}
\ifnum\FN@currentinsertion=\FN@savebox
\else
- \def\FN@defaultpenalty{-\@M}%
+ \edef\FN@defaultpenalty{\number-\@M}%
\edef\FN@masterslot{\number\dp\z@}%
\edef\FN@masterid{\FN@slotget\FN@masterslot}%
\fi
@@ -2653,15 +2914,19 @@
% split, we want to have all available page stretchability properly
% taken into account. So we take the box, and add the available page
% stretchability at the top. Note that the stretchability is
-% registered negatively.
+% registered negatively. If we are on the main vertical list, an
+% empty page can be an acceptable option, so we add a penalty of zero
+% to account for that. Note that any prospective true penalties will
+% already have disappeared into the page break.
% \begin{macrocode}
\let\FN@splitcolors\@empty
\setbox\z@\vbox{\vskip-\glueexpr(\FN@vsize-\dimexpr\FN@vsize
\relax\@minus\glueshrink\FN@vsize)%
*\@m/\count\FN@currentinsertion
+ \penalty\z@
\unvbox\z@
\ifnum\FN@defaultpenalty>-\@M
- \penalty\FN@defaultpenalty\nointerlineskip
+ \penalty\FN@defaultpenalty\relax\nointerlineskip
\vbox to\maxdimen{}%
\fi}%
% \end{macrocode}
@@ -2672,10 +2937,11 @@
% \begin{macrocode}
\setbox\tw@\vsplit\z@ to%
\dimexpr\FN@vsize*\@m/\count\FN@currentinsertion
- -\FN@myvsize
+ -\FN@myvsize-\splitmaxdepth
\relax
\ifnum\FN@defaultpenalty>-\@M
\setbox\z@\vbox\bgroup\unvbox\z@\setbox\z@\lastbox
+ \unskip
\unpenalty
\ifnum\lastnodetype<\z@
\egroup \setbox\z@\box\voidb@x
@@ -2694,29 +2960,12 @@
*\@m/\count\FN@currentinsertion
\unvbox\tw@\boxmaxdepth\splitmaxdepth}%
% \end{macrocode}
-% Ok, now rinse and repeat if we don't have reached the last footnote
-% in the block. Or, if we are in the main block and have not reached
-% the necessary minimum size.
+% Ok, now rinse and repeat if we haven't reached the last footnote
+% in the block.
% \begin{macrocode}
\ifnum\FN@currentinsertion=\FN@savebox
\edef\FN@slaveid{\splitbotmarks\FN@slave}%
\FN@contribute@tw@
- \ifdim\FootnoteMainMinimum>\FN@myvsize
- \loop
- \setbox\tw@\vsplit\z@ to\z@
- \edef\FN@slaveid{\splitbotmarks\FN@slave}%
- \FN@contribute@tw@
- \ifcase\ifdim\FootnoteMainMinimum>\FN@myvsize
- \ifvoid\z@
- \@ne
- \else
- \tw@
- \fi\fi \z@
- \or
- \PackageWarning{bigfoot}{too little main material}%
- \else
- \repeat
- \fi
\else
\ifnum0\splitbotmarks\FN@master=\FN@masterslot \else
\loop
@@ -2774,7 +3023,7 @@
\dimexpr\FN@myvsize*\count\FN@currentinsertion/\@m \relax\relax}
% \end{macrocode}
% \end{macro}
-%
+%
% \subsubsection{Main label for reconsideration}
% When we are here, then there is not yet a split in the next footnote
% blocks scheduled. We might have to restitch stuff together here,
@@ -2806,20 +3055,43 @@
% the best previous one. Also we calculate the badness of the current
% situation.
% \begin{macrocode}
- \xdef\FN@badness{\number\FN@entrybadness}%
+ \xdef\FN@penalties{\number\FN@entrypenalties}%
\FN@checkcurrent
% \end{macrocode}
% No point in recursing if we can't beat the current best one.
% However, if we find a forced break, this is considered perfect as
% long as we are not overfull. Note that recursion can only increase
-% the badness if we are still underfull here.
+% the badness if we are still underfull here, so there is no point in
+% using \cmd{\FN@penalties} as the deciding factor of whether there may
+% be a point in recursing: the current ebadness (which is never less
+% than the badness) already is minimal.
% \begin{macrocode}
\ifnum
- \ifdim\skip@>\z@ \FN@ebadness \else \FN@badness \fi >\FN@bestebadness
+ \ifdim\skip@>\z@ \FN@ebadness \else \FN@penalties \fi
+ >\FN@bestcost\relax
+%<trace> \if\foottrace1%
+%<trace> \message{no recursion: \skip@=\the\skip@,
+%<trace> \noexpand\FN@bestvsize=\FN@bestvsize,
+%<trace> \noexpand\FN@ebadness=\FN@ebadness,
+%<trace> \noexpand\FN@penalties=\FN@penalties,
+%<trace> \noexpand\FN@bestcost=\FN@bestcost.}\fi
\else
- \xdef\FN@badness{\number\FN@entrybadness}%
+%<trace> \if\foottrace1%
+%<trace> \message{before recursion: \skip@=\the\skip@,
+%<trace> \noexpand\FN@bestvsize=\FN@bestvsize,
+%<trace> \noexpand\FN@ebadness=\FN@ebadness,
+%<trace> \noexpand\FN@penalties=\FN@penalties,
+%<trace> \noexpand\FN@bestcost=\FN@bestcost.^^J
+%<trace> recurse with \noexpand\FN@penalties=\number\FN@entrypenalties.}\fi
+ \xdef\FN@penalties{\number\FN@entrypenalties}%
\FN@vsizerecurse
\FN@checkcurrent
+%<trace> \if\foottrace1%
+%<trace> \message{after recursion: \skip@=\the\skip@,
+%<trace> \noexpand\FN@bestvsize=\FN@bestvsize,
+%<trace> \noexpand\FN@ebadness=\FN@ebadness,
+%<trace> \noexpand\FN@penalties=\FN@penalties,
+%<trace> \noexpand\FN@bestcost=\FN@bestcost.}\fi
\fi
% \end{macrocode}
% Don't look further if we had a forced break or are overfull or are
@@ -2839,25 +3111,60 @@
\FN@contribute@tw@
\expandafter \FN@splitfurther
\fi}
+% \end{macrocode}
% \end{macro}
% \begin{macro}{\FN@checkcurrent}
-% Check out the badness of the current configuration.
+% Check out the badness of the current configuration. The last box
+% on the list is the material constituting the discardable material
+% after a split.
% \begin{macrocode}
\def\FN@checkcurrent{%
+ \FN@getbreakpenalty
+ \ifnum\FN@breakpenalty<-\@M
+ \edef\FN@breakpenalty{\number-\@M}%
+ \fi
+ \ifnum\FN@currentinsertion=\FN@savebox
+ \else
+ \ifdim\FN@specific\FN@currentinsertion\footnotecarryratio\p@>\z@
+ \skip@
+ \ifdim\FN@specific\FN@currentinsertion\footnotecarryratio\p@>\p@
+ \dimexpr\ht\z@+\dp\z@\relax
+ \@plus-\dimexpr((\FN@myvsize+\ht\z@+\dp\z@)
+ *\p@/\dimexpr
+ \FN@specific\FN@currentinsertion
+ \footnotecarryratio\p@)\relax
+ \else
+ \FN@specific\FN@currentinsertion
+ \footnotecarryratio
+ \dimexpr\ht\z@+\dp\z@\relax
+ \@plus-\dimexpr\FN@myvsize+\ht\z@+\dp\z@\relax
+ \fi
+ \relax
+ \FN@getbadness\skip@
+ \xdef\FN@penalties{\number\numexpr\FN@penalties+\badness}%
+ \fi
+ \fi
\skip@\glueexpr\FN@vsize-\FN@myvsize
*\count\FN@currentinsertion/\@m\relax
- \FN@getbreakpenalty
\FN@getbadness\skip@
- \xdef\FN@badness{\number\numexpr\FN@badness+%
+ \xdef\FN@penalties{\number\numexpr\FN@penalties+%
\FN@breakpenalty+\@M}%
\ifnum\badness>\@M
\edef\FN@ebadness{\number\numexpr\maxdimen-\@ne}%
\else
\ifnum\badness=\@M
- \edef\FN@ebadness{\number\numexpr\maxdimen-\tw@}%
+ \ifdim\skip@<\vsize
+ \edef\FN@ebadness{\number\numexpr\maxdimen-\tw@}%
+ \else
+ \edef\FN@ebadness{\number\numexpr\maxdimen}%
+ \fi
\else
\edef\FN@ebadness{\number\numexpr
- \FN@badness+\badness}%
+ \FN@penalties+\badness
+ \ifdim\FN@specific\FN@currentinsertion\FootnoteMinimum>\FN@myvsize
+ 1000000
+ \fi
+ }%
\fi
\fi
\dimen@\glueexpr\FN@bestvsize\relax
@@ -2881,13 +3188,13 @@
% So we check if it is at least better than the last one, in which
% case we need to replace the previous best.
% \begin{macrocode}
- \ifnum\FN@bestebadness>\FN@ebadness \@ne\fi
- \ifnum\FN@bestebadness<\FN@ebadness \tw@\fi
+ \ifnum\FN@bestcost>\FN@ebadness \@ne\fi
+ \ifnum\FN@bestcost<\FN@ebadness \tw@\fi
\ifdim\skip@<\z@
- \ifdim\dimen@<\skip@ \@ne \else \tw@\fi
+ \ifdim\dimen@<\skip@ \@ne \fi \tw@
\fi
\ifdim\dimen@>\skip@ \@ne\fi \tw@}
-% \end{macrocode}
+% \end{macrocode}
% \end{macro}
% \begin{macro}{\FN@mayberecordbest}
% This checks whether the current configuration is better than a
@@ -2904,8 +3211,8 @@
\FN@checkforbest
\or
\xdef\FN@tempinfo{\def\noexpand\FN@bestvsize{\the\skip@}%
- \def\noexpand\FN@bestebadness{\FN@ebadness}%
- \def\noexpand\FN@bestbadness{\number\FN@badness}%
+ \def\noexpand\FN@bestcost{\FN@ebadness}%
+ \def\noexpand\FN@bestbadness{\number\FN@penalties}%
\def\noexpand\FN@bestconfig{\FN@config}%
\def\noexpand\FN@bestslaveid{\FN@slaveid}%
\def\noexpand\FN@bestsplitcolors{\FN@splitcolors}%
@@ -2933,9 +3240,7 @@
\copy\z@\break\nointerlineskip
\copy\FN@tempbox\penalty\FN@tempbox
\let\@elt\FN@copycachebox
- \FN@currentrecursion
- \xdef\FN@tempinfo{\FN@myvsize=\the\FN@myvsize\relax}}%
- \FN@tempinfo
+ \FN@currentrecursion}%
\setbox\z@
\vbox\bgroup
\unvbox\z@
@@ -2950,8 +3255,8 @@
\ifcase\FN@checkforbest
\or
\xdef\FN@tempinfo{\def\noexpand\FN@bestvsize{\the\skip@}%
- \def\noexpand\FN@bestebadness{\FN@ebadness}%
- \def\noexpand\FN@bestbadness{\number\FN@badness}%
+ \def\noexpand\FN@bestcost{\FN@ebadness}%
+ \def\noexpand\FN@bestbadness{\number\FN@penalties}%
\def\noexpand\FN@bestconfig{\FN@config}%
\def\noexpand\FN@bestslaveid{\FN@slaveid}%
\def\noexpand\FN@bestsplitcolors{\FN@splitcolors}%
@@ -2974,7 +3279,7 @@
\or
\global\let\FN@config\FN@bestconfig
\global\FN@vsize\FN@bestvsize
- \global\let\FN@badness\FN@bestbadness
+ \global\let\FN@penalties\FN@bestbadness
\egroup
% \end{macrocode}
% Restore the saved configuration.
@@ -2990,7 +3295,7 @@
\ifnum\FN@currentinsertion=\FN@savebox
\else
\setbox\z@\vbox{%
- \dimen@\dp\z@
+ \prevdepth\dp\z@
\unvbox\z@
\ifvoid\FN@tempbox
\else
@@ -2998,16 +3303,18 @@
\marks\FN@master{\FN@masterslot}%
\marks\FN@slave{\FN@slaveid}%
\FN@coloraftersplit\FN@splitcolors
+ \FN@specific\FN@currentinsertion\FN@afterbreak
\nobreak
\unvbox\FN@tempbox}%
+ \FN@specific\FN@currentinsertion\FN@beforebreak
\ht\FN@tempbox
\dimexpr\ht\FN@tempbox+\dp\FN@tempbox-\FN@masterslot sp\relax
\dp\FN@tempbox\FN@masterslot sp\relax
\wd\FN@tempbox\maxdimen
\fi
- \ifdim\dimen@<\splitmaxdepth
- \hrule\@height-\dimen@ \@width\z@
- \@depth \splitmaxdepth \relax \fi}%
+ \ifdim\prevdepth<\splitmaxdepth
+ \hrule\@height-\prevdepth \@width\z@
+ \@depth \splitmaxdepth \relax \fi}%
\ht\z@=\dimexpr\ht\z@+\dp\z@-\FN@masterslot sp\relax
\dp\z@=\FN@masterslot sp
\fi
@@ -3019,7 +3326,10 @@
\ifvoid\FN@tempbox \egroup
% \end{macrocode}
% If not, we add the carried-over box to the list, flag it with a
-% \cmd{\nobreak}, and subtract its size from the finished box.
+% \cmd{\nobreak}, and subtract its size from the finished box. Please
+% note that the \cmd{\expandafter} chain will expand just
+% |\cmd\dimen@|, but everything following it will be evaluated only
+% after \cmd{\egroup}, thus using the new height of the box.
% \begin{macrocode}
\else
\dimen@-\dimexpr\ht\FN@tempbox+\dp\FN@tempbox\relax
@@ -3032,7 +3342,7 @@
}
% \end{macrocode}
% \end{macro}
-%
+%
% \begin{macro}{\FN@contribute@tw@}
% This will go from the state where we have the previous
% \cmd{\splitdiscards} struttified on the current list some material
@@ -3155,6 +3465,7 @@
% \cmd{\FN@reconfig}.
% \begin{macrocode}
\def\FN@rejoin#1#2{{%
+%<trace> \if\foottrace1\message{^^JRejoining #2}\fi
\count@\FN@cache#2%
\ifvoid\count@\else
\global\advance\FN@vsize\dimexpr
@@ -3181,7 +3492,7 @@
\fi}}
% \end{macrocode}
% \end{macro}
-%
+%
% \begin{macro}{\FN@retainkept}
% This relies on \cmd{\@elt} being set to \cmd{\FN@removecheck} which
% expands to \cmd{\@ne} if |\box0| is strictly between the two values
@@ -3197,13 +3508,13 @@
\ifcase
\ifvoid\z@\m@ne\fi \FN@config\z@
%<trace> \if\foottrace8\message{^^J\string\FN@retainkept:
-%<trace> retaining box \FN@slotget{\number\dp\z@}}\fi
+%<trace> retaining Id \FN@slotget{\number\dp\z@}}\fi
%<trace> \if\foottrace{16}{\showboxdepth4 \showboxbreadth400
%<trace> \tracingonline=\@ne\showbox\z@}\fi
{\FN@retainkept \nointerlineskip \box\z@}%
\or
%<trace> \if\foottrace8\message{^^J\string\FN@retainkept:
-%<trace> dropping box \FN@slotget{\number\dp\z@}}\fi
+%<trace> dropping Id \FN@slotget{\number\dp\z@}}\fi
%<trace> \if\foottrace{16}{\showboxdepth4 \showboxbreadth400
%<trace> \tracingonline=\@ne\showbox\z@}\fi
\FN@retainkept
@@ -3246,20 +3557,17 @@
\csname MFL@start#1\endcsname{#2}\fi#3}
\@onlypreamble\FN@maybestart
\AtBeginDocument{\@ifundefined{footinsdefault}%
- {\DeclareNewFootnote[plain]{default}%
+ {\newfootnote[plain]{default}%
{\let\@elt\FN@maybestart
- \MFL@list\relax}}{}%
- \let\c@footnote\c@footnotedefault
- \let\thefootnote\thefootnotedefault
- \def\thefootnotedefault{\thefootnote}%
-}
+ \MFL@list\relax}
+ }{}%
% \end{macrocode}
% And since LaTeX's macros are inferior to our own (and would probably
% not match too well), we reroot them to the default footnote style.
% \begin{macrocode}
-\def\footnote{\footnotedefault}
-\def\footnotemark{\footnotemarkdefault}
-\def\footnotetext{\footnotetextdefault}
+ \def\@footnotetext{\Footnotetextdefault{}}
+ \def\p@footnotedefault{\p@footnote}
+}
%</style>
% \end{macrocode}
%
@@ -3272,7 +3580,7 @@
% is supposed to cater for the installation itself.
% \begin{macrocode}
%<installer> \input docstrip
-%<installer&make> \askforoverwritefalse
+%<installer&make> \askforoverwritefalse \nopreamble
%<installer> \generate{
%<installer> \file{bigfoot.drv}{\from{bigfoot.dtx}{driver}}
%<installer> \file{perpage.drv}{\from{perpage.dtx}{driver}}
diff --git a/Master/texmf-dist/source/latex/bigfoot/bigfoot.ins b/Master/texmf-dist/source/latex/bigfoot/bigfoot.ins
index 6f3200db1f4..f445cedcd79 100644
--- a/Master/texmf-dist/source/latex/bigfoot/bigfoot.ins
+++ b/Master/texmf-dist/source/latex/bigfoot/bigfoot.ins
@@ -1,28 +1,9 @@
%%
-%% This is file `bigfoot.ins',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% bigfoot.dtx (with options: `installer')
-%%
-%% IMPORTANT NOTICE:
-%%
-%% For the copyright see the source file.
-%%
-%% Any modified versions of this file must be renamed
-%% with new filenames distinct from bigfoot.ins.
-%%
-%% For distribution of the original source see the terms
-%% for copying and modification in the file bigfoot.dtx.
-%%
-%% This generated file may be distributed as long as the
-%% original source files, as listed above, are part of the
-%% same distribution. (The sources need not necessarily be
-%% in the same archive or directory.)
-%%
%% bigfoot is part of the bigfoot bundle for critical typesetting
-%% Copyright 2004, 05, 06 David Kastrup <dak@gnu.org>
+%% Copyright 2004--2014 David Kastrup <dak@gnu.org>
+%%
+%% The license notice and corresponding source code for this file are
+%% contained in bigfoot.dtx.
%%
\input docstrip
\generate{
diff --git a/Master/texmf-dist/source/latex/bigfoot/perpage.drv b/Master/texmf-dist/source/latex/bigfoot/perpage.drv
index d90ad19647f..1a520416b48 100644
--- a/Master/texmf-dist/source/latex/bigfoot/perpage.drv
+++ b/Master/texmf-dist/source/latex/bigfoot/perpage.drv
@@ -22,7 +22,10 @@
%% in the same archive or directory.)
%%
%% perpage is part of the bigfoot bundle for critical typesetting
-%% Copyright 2002, 03, 04, 05, 06 David Kastrup <dak@gnu.org>
+%% Copyright 2002--2014 David Kastrup <dak@gnu.org>
+%%
+%% The license notice and corresponding source code for this file are
+%% contained in perpage.dtx.
%%
\documentclass{ltxdoc}
\usepackage{perpage}
@@ -32,18 +35,6 @@
\AlsoImplementation
\DocInput{perpage.dtx}
\end{document}
-\def\pp@ppagectr#1#2#3#4{\@ifundefined{c@pp@a@#1}{}{%
- \def\next{#3}%
- \expandafter\ifx\csname pp@page@#1\endcsname\next
- \addtocounter{pp@a@#1}\@ne
- \else
- \setcounter{pp@a@#1}{\value{pp@r@#1}}%
- \fi
- \global\expandafter\let\csname pp@page@#1\endcsname\next
- \edef\next{\noexpand
- \@newl@bel{pp@r@#1}{#2}{{\number\value{pp@a@#1}}{#3}%
- {#4}}}\next}}
-
\endinput
%%
%% End of file `perpage.drv'.
diff --git a/Master/texmf-dist/source/latex/bigfoot/perpage.dtx b/Master/texmf-dist/source/latex/bigfoot/perpage.dtx
index 0209aa9e5d2..ad4be3ad782 100644
--- a/Master/texmf-dist/source/latex/bigfoot/perpage.dtx
+++ b/Master/texmf-dist/source/latex/bigfoot/perpage.dtx
@@ -1,7 +1,10 @@
% \iffalse
%%
%% perpage is part of the bigfoot bundle for critical typesetting
-%% Copyright 2002, 03, 04, 05, 06 David Kastrup <dak@gnu.org>
+%% Copyright 2002--2014 David Kastrup <dak@gnu.org>
+%%
+%% The license notice and corresponding source code for this file are
+%% contained in perpage.dtx.
%%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
@@ -17,7 +20,7 @@
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
% \fi
-% \CheckSum{363}
+% \CheckSum{396}
% \GetFileInfo{perpage.sty}
% \date{\filedate}
% \author{David Kastrup\thanks{\texttt{dak@gnu.org}}}
@@ -63,15 +66,15 @@
% \begin{quote}
% |\renewcommand{\thefigure}{\thepage-\arabic{figure}}|
% \end{quote}
-% you'll have the problem that \thepage is updated asynchronously with
-% the real page, since \TeX\ does not know which page the figure will
-% end up. If you have used the |perpage| package for modifying the
-% figure counter, however, at the point where the counter is
-% incremented, the macro \cmd{\theperpage} will be set to the correct
-% value corresponding to the actual page location. Note that this
-% macro is shared between all counters, so advancing a different
-% counter under control of |perpage| will render \cmd{\thefigure}
-% incorrect.
+% you'll have the problem that \cmd{\thepage} is updated
+% asynchronously with the real page, since \TeX\ does not know which
+% page the figure will end up. If you have used the |perpage| package
+% for modifying the figure counter, however, at the point where the
+% counter is incremented, the macro \cmd{\theperpage} will be set to
+% the correct value corresponding to the actual page location. Note
+% that this macro is shared between all counters, so advancing a
+% different counter under control of |perpage| will render
+% \cmd{\thefigure} incorrect.
%
% \DescribeMacro{\MakeSorted}
% \begin{quote}
@@ -152,18 +155,58 @@
% \end{macrocode}
%
% \section{The package interfaces}
-% First identification. We just use date and version from CVS.
+% First identification.
% \begin{macrocode}
%<*style>
\NeedsTeXFormat{LaTeX2e}
-\def\next$#1: #2 #3${#2}
-\ProvidesPackage{perpage}[\next$Date: 2006/07/15 21:43:23 $
- \next$Revision: 1.12 $ Reset/sort counters per page]
+\ProvidesPackage{perpage}[2014/10/25 2.0 Reset/sort counters per page]
+% \end{macrocode}
+% \begin{macro}{\pp@cl@begin}
+% \begin{macro}{\pp@cl@end}
+% These macros are considerable tricky. They are called as
+% artificial `dependent' counters when the counter they are hooked
+% into is advanced. The way in which those counters are called are
+% one of the following:
+% \begin{quote}
+% \begin{verbatim}
+% \def\@stpelt#1{\global\csname c@#1\endcsname \z@}
+% \end{verbatim}
+% \end{quote}
+% which is the default way of resetting a subordinate counter used
+% in \LaTeX, or
+% \begin{quote}
+% \begin{verbatim}
+% \def\@stpelt#1{\global\csname c@#1\endcsname \m@ne\stepcounter{#1}}
+% \end{verbatim}
+% \end{quote}
+% which is a little present from |fixltx2e.sty| as of 2014/05/01,
+% quite complicating this feat.
+%
+% The startup code swallows either |\global \advance| or |\global|.
+% \begin{macrocode}
+\def\pp@cl@begin{\z@\z@ \begingroup}
% \end{macrocode}
+% The command used for ending our fake counters checks for the
+% |\m@ne| condition. We don't want to bump our auxiliary counters
+% twice, so we remove the following |\stepcounter| command. Things
+% will go haywire if there is none, of course.
+% \begin{macrocode}
+\def\pp@cl@end{\afterassignment\pp@cl@end@ii \count@}
+\def\pp@cl@end@ii{%
+ \relax
+ \expandafter\endgroup
+ \ifnum\count@<\z@
+ \expandafter\pp@cl@end@iii
+ \fi}
+\def\pp@cl@end@iii\stepcounter#1{}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}{\AddAbsoluteCounter}
-% adds a counter with prefix |abs| to a given counter. It typesets as
-% an arabic number and never gets reset. And it is advanced with the
-% unprefixed counter.
+% adds a counter with prefix |abs| to a given counter. It typesets
+% as an arabic number and never gets reset. And it is advanced
+% whenever the unprefixed counter gets advanced.
% \begin{macrocode}
\newcommand\AddAbsoluteCounter[1]
{\@ifundefined{c@abs#1}{%
@@ -172,9 +215,9 @@
\global\expandafter\let\csname cl@abs#1\endcsname\@empty
\expandafter\xdef\csname theabs#1\endcsname{%
\noexpand\number \csname c@abs#1\endcsname}%
- \global\@namedef{c@pabs@#1}{\z@=\z@{%
- \stepcounter{abs#1}%
- \afterassignment}\count@}%
+ \global\@namedef{c@pabs@#1}{\pp@cl@begin
+ \stepcounter{abs#1}%
+ \pp@cl@end}%
\@addtoreset{pabs@#1}{#1}}{}}
% \end{macrocode}
% \end{macro}
@@ -294,7 +337,8 @@
\addtocounter{pp@a@#1}\m@ne
\@addtoreset{pchk@#1}{#1}%
\AtBeginDocument{\setcounter{pp@a@#1}\z@}%
- \edef\next{\noexpand\AtEndDocument{\noexpand\setcounter{pp@a@#1}{%
+ \edef\next{\noexpand\AtEndDocument
+ {\noexpand\setcounter{pp@a@#1}{%
\number\value{pp@a@#1}}}}\next}
\@onlypreamble\pp@makeperpage
% \end{macrocode}
@@ -329,12 +373,12 @@
% \begin{macrocode}
\def\pp@fetchctr#1{\expandafter\expandafter\expandafter\pp@fetchctrii
\csname pp@r@#1@\number\value{pp@a@#1}\endcsname
- \@empty\@empty}
+ {}{}}
\global\let\theperpage\@empty
-\def\pp@fetchctrii#1#2#3{\edef\pp@label{#1}%
- \edef\pp@page{#2}%
+\def\pp@fetchctrii#1#2#3{\def\pp@label{#1}%
+ \def\pp@page{#2}%
\gdef\theperpage{#3}}
% \end{macrocode}
% \end{macro}
@@ -352,8 +396,7 @@
% generic command. That is the reason we start off this command by
% giving \cmd{\global} something to chew on.
% \begin{macrocode}
-\def\c@pchk@#1{\z@=\z@
- \begingroup
+\def\c@pchk@#1{\pp@cl@begin
% \end{macrocode}
% Now we fetch the page value corresponding to the not yet adjusted
% value of the absolute counter to see whether the previous counter
@@ -379,18 +422,28 @@
% \begin{macro}{\pp@writectr}
% This is the common ending of all pseudo reset counters. It writes
% out an appropriate command to the |.aux| file with all required
-% information.
+% information. We try to replicate any sentinel kerns or penalties.
% \begin{macrocode}
\def\pp@writectr#1#2#3{\edef\next{%
\string#1{#2}{\number\value{pp@a@#2}}{#3}{\noexpand\thepage}}%
\pp@chkvlist
\dimen@=\lastkern
\ifdim\dimen@=\z@ \else \unkern\fi
+ \count@=\lastpenalty
\protected@write\@auxout{}{\next}%
- \ifdim\dimen@=\z@ \nobreak \else \kern\dimen@\fi
- \afterassignment\endgroup\count@}
+ \ifdim\dimen@=\z@
+ \penalty \ifnum\count@<\@M \@M \else \count@ \fi
+ \else \kern\dimen@\fi
+ \pp@cl@end}
% \end{macrocode}
% \end{macro}
+% \begin{macro}{\pp@labeldef}
+% This is a helper macro.
+% \begin{macrocode}
+\def\pp@labeldef#1#2#3#4#5{\@newl@bel{pp@r@#2}{#3}{{#1}{#4}{#5}}}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\pp@pagectr}
% This is the workhorse for normal per page counters. It is called
% whenever the |.aux| file is read in and establishes the
@@ -399,9 +452,8 @@
% \begin{macrocode}
\def\pp@pagectr#1#2#3#4{\@ifundefined{c@pp@a@#1}{}{%
\addtocounter{pp@a@#1}\@ne
- \edef\next{\noexpand
- \@newl@bel{pp@r@#1}{#2}{{\number\value{pp@a@#1}}{#3}%
- {#4}}}\next}}
+ \expandafter\pp@labeldef\expandafter
+ {\number\value{pp@a@#1}}{#1}{#2}{#3}{#4}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\c@schk@}
@@ -413,8 +465,7 @@
% get reset, too, so that the check for changed |.aux| files will
% still work.
% \begin{macrocode}
-\def\c@schk@#1{\z@=\z@
- \begingroup
+\def\c@schk@#1{\pp@cl@begin
\addtocounter{pp@a@#1}\@ne
\ifnum\value{#1}=\@ne
\expandafter\xdef\csname pp@g@#1\endcsname{\number\value{pp@a@#1}}%
@@ -436,9 +487,8 @@
\count@0\csname pp@g@#1@#3\endcsname
\advance\count@\@ne
\expandafter\xdef\csname pp@g@#1@#3\endcsname{\number\count@}%
- \edef\next{\noexpand
- \@newl@bel{pp@r@#1}{#2}{{\number\count@}{#3}%
- {#4}}}\next}}
+ \expandafter\pp@labeldef\expandafter
+ {\number\count@}{#1}{#2}{#3}{#4}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\c@spchk@}
@@ -448,14 +498,12 @@
% and it would be hard to decide what to do in case count groups and
% page positions overlap.
% \begin{macrocode}
-\def\c@spchk@#1{\z@=\z@
- \begingroup
+\def\c@spchk@#1{\pp@cl@begin
\addtocounter{pp@a@#1}\@ne
\pp@fetchctr{#1}%
\ifx\pp@page\@empty
\else \setcounter{#1}{\pp@label}\fi
\pp@writectr\pp@ppagectr{#1}{\noexpand\theabspage}}
-%</style>
% \end{macrocode}
% \end{macro}
% \begin{macro}{\pp@ppagectr}
@@ -468,16 +516,32 @@
\setcounter{pp@a@#1}{\value{pp@r@#1}}%
\fi
\global\expandafter\let\csname pp@page@#1\endcsname\next
- \edef\next{\noexpand
- \@newl@bel{pp@r@#1}{#2}{{\number\value{pp@a@#1}}{#3}%
- {#4}}}\next}}
+ \expandafter\pp@labeldef\expandafter
+ {\number\value{pp@a@#1}}{#1}{#2}{#3}{#4}}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@testdef}
+% \LaTeX's current (2007) definition of this macro causes save stack
+% overflow. We fix this by an additional grouping. Delay to the
+% beginning of document to keep Babel happy.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \begingroup
+ \@testdef{}{undefined}{}%
+ \expandafter
+ \endgroup
+ \ifx\@undefined\relax
+ \let\pp@@testdef\@testdef
+ \def\@testdef#1#2#3{{\pp@@testdef{#1}{#2}{#3}%
+ \if@tempswa\aftergroup\@tempswatrue\fi}}%
+ \fi}
+%</style>
% \end{macrocode}
% \end{macro}
%
-% \Finale{}
+% \Finale
% \endinput
% Local Variables:
% mode: doctex
% TeX-master: "perpage.drv"
% End:
-
diff --git a/Master/texmf-dist/source/latex/bigfoot/suffix.drv b/Master/texmf-dist/source/latex/bigfoot/suffix.drv
index b77eddc6d27..cdf92eb2af4 100644
--- a/Master/texmf-dist/source/latex/bigfoot/suffix.drv
+++ b/Master/texmf-dist/source/latex/bigfoot/suffix.drv
@@ -21,8 +21,11 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%%
-%% perpage is part of the bigfoot bundle for critical typesetting
-%% Copyright 2002, 03, 04, 05, 06 David Kastrup <dak@gnu.org>
+%% suffix is part of the bigfoot bundle for critical typesetting
+%% Copyright 2002--2006 David Kastrup <dak@gnu.org>
+%%
+%% The license notice and corresponding source code for this file are
+%% contained in suffix.dtx.
%%
\documentclass{ltxdoc}
\usepackage{hyperref}
diff --git a/Master/texmf-dist/source/latex/bigfoot/suffix.dtx b/Master/texmf-dist/source/latex/bigfoot/suffix.dtx
index 04f2e9a868a..9a6478e73a7 100644
--- a/Master/texmf-dist/source/latex/bigfoot/suffix.dtx
+++ b/Master/texmf-dist/source/latex/bigfoot/suffix.dtx
@@ -1,7 +1,10 @@
% \iffalse
%%
-%% perpage is part of the bigfoot bundle for critical typesetting
-%% Copyright 2002, 03, 04, 05, 06 David Kastrup <dak@gnu.org>
+%% suffix is part of the bigfoot bundle for critical typesetting
+%% Copyright 2002--2006 David Kastrup <dak@gnu.org>
+%%
+%% The license notice and corresponding source code for this file are
+%% contained in suffix.dtx.
%%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
@@ -17,7 +20,7 @@
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
% \fi
-% \CheckSum{206}
+% \CheckSum{198}
% \GetFileInfo{suffix.sty}
% \author{David Kastrup\thanks{\href{mailto:dak@gnu.org}
% {Email: \texttt{dak@gnu.org}}}}
@@ -96,11 +99,7 @@
% First we announce the package and check for e\TeX~2.
% \begin{macrocode}
%<*style>
-\def\next$#1: #2 #3${#2}
-\edef\next{\noexpand
- \ProvidesPackage{suffix}[\next$Date: 2006/07/15 21:24:56 $
- \next$Revision: 1.5 $ Variant command support]}
-\next
+\ProvidesPackage{suffix}[2006/07/15 1.5a Variant command support]
\ifcase\ifx\eTeXversion\@undefined \@ne\fi
\ifnum\eTeXversion<\tw@ \@ne\fi\z@
\else