diff options
author | Karl Berry <karl@freefriends.org> | 2022-02-11 21:53:45 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-02-11 21:53:45 +0000 |
commit | 6981d9f5465cd5432cfb27196814914d44fd0b56 (patch) | |
tree | cd34e77e73466ad1eb8bb1c15f286e897119b18d /Master/texmf-dist/source/latex/footmisc/footmisc.dtx | |
parent | a2b63cb66fbde22e2615466521546b8e9477a468 (diff) |
footmisc (11feb22)
git-svn-id: svn://tug.org/texlive/trunk@61979 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/footmisc/footmisc.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/footmisc/footmisc.dtx | 1599 |
1 files changed, 799 insertions, 800 deletions
diff --git a/Master/texmf-dist/source/latex/footmisc/footmisc.dtx b/Master/texmf-dist/source/latex/footmisc/footmisc.dtx index 0b9e77114f4..096889ce60b 100644 --- a/Master/texmf-dist/source/latex/footmisc/footmisc.dtx +++ b/Master/texmf-dist/source/latex/footmisc/footmisc.dtx @@ -1,5 +1,25 @@ -%\iffalse meta-comment, etc. -%% This is footmisc.dtx, and it's -*-LaTeX-*- text +% \iffalse meta-comment +% +%% File: footmisc.dtx (C) Copyright 1995-2011 Robin Fairbairns +%% (C) Copyright 2018-2022 Frank Mittelbach +% +% It may be distributed and/or modified under the conditions of the +% LaTeX Project Public License (LPPL), either version 1.3c of this +% license or (at your option) any later version. The latest version +% of this license is in the file +% +% https://www.latex-project.org/lppl.txt +% +% This bundle has the status "maintained" and the current maintainer +% is Frank Mittelbach. +% +% The development version of the bundle can be found at +% +% https://github.com/FrankMittelbach/fmitex-footmisc/ +% +% for those people who are interested or want to report an issue. +% +% % % We use the same body for the \cs{ProvidesFile} as for the % \cs{ProvidesPackage} command. @@ -11,16 +31,21 @@ %<*dtx> \ProvidesFile{footmisc.dtx}% %</dtx> +%<+package>\providecommand\DeclareRelease[3]{} +%<+package>\providecommand\DeclareCurrentRelease[2]{} +%<+package> +%<+package>\DeclareRelease{v5}{2011-06-06}{footmisc-2011-06-06.sty} +%<+package>\DeclareCurrentRelease{}{2022-02-10} %<package>\ProvidesPackage{footmisc}% %<*!debugins> - [2011/06/06 v5.5b + [2022/02/10 v6.0a %</!debugins> %<package> a miscellany of footnote facilities% %<*dtx> footmisc package source file% %</dtx> %<*!debugins> - ]% $Id: footmisc.dtx,v 4.25 2011/06/06 14:25:44 rf10 Exp rf10 $ + ] %</!debugins> % \end{macrocode} % @@ -30,9 +55,10 @@ %<*driver> \setcounter{errorcontextlines}{999} \documentclass{ltxdoc} +\usepackage{hyperref} % \end{macrocode} % -% we limit the things that we will index +% We limit the things that we will index % \begin{macrocode} \DoNotIndex{\#,\@MM,\@cclv,\@gobble,\@ifnextchar,\@ifundefined} \DoNotIndex{\|,\advance,\begingroup,\bgroup,\box,\csname} @@ -51,7 +77,7 @@ \DoNotIndex{\wd,\xdef,\@} \GetFileInfo{footmisc.dtx} \EnableCrossrefs -% to get documented source of the package, comment out the next line, +% To get documented source of the package, comment out the next line, % and uncomment the following one; otherwise, create yourself % (somewhere on your LaTeX input path) a file ltxdoc.cfg that contains % simply \AtBeginDocument{\AlsoImplementation} @@ -63,37 +89,48 @@ \end{document} %</driver> % \end{macrocode} +% % \fi % -% \CheckSum{1711} +% % % \title{\texttt{footmisc} ---\\ % a portmanteau package\\ -% for customising footnotes in \LaTeX\thanks{This file has +% for customizing footnotes in \LaTeX\thanks{This file has % version number \fileversion, last revised \filedate}} -% \author{Robin Fairbairns\thanks{University of Cambridge Computer -% Laboratory, William Gates Building, J.\,J. Thompson Avenue, -% Cambridge, CB2 0FD, UK -% (\texttt{rf10<snail-shape>cam.ac.uk})}} +% \author{Robin Fairbairns\thanks{Formerly: University of Cambridge Computer +% Laboratory, Cambridge, UK} \and +% Frank Mittelbach\thanks{Responsible maintainer since 2018}} % \maketitle % +% +% \newcommand\fmi[1]{\begin{quote} TODO: \itshape #1\end{quote}} +% \newcommand\NEW[1]{\marginpar{\mbox{}\hfill\fbox{New: #1}}} +% \providecommand\pkg[1]{\texttt{#1}} +% +% % \section*{Copyright statement} % % \noindent Program: \texttt{footmisc.dtx}\par -% \noindent Copyright 1995 1996 1998 1999 2001--2003 2008 2009 Robin Fairbairns +% \noindent Copyright 1995--2011 Robin Fairbairns\par +% \noindent Copyright 2018--2022 Robin Fairbairns, Frank Mittelbach % % This program is offered under the terms -% of the LaTeX Project Public License, version 1.3c of this license or +% of the \LaTeX{} Project Public License, version 1.3c of this license or % (at your option) any later version. The latest version of this -% license is in http://www.latex-project.org/lppl.txt, and version -% 1.3c or later is part of all distributions of LaTeX version -% 2005/12/01 or later. +% license is in \texttt{https://www.latex-project.org/lppl.txt}, and version +% 1.3c or later is part of all distributions of \LaTeX{} version +% 2008 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% +% \tableofcontents % -% This work has the LPPL maintenance status `author-maintained'. % % \section*{History} % -% This package originated as support of a personal project, which I +% This package originated as support of a personal project, which I (Robin) % was switching to \LaTeX{} 2e over the Christmas holiday period of % 1993, using the first \ensuremath{\beta} release. % @@ -102,10 +139,23 @@ % used by a package written by Mark Wooding. So the package is now % known (as you can see) as ``footmisc''. % +% Frank took over maintenance in 2018 but due to other commitments never +% got around finishing the changes he started to make in 2018. +% +% In 2022 a few new options (\texttt{abovefloats}, +% \texttt{belowfloats}, \texttt{bottomfloats}, and \texttt{bottomfootnotes}) +% got introduced and the package now works +% with \textsf{hyperref} regardless of loading order. There arem +% however, still a few restrictions when using both packages together, +% in particular the \texttt{multiple} option does not fully work. +% +% +% +% % \section{User interface~--- package options} % % The \textsf{footmisc} package provides several different -% customisations of the way foonotes are represented in \LaTeXe{} +% customizations of the way footnotes are represented in \LaTeXe{} % documents (the sources of the code in this package are various, but % all of it has been massaged by the author; where the code comes from % elsewhere, there are attributions given below, somewhere or other). @@ -130,7 +180,7 @@ % so an additional pass for this purpose shouldn't cause any % additional problem. The option includes code to report that % `\emph{Label(s) may have changed}', which will help the poor user to -% realise that (yet) another run is in order. +% realize that (yet) another run is in order. % % \subsection{Option \texttt{para}} % @@ -220,13 +270,16 @@ % confound automatic generation procedures. In the same situation, % the \texttt{symbol*} option produces information messages and a % warning message at end document, and the user may scan the log for -% those messages \emph{after} processing has stabilised. The option +% those messages \emph{after} processing has stabilized. The option % produces numbers (17 and higher, in the case of the default symbol % set) in place of symbols, when the footnote number is too large. % % \subsection{The \cs{setfnsymbol} and \cs{DefineFNsymbols} commands} % \label{footnote-symbols} % +% \fmi{At some point in the past this interface got extended, but the +% documentation lags behind so this needs updating.} +% % These commands permit the definition and use of alternative % (ordered) sets of symbols for numbering footnotes. \LaTeX{} of % course comes with such a set ready-defined, but the choice of @@ -266,17 +319,86 @@ % This last set, known as \texttt{lamport*} is selected as the default % symbol set by the package. % -% \subsection{Option \texttt{bottom}} % -% This option forces footnotes to the bottom of the page; this is only -% noticeably useful in case that \cs{raggedbottom} is in effect, when +% \subsection{Options altering the footnotes/floats relationship} +% +% In \LaTeX{} the default order on a page is ``page text'' followed by +% ``footnotes'' (if any) followed by ``bottom floats'' (if any). The +% spacing between the three components depends of whether pages are +% always stretched to the same height (\cs{flushbottom} as used by the +% book class) or if they +% can run short (\cs{raggedbottom} as used by the article or report +% class). +% If \cs{raggedbottom} is in force, then % \LaTeX{} would normally set the footnotes a mere -% \cs{skip}\cs{footins} distant from the bottom of the text. +% \cs{skip}\cs{footins} distant from the bottom of the text and bottom +% floats follow separated by \cs{textfloatsep}. Both spaces might get +% stretched if \cs{flushbottom} is in force. +% +% If\NEW{2022-02} +% you want to diverge from this default placement, then there are +% a number of alterations that can be made: +% \begin{itemize} +% \item the order of footnotes and floats can be swapped; and +% \item both footnotes and floats can be forced to the bottom (i.e., +% \cs{raggedbottom} then only applies to pages with neither), or +% \item only one of them is forced to the bottom, the other stays +% close to the text. +% \end{itemize} +% These can be achieved by applying one or more of the options +% discussed below. +%^^A \texttt{abovefloats}, \texttt{belowfloats}, \texttt{bottom}, +%^^A \texttt{bottomfloats}, or \texttt{bottomfootnotes}. +% +% +% +% \subsubsection{Options \texttt{abovefloats} and \texttt{belowfloats}} +% +% These\NEW{2022-02} +% two options describe the footnote placement with respect to +% floats on the page. \LaTeX's default is \texttt{abovefloats}, but it +% can still be useful to specify it because it fixes the bug discussed +% in section~\ref{sec:spacebug}. +% +% +% \subsubsection{Option \texttt{bottom}} +% +% This option forces footnotes \emph{and} floats to the bottom and +% also implies \texttt{belowfloats}. If you want both at the bottom +% but footnotes first, then add \texttt{abovefloats} in addition. +% +% \subsubsection{Options \texttt{bottomfloats} and +% \texttt{bottomfootnotes}} +% +% If\NEW{2022-02} +% you want force only floats or only footnotes to the bottom then +% use one of these options. As they naturally define the order, i.e., +% in case of \texttt{bottomfloats} footnotes are obviously earlier, the +% options \texttt{abovefloats} and \texttt{belowfloats} are +% meaningless and are ignored if given. +% +% +% \subsubsection{Fixing a strange behavior of \LaTeX} +% \label{sec:spacebug} +% +% In\NEW{2022-02} +% the default case (if \pkg{footmisc} is not loaded) \LaTeX{} shows +% a somewhat strange discrepancy: on most pages the +% footnotes are attached a distance of \cs{skip}\cs{footins} from the +% main text, even if that page is run short (i.e., with +% \cs{raggedbottom} in force). However, whenever the is some +% infinite stretch at the end of the page, e.g., from using \cs{newpage} or +% \cs{clearpage} the footnotes are pushed to the bottom (in particular +% on the last page of a document or chapter). +% +% This is automatically corrected if \pkg{footmisc} is loaded with any +% of the options that deal with footnote placement, i.e., +% \texttt{abovefloats}, \texttt{belowfloats}, \texttt{bottom}, +% \texttt{bottomfloats}, or \texttt{bottomfootnotes}. In particular, +% if you want to have the standard \LaTeX{} placement (but with this +% strange behavior fixed, apply \texttt{abovefloats} (which is the +% normal order but with the bug fixed). % -% There's a further infelicity in \LaTeX{}'s placing of footnotes of -% the bottom of pages: if a bottom float appears on a page, \LaTeX{} -% places the footnote \emph{above} it. The \texttt{bottom} option -% places the footnote at the foot of the page. % % \subsection{Option \texttt{marginal}} % @@ -405,7 +527,7 @@ % letters. However, the numbers used by \cs{footnotemark} make % reference to the `main' % footnote counter, and are set in whatever is the current style for -% that: this behaviour often surprises, and there's no obvious way in +% that: this behavior often surprises, and there's no obvious way in % standard \LaTeX{} to ``get around'' it. The command % \cs{mpfootnotemark} gets around this problem in a minipage, by % generating footnote marks in the same way as those used by @@ -418,7 +540,8 @@ % subsequent \cs{footnotemark} or \cs{mpfootnotemark}. This is a % tedious way of going about things, and doesn't allow representation % of all possible forms of footnote mark; \cs{footref} is a form of -% reference command that sets the reference as if it were a footnote. +% reference command that sets the reference as if it were +% a footnote.\footnote{This command is already provided by the \LaTeX{} format.} % The label should be set \emph{within} the argument of the footnote % command that is being labelled: % \begin{verbatim} @@ -431,7 +554,7 @@ % % The \textsf{footmisc} package modifies several parts of the \LaTeX{} % kernel; what gets modified depends on the options you select. This -% behaviour can cause problems with other packages, particularly those +% behavior can cause problems with other packages, particularly those % that also modify the kernel. % % Known interactions are: @@ -444,6 +567,8 @@ % \item[\normalfont\textsf{memoir} class] The class emulates % \textsf{setspace}, and we detect that emulation and deal with it % in the same way as \textsf{setspace}. +% +% \iffalse FMi: this should now work! % \item[\normalfont\textsf{hyperref}] The \textsf{hyperref} package % has ambitions to make hyperlinks from footnote marks to the % corresponding footnote body; naturally this causes grief to @@ -453,6 +578,8 @@ % \quad\verb|\usepackage[hyperfootnotes=false,...]{hyperref}|\\ % Further work on the interaction between the two packages is % proposed, but not yet scheduled. +% \fi +% % \item[\normalfont\textsf{manyfoot}] The \textsf{manyfoot} package % permits several independent sequences of footnotes. Some % preliminary work towards interworking with \textsf{footmisc} has @@ -470,9 +597,9 @@ %<*package> % \end{macrocode} % -% Now declare what environment we need: +% Now declare what environment we need: version 6 needs a fairly recent \LaTeX. % \begin{macrocode} -\NeedsTeXFormat{LaTeX2e}[1994/12/01] +\NeedsTeXFormat{LaTeX2e}[2020/10/01] % \end{macrocode} % % We need a token register in case we have to patch \cs{@makecol}: @@ -487,13 +614,14 @@ % \begin{macrocode} \providecommand\protected@writeaux{% \protected@write\@auxout -}% \end{macrocode} +} +% \end{macrocode} % \end{macro} % % \begin{macro}{\l@advance@macro} -% \begin{macro}{@@dvance@macro} +% \begin{macro}{\@@dvance@macro} % \begin{macro}{\@advance@macro} -% We make the following (\cs{@@dvance@macro}) generalisable as follows +% We make the following (\cs{@@dvance@macro}) generalizable as follows % (the global form isn't used in this package \dots\ yet): % % \begin{macrocode} @@ -513,20 +641,9 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\ifFN@etex} -% Check whether we're using etex -% \begin{macrocode} -\newif\ifFN@etex -\ifx\dimexpr\undefined - \FN@etexfalse -\else - \FN@etextrue -\fi -% \end{macrocode} -% \end{macro} % \begin{macro}{\footnotemargin} % Finally, we define the length used by the \texttt{marginal} option, -% and initialise it as if we've not had the option. +% and initialize it as if we've not had the option. % \begin{macrocode} \newdimen\footnotemargin \footnotemargin1.8em\relax @@ -545,7 +662,7 @@ % This is a declaration that appears in the original \LaTeX{} book. % Since it appeared in the old |pagefoots.sty| (presumably since it % goes so naturally with the |perpage| option), I've added this -% trivial piece of customisation to the package. +% trivial piece of customization to the package. % % \begin{macrocode} \DeclareOption{symbol}{\renewcommand\thefootnote{\fnsymbol{footnote}}} @@ -558,8 +675,10 @@ % number. We use a robust version of the ``extended ordinary'' symbol set, % described later (in section~\ref{footnote-symbols}). % \begin{macrocode} +\newif\ifFN@robust \FN@robustfalse \DeclareOption{symbol*}{% \renewcommand\thefootnote{\@fnsymbol\c@footnote}% + \FN@robusttrue \AtEndOfPackage{\setfnsymbol{lamport*-robust}}% } % \end{macrocode} @@ -600,7 +719,7 @@ % \subsection{The \texttt{side} option} % % \begin{macro}{\ifFN@sidefn} -% Simply changes the behaviour of \cs{@footnotetext}; incompatible +% Simply changes the behavior of \cs{@footnotetext}; incompatible % with paragraph footnotes. % \begin{macrocode} \newif\ifFN@sidefn \FN@sidefnfalse @@ -662,18 +781,99 @@ % \end{macrocode} % \end{macro} % -% \subsection{The \texttt{bottom} option} % -% \begin{macro}{\ifFN@bottom} -% All this needs to do is to set a flag to say that it should happen +% \subsection{Fixing the \LaTeX{} misbehavior with respect to spacing} +% +% +% \begin{macro}{\ifFN@fixskip} +% We maintain a boolean to decide if we want to fix that, by +% default we don't but if any placement option is given we apply the fix. +% \begin{macrocode} +\newif\ifFN@fixskip \FN@fixskipfalse +% \end{macrocode} +% \end{macro} +% +% \subsection{The footnote/float placement options} +% +% We have up to three blocks on a page (four if you count +% top-floats). If there is any excess space that needs to be added the +% question is where that goes: +% \begin{enumerate} +% \item above footnotes and floats; +% \item between footnotes and floats; +% \item after footnotes and floats; +% \item nowhere in particular (everything is equally spaced out). +% \end{enumerate} +% Technically, the last two cases can be combined in one: +% \cs{raggedbottom} adds some ``fill'' space at the very bottom (which +% covers case 3) and \cs{flushbottom} puts nothing in this place, so +% covers case 4 if we do not add any \cs{vfill} elsewhere. +% +% +% \begin{macro}{\FN@ORspacehandling} +% We record in which case we want to be in +% \cs{FN@ORspacehandling}. The default is case 3. +% \begin{macrocode} +\let\FN@ORspacehandling\thr@@ +% \end{macrocode} +% \end{macro} +% +% +% +% \subsubsection{The \texttt{bottom} option} +% +% \begin{macro}{\ds@bottom} +% The \texttt{bottom} option implements case 1 and puts the footnotes +% by default below the floats. % \begin{macrocode} -\newif\ifFN@bottom \FN@bottomfalse \DeclareOption{bottom}{% - \FN@bottomtrue + \let\FN@ORspacehandling\@ne + \FN@abovefloatsfalse +% \end{macrocode} +% We also state that we want to fix \LaTeX{} space issue (as we do +% in all other options. +% \begin{macrocode} + \FN@fixskiptrue +} +% \end{macrocode} +% \end{macro} +% +% \subsection{The \texttt{abovefloats}, \texttt{belowfloats} options} +% +% \begin{macro}{\ifFN@abovefloats} +% All this needs to do is to set a flag to say that it should happen. +% \begin{macrocode} +\newif\ifFN@abovefloats \FN@abovefloatstrue +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{ds@abovefloats,ds@belowfloats} +% These options change the order and that's it. +% \begin{macrocode} +\DeclareOption{abovefloats}{\FN@abovefloatstrue \FN@fixskiptrue} +\DeclareOption{belowfloats}{\FN@abovefloatsfalse \FN@fixskiptrue} +% \end{macrocode} +% \end{macro} +% +% \subsection{The \texttt{bottomfloats}, \texttt{bottomfootnotes} options} +% +% \begin{macro}{ds@bottomfloats,ds@bottomfootnotes} +% These options are for case 2. In addition they have to say what +% comes first. +% \begin{macrocode} +\DeclareOption{bottomfloats}{% + \let\FN@ORspacehandling\tw@ + \FN@abovefloatstrue \FN@fixskiptrue +} +\DeclareOption{bottomfootnotes}{% + \let\FN@ORspacehandling\tw@ + \FN@abovefloatsfalse \FN@fixskiptrue } % \end{macrocode} % \end{macro} % +% % \subsection{The \texttt{marginal} option} % % Again, the processing of the option is pretty trivial: @@ -824,268 +1024,469 @@ % hacked to achieve our effects, and we do all of this now, according % to flags set in option processing. % -% \subsection{The output routine} +% \subsection{The output routine part} +% +% We interface with \cs{@makecol} from the kernel. Eventually this +% should move directly into the kernel. % -% Now; do we need to mess about with the output routine? If either -% |para| or |bottom| has been invoked, we do. +% In order for other packages to prepend or append code to +% \cs{@makecol}, they can use the generic command hooks +% \texttt{cmd/@makecol/before} and \texttt{cmd/@makecol/after}, so +% there is nothing we need to do here. +% +% +% +% \begin{macro}{\@makecol} +% \cs{@makecol} is shortened a lot, basically all the hardwired +% code in the middle has moved into a configuration point. +% \begin{macrocode} +\def \@makecol {% + \@kernel@before@cclv + \setbox\@outputbox \box\@cclv +% \end{macrocode} +% The only real addition is the next command which either does +% nothing or removes an infinite glue from the bottom of the +% \cs{@outputbox}. +% \begin{macrocode} + \@outputbox@removebskip +% \end{macrocode} +% Any ``here'' floats in the \cs{@outputbox} are now handled so we +% recycle their registers and put them back to the \cs{@freelist}. % \begin{macrocode} -\let \if@tempswa \ifFN@bottom -\ifFN@para \@tempswatrue \fi -\if@tempswa + \let\@elt\relax + \xdef\@freelist{\@freelist\@midlist}% + \global \let \@midlist \@empty +% \end{macrocode} +% Here we have the configurable part. +% \fmi{Interface to configuration points will change in the future} +% \begin{macrocode} + \@makecol@appendblocks +% \end{macrocode} +% The we deal with any \cs{enlargethispage} or run the normal code +% to build a column. +% \begin{macrocode} + \ifvbox\@kludgeins + \@makespecialcolbox + \else + \@makenormalcolbox + \fi + \global \maxdepth \@maxdepth +} % \end{macrocode} -% \dots{} so we've patching to do. +% \end{macro} % -% First, we ensure that \cs{@makecol} is as expected from the time at -% which these macros were written: since we're going to patch it, we -% had better be sure that we're patching the right thing. (There was -% a minuscule change to the definition 1999, but this doesn't as far -% as I can tell make any difference to the semantics of the definition -% we base our patch on.) +% +% \begin{macro}{\@outputbox@depth} +% We need to know the depth of \cs{@outputbox} once in a +% while. Rather than using a temp dimen (as it was done in the +% past), we give it a proper register. % \begin{macrocode} - \@ifl@t@r\fmtversion{2005/12/01}{% - \CheckCommand*\@makecol{\ifvoid \footins - \setbox\@outputbox \box\@cclv - \else - \setbox\@outputbox \vbox{% - \boxmaxdepth \@maxdepth - \unvbox\@cclv - \vskip \skip\footins - \color@begingroup - \normalcolor\footnoterule - \unvbox\footins - \color@endgroup - }% - \fi - \let \@elt \relax - \xdef\@freelist{\@freelist\@midlist}% - \global\let\@midlist\@empty - \@combinefloats - \ifvbox\@kludgeins - \@makespecialcolbox - \else - \setbox\@outputbox \vbox to\@colht{% - \@texttop \dimen@\dp\@outputbox - \unvbox\@outputbox - \vskip -\dimen@\@textbottom - }% - \fi - \global\maxdepth\@maxdepth - } - }{% - \@ifl@t@r\fmtversion{2003/12/01}{% - \CheckCommand*\@makecol{\ifvoid \footins - \setbox\@outputbox \box\@cclv - \else - \setbox\@outputbox \vbox{% - \boxmaxdepth\@maxdepth - \@tempdima\dp\@cclv - \unvbox\@cclv - \vskip \skip\footins - \color@begingroup - \normalcolor - \footnoterule - \unvbox\footins - \color@endgroup - }% - \fi - \let \@elt \relax - \xdef\@freelist{\@freelist\@midlist}% - \global\let\@midlist\@empty - \@combinefloats - \ifvbox\@kludgeins - \@makespecialcolbox - \else - \setbox\@outputbox \vbox to\@colht{% - \@texttop - \dimen@\dp\@outputbox - \unvbox\@outputbox - \vskip -\dimen@ - \@textbottom - }% - \fi - \global\maxdepth\@maxdepth - }% - }{% - \@ifl@t@r\fmtversion{1999/12/01}{% - \CheckCommand*\@makecol{\ifvoid \footins - \setbox\@outputbox \box\@cclv - \else - \setbox\@outputbox \vbox{% - \boxmaxdepth\@maxdepth - \@tempdima\dp\@cclv - \unvbox\@cclv - \vskip \skip\footins - \color@begingroup - \normalcolor\footnoterule - \unvbox\footins - \color@endgroup - }% - \fi - \xdef\@freelist{\@freelist\@midlist}% - \global\let\@midlist\@empty - \@combinefloats - \ifvbox\@kludgeins - \@makespecialcolbox +\newdimen\@outputbox@depth +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@makenormalcolbox} +% Taken out of \cs{@makecol} for readability. +% \begin{macrocode} +\def \@makenormalcolbox {% + \setbox\@outputbox \vbox to\@colht {% + \@texttop + \@outputbox@depth \dp\@outputbox + \unvbox \@outputbox + \vskip -\@outputbox@depth + \@textbottom + }% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@makespecialcolbox} +% Make the colbox when \cs{enlargethispage} was used. +% \begin{macrocode} +\def \@makespecialcolbox {% + \@outputbox@append {\vskip-\@outputbox@depth}% + \@tempdima \@colht + \ifdim \wd\@kludgeins>\z@ + \advance \@tempdima -\ht\@outputbox + \advance \@tempdima \pageshrink + \setbox\@outputbox \vbox to \@colht {% + \unvbox\@outputbox + \vskip \@tempdima + \@textbottom + }% + \else + \advance \@tempdima -\ht\@kludgeins + \setbox \@outputbox \vbox to \@colht {% + \vbox to \@tempdima {% + \unvbox\@outputbox + \@textbottom}% + \vss}% + \fi + {\setbox \@tempboxa \box \@kludgeins}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@outputbox@removebskip} +% +% This is really a bug fix for the kernel, but perhaps one has to +% make it optional because it is in there since day one). If +% \cs{raggedbottom} is in force, footnotes get attached to the main +% galley at a distance of \cs{footskip} on all pages except on +% those that are ended by \cs{newpage} or \cs{clearpage} where the +% \cs{vfil} from \cs{newpage} pushes the footnotes to the very bottom. +% +% This is kind of a weird difference to a page ending with +% \cs{pagebreak}---in that case the page is also run +% short, but the footnotes are not pushed to the bottom. +% +% This is fixed by \cs{@outputbox@removebskip} but only if the +% switch \texttt{FN@fixskip} is set to true (which is done whenever +% \pkg{footmisc} is called with with an option specifying the +% footnote placement, i.e., not in the default case). +% \begin{macrocode} +\ifFN@fixskip + \def\@outputbox@removebskip{% +% \end{macrocode} +% We first test if we are in a \cs{raggedbottom} layout. If not we +% do nothing, but we don't disable the code because +% \cs{raggedbottom} may get used only for some parts of the +% document. +% \begin{macrocode} + \ifx\@textbottom\relax \else +% \end{macrocode} +% We then append some negative glue at the end of \cs{@outputbox} +% provided it has a glue stretch order of 1 or more (i.e., contains +% a \texttt{fil} or \texttt{fill} part). +% \begin{macrocode} + \@outputbox@append{% + \@tempskipa\lastskip + \ifnum \gluestretchorder\@tempskipa>\z@ + \vskip-\@tempskipa +% \end{macrocode} +% \begin{macro}{\@outputbox@reinsertbskip} +% We also record the value so that it can be reinserted +% elsewhere. As we have to do this globally, we also need to +% explicitly reset it if we don't find any such glue. +% \begin{macrocode} + \xdef\@outputbox@reinsertbskip + {\noexpand\@outputbox@append{\vskip\the\@tempskipa}}% \else - \setbox\@outputbox \vbox to\@colht{% - \@texttop \dimen@\dp\@outputbox - \unvbox\@outputbox - \vskip -\dimen@\@textbottom - }% + \global\let\@outputbox@reinsertbskip\relax \fi - \global\maxdepth\@maxdepth }% - }% - }{% - \CheckCommand*\@makecol{\ifvoid \footins - \setbox\@outputbox \box\@cclv - \else - \setbox\@outputbox \vbox{% - \boxmaxdepth\@maxdepth - \unvbox\@cclv - \vskip \skip\footins - \color@begingroup - \normalcolor\footnoterule - \unvbox\footins - \color@endgroup - }% - \fi - \xdef\@freelist{\@freelist\@midlist}% - \global\let\@midlist\@empty - \@combinefloats - \ifvbox\@kludgeins - \@makespecialcolbox - \else - \setbox\@outputbox \vbox to\@colht{% - \@texttop \dimen@\dp\@outputbox - \unvbox\@outputbox - \vskip -\dimen@\@textbottom - }% - \fi - \global\maxdepth\@maxdepth - }% - }% -} + \fi + } % \end{macrocode} +% We need a trivial top-level definition for +% \cs{@outputbox@reinsertbskip} in case the first page has no +% bottom glue and the command gets called. +% \begin{macrocode} +\let\@outputbox@reinsertbskip\relax +% \end{macrocode} +% If nothing should get fixed we set both commands to \cs{relax}. +% \begin{macrocode} +\else + \let\@outputbox@removebskip \relax + \let\@outputbox@reinsertbskip\relax +\fi +% \end{macrocode} +% \end{macro} +% \end{macro} % -% If we're doing paragraph footnotes, the output routine needs -% different code to place the actual text. We prepare this code here, -% since it's potentially used in two different places. % -% We prepare the code in a token register to be used at the -% appropriate place in the patching of \cs{@makecol}; thus it becomes -% a token register containing code to place stuff in a token register +% \begin{macro}{\@kernel@before@cclv} +% \begin{macro}{\@kernel@before@footins} +% These two commands are internal kernel hooks intended for tagging +% support in case that is active. By default they do nothing (and +% may have been defined already by \cs{DocumentMetadata}). % \begin{macrocode} - \ifFN@para +\providecommand\@kernel@before@cclv{} +\providecommand\@kernel@before@footins{} % \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% +% \subsection{The output routine configuration components} +% +% Here we provide the components that are used to define +% \cs{@makecol@appendblocks}. % -% We make a box out of the paragraph of footnotes, and then stuff the -% contents of the box into that which is going to be \cs{ship}ped -% |out|. +% +% \begin{macro}{@outputbox@append} +% +% This general purpose command alters the \cs{@outputbox} box by +% appending material to it. As this is a box typesetting operation +% we make sure that the last line of the box reflects the true +% depth of the last line (in case that is needed later). We also +% expose the current depth of \cs{@outputbox} as +% \cs{@outputbox@depth} before unboxing so that its value can be +% used by \verb=#1= if wanted. % \begin{macrocode} - \FN@temptoken{% - \toks@\expandafter{\the\toks@ - \vskip\skip\footins - \color@begingroup - \normalcolor\footnoterule - \global\setbox\FN@tempboxc\vbox{\makefootnoteparagraph}% - \unvbox\FN@tempboxc - \color@endgroup - }% - }% +\def\@outputbox@append #1{% +% \if!\detokenize{#1}!\else + \setbox\@outputbox \vbox {% + \boxmaxdepth \@maxdepth + \@outputbox@depth\dp\@outputbox % if needed in #1 + \unvbox \@outputbox + #1% + }% +% \fi +} % \end{macrocode} +% \end{macro} % -% If we're not doing paragraph footnotes, we insert the little bit of -% code that would have been replaced by the stuff above: +% +% +% +% \begin{macro}{\@outputbox@appendfootnotes} +% +% This command appends the footnotes to the \cs{@outputbox} (if +% there are any). If not then it does nothing. % \begin{macrocode} - \else - \FN@temptoken{% - \toks@\expandafter{\the\toks@ - \vskip\skip\footins - \color@begingroup - \normalcolor\footnoterule - \unvbox\footins - \color@endgroup +\def\@outputbox@appendfootnotes {% + \ifvoid\footins \else +% \end{macrocode} +% First come two configuration points: what to do if we are in a split +% footnote situation and a second one that does some manipulation +% of the \cs{footins} box before it gets appended. +% \fmi{this code will get revised as part of CP handling in the future} +% \begin{macrocode} + \@makecol@handlesplitfootnotes + \@makecol@preparefootinshook +% \end{macrocode} +% Then the footnotes are appended: +% \begin{macrocode} + \@outputbox@append{% + \vskip \skip\footins + \@kernel@before@footins + \color@begingroup + \normalcolor + \footnoterule +% \end{macrocode} +% Support for \pkg{pdfcolfoot}, eventually this can go once color +% is properly supported. +% \begin{macrocode} + \csname pdfcolfoot@current\endcsname + \unvbox \footins + \color@endgroup }% - }% \fi +} % \end{macrocode} +% \end{macro} +% +% % -% Now we start building up the revised version of \cs{@makecol}. The -% definition starts out in \cs{toks@}; first the \textsf{bottom} version: +% \begin{macro}{\@outputbox@attachfloats} +% \begin{macro}{\@outputbox@attachtopfloats} +% \begin{macro}{\@outputbox@attachbottomfloats} +% Attaching top and bottom floats can usually be done in one go, +% but for special layouts we might want more control so we provide +% also separate commands. % \begin{macrocode} - \ifFN@bottom - \toks@{\setbox\@outputbox \box\@cclv - \xdef\@freelist{\@freelist\@midlist}% - \global\let\@midlist\@empty - \@combinefloats - \ifvoid\footins - \else - \setbox\@outputbox \vbox\bgroup - \boxmaxdepth\@maxdepth - \unvbox\@outputbox - \vfill\relax +\let \@outputbox@attachfloats \@combinefloats +% \end{macrocode} +% +% \begin{macrocode} +\def \@outputbox@attachtopfloats {% + \ifx \@toplist\@empty \else \@cflt \fi +} +\def \@outputbox@attachbottomfloats {% + \ifx \@botlist\@empty \else \@cflb \fi +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% +% +% \begin{macro}{\@makecol@handlesplitfootnotes} +% \begin{macro}{\@makecol@splitfootnotemessagehook} +% This is only an early draft and doesn't do much. +% Contains incomplete preparation for tagging commented out. +% \fmi{Interfaces and code will change in the future} +% \begin{macrocode} +\def\@makecol@handlesplitfootnotes {% +% \ifx\splitfootnote@continuation\@empty \else +% \setbox\footins\vbox{\splitfootnote@continuation\unvbox\footins}% +% \global\let\splitfootnote@continuation\@empty +% \fi + \ifnum\insertpenalties>\z@ + \@makecol@splitfootnotemessagehook +% \setbox\footins\vbox{\unvbox\footins --- END at split}% +% \gdef\splitfootnote@continuation {--- START after split}% + \fi +} +%\def\splitfootnote@continuation{} +% \end{macrocode} +% This could issue warning if split footnotes are encountered. +% \begin{macrocode} +\let \@makecol@splitfootnotemessagehook \@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% \begin{macro}{\@makecol@preparefootinshook} +% +% Configuration point to support manipulation of footins box +% (result needs to be moved back in there). Used by the +% \texttt{para} option. +% \fmi{Interface will change in the future} +% \begin{macrocode} +\let \@makecol@preparefootinshook \@empty +% \end{macrocode} +% +% Footnote box layout for para footnotes; +% this would also be the hook to support dblfootnotes (from the +% \texttt{dblfnote} package if we integrate that). +% \begin{macrocode} +\ifFN@para + \def\@makecol@preparefootinshook {% + \global\setbox\footins\vbox{\FN@makefootnoteparagraph}% } - \the\FN@temptoken - \toks@\expandafter{\the\toks@\egroup\fi} +\fi % \end{macrocode} +% \end{macro} % -% Not putting stuff at the bottom: footnotes are placed using the -% kernel's algorithm. +% +% +% \subsection{The \cs{@makecol} configuration based on options} +% +% +% Placement of footnotes in relation to main galley and floats is +% covered by the value of \cs{FN@ORspacehandling} (distribution of +% space) and the status of the switch \texttt{@abovefloats}. +% +% \begin{macrocode} +\ifcase \FN@ORspacehandling\relax +%--------------------------------------------------------- +% 0 = undefined +%--------------------------------------------------------- +\ERROR +\or +%--------------------------------------------------------- +% 1 = space above footnotes and floats +%--------------------------------------------------------- +% \end{macrocode} +% All excess space are above the footnote and bottom float +% blocks. The order of the blocks depend on \texttt{@abovefloats}: % \begin{macrocode} + \ifFN@abovefloats +%--------------------------------------------------------- +% \end{macrocode} +% Footnotes above floats both at bottom: +% \begin{macrocode} + \def\@makecol@appendblocks {% + \@outputbox@append{\vfill}% + \@outputbox@appendfootnotes + \@outputbox@attachfloats + } +%--------------------------------------------------------- \else - \toks@{\ifvoid\footins - \setbox\@outputbox\box\@cclv - \else - \setbox\@outputbox \vbox\bgroup - \boxmaxdepth\@maxdepth - \unvbox\@cclv +% \end{macrocode} +% Footnotes below floats: +% \begin{macrocode} + \def\@makecol@appendblocks {% + \@outputbox@append{\vfill}% + \@outputbox@attachfloats + \@outputbox@appendfootnotes } - \the\FN@temptoken + \fi +\or +%--------------------------------------------------------- +% 2 = space between footnotes and floats (or floats and footnotes) +%--------------------------------------------------------- + \ifFN@abovefloats +%--------------------------------------------------------- +% \end{macrocode} +% Footnotes first then space then floats at bottom: +% \begin{macrocode} + \def\@makecol@appendblocks {% + \@outputbox@appendfootnotes + \@outputbox@append{\vfill}% + \@outputbox@attachfloats + } +%--------------------------------------------------------- + \else % \end{macrocode} -% -% Finally, close the \cs{setbox} and the \cs{ifvoid} and tag the parts -% of the definition of \cs{@makecol} up to the end of the definition -% of the \textsf{bottom} version on to \cs{toks@}. +% Then the other way around: % \begin{macrocode} - \toks@\expandafter{\the\toks@ - \egroup - \fi - \xdef\@freelist{\@freelist\@midlist}% - \global\let\@midlist\@empty - \@combinefloats - }% + \def\@makecol@appendblocks {% + \@outputbox@attachfloats + \@outputbox@append{\vfill}% + \@outputbox@appendfootnotes + } +%--------------------------------------------------------- \fi +\or +%--------------------------------------------------------- +% 3 = space below footnotes and floats +%--------------------------------------------------------- +% \end{macrocode} +% If the excess spaces goes on the bottom we don't append +% \cs{vfill} there. Instead we make use of the fact that +% \cs{raggedbottom} already puts a stretchable space there, and if +% we are in a \cs{flushbottom} scenario then any excess space is +% supposed to be distributed across the whole page. +% \begin{macrocode} + \ifFN@abovefloats +%--------------------------------------------------------- + \def\@makecol@appendblocks {% + \@outputbox@appendfootnotes + \@outputbox@attachfloats +% \end{macrocode} +% We do, however, reinsert the bottom skip from \cs{newpage} if it +% was taken out earlier. This is, strictly speaking, not necessary +% in most cases, but it is a \cs{vfil} while \cs{raggedbottom} is +% only generating \verb=\vspace{0pt plus .0001fil}=, so if you have +% several \cs{vfil} on the page before the \cs{newpage} you would +% alter the space distribution if one is taken out. +% \begin{macrocode} + \@outputbox@reinsertbskip + } + \else +%--------------------------------------------------------- % \end{macrocode} -% -% Finally, create the new definition from the resulting object with -% the remainder of the original \cs{@makecol} tagged on at the end. +% Same thing but with blocks swapped. % \begin{macrocode} - \toks@\expandafter{\the\toks@ - \ifvbox\@kludgeins - \@makespecialcolbox - \else - \setbox\@outputbox \vbox to\@colht{% - \@texttop \dimen@\dp\@outputbox - \unvbox\@outputbox - \vskip -\dimen@\@textbottom - }% - \fi - \global\maxdepth\@maxdepth - } - \edef\@makecol{\the\toks@} + \def\@makecol@appendblocks {% + \@outputbox@attachfloats + \@outputbox@appendfootnotes + \@outputbox@reinsertbskip +} +%--------------------------------------------------------- + \fi +\else +%--------------------------------------------------------- +% 3 > undefined +%--------------------------------------------------------- % \end{macrocode} -% -% All of the above occurred conditionally on the `or' of -% \cs{ifFN@para} and \cs{ifFN@bottom}, so we now close the -% conditional. +% The \cs{ERROR} here and above should never execute, like ``This +% can't happen'' in the \TeX{} program code. If they execute then code +% is badly broken. % \begin{macrocode} +\ERROR \fi + % \end{macrocode} % % % \subsection{The requirements of \cs{@footnotetext}} % +% Instead of (re)defining \cs{@footnotetext} we define +% \cs{FN@footnotetext} and at the end we check what we do with it, +% depending on whether or not \texttt{hyperref} was loaded. +% % \begin{macro}{\ifFN@baselinestretch} % \begin{macro}{\FN@singlespace} % Whatever we do, we are going to patch \cs{@footnotetext}; so first @@ -1119,7 +1520,7 @@ % footnotes: % \begin{macrocode} \ifFN@para - \renewcommand\@footnotetext[1]{% + \long\def\FN@footnotetext#1{% \insert\footins{% % \end{macrocode} % insert compatibility code with |setspace.sty| if necessary @@ -1139,10 +1540,10 @@ % \end{macrocode} % % We set the paragraph in an \cs{hbox} and apply the fudge factor -% here: +% here (these days done with e\TeX{} methods): % % \begin{macrocode} - \setbox\FN@tempboxa=\hbox{% + \setbox\FN@tempboxa\hbox{% % \end{macrocode} % % This needs a parameter; the rule should be moved to the beginning of @@ -1161,13 +1562,9 @@ \hskip\footglue }% end of \@makefntext parameter }% end of \hbox - \dp\FN@tempboxa=0pt - \ifFN@etex - \ht\FN@tempboxa=\dimexpr\wd\FN@tempboxa * - \footnotebaselineskip / \columnwidth\relax - \else - \ht\FN@tempboxa=\fudgefactor\wd\FN@tempboxa - \fi + \dp\FN@tempboxa\z@ + \ht\FN@tempboxa\dimexpr\wd\FN@tempboxa *% + \footnotebaselineskip / \columnwidth\relax \box\FN@tempboxa \color@endgroup }% @@ -1182,7 +1579,7 @@ % \begin{macrocode} \else \ifFN@sidefn - \renewcommand\@footnotetext[1]{% + \long\def\FN@footnotetext#1{% \marginpar{% % \end{macrocode} % insert compatibility code with |setspace.sty| if necessary @@ -1203,7 +1600,7 @@ \FN@mf@prepare }% \else - \renewcommand\@footnotetext[1]{% + \long\def\FN@footnotetext#1{% \insert\footins{% % \end{macrocode} % insert compatibility code with \textsf{setspace} if necessary @@ -1235,6 +1632,9 @@ % \end{macrocode} % % +% +% +% % \subsection{Support code for paragraph footnotes} % % This code used (most inefficiently) to be in the argument of the @@ -1302,29 +1702,17 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\fudgefactor} -% Now we derive a fudge factor from the baselineskip we've just -% established (we use \cs{dimexpr} if we're in etex, so there's no need -% for the fudge factor in that case). -% \begin{macrocode} - \ifFN@etex - \else - \@tempdima=\footnotebaselineskip \multiply\@tempdima by 1024 - \divide \@tempdima by \columnwidth \multiply\@tempdima by 64 - \xdef\fudgefactor{\strip@pt\@tempdima }% - \fi -% \end{macrocode} -% \end{macro} % -% \begin{macro}{\makefootnoteparagraph} + +% \begin{macro}{\FN@makefootnoteparagraph} % For use in the output routine % \begin{macrocode} - \long\def\makefootnoteparagraph{\unvbox\footins \makehboxofhboxes - \setbox\FN@tempboxa=\hbox{\unhbox\FN@tempboxa \removehboxes} + \long\def\FN@makefootnoteparagraph{\unvbox\footins \FN@makehboxofhboxes + \setbox\FN@tempboxa=\hbox{\unhbox\FN@tempboxa \FN@removehboxes}% % \end{macrocode} % Now we are ready to set the paragraph: % \begin{macrocode} - \hsize\columnwidth + \FN@setfootnoteparawidth \@parboxrestore \baselineskip=\footnotebaselineskip \noindent @@ -1334,20 +1722,20 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\makehboxofhboxes} -% \begin{macro}{\removehboxes} -% Support code for \cs{makefootnoteparagraph} +% \begin{macro}{\FN@makehboxofhboxes} +% \begin{macro}{\FN@removehboxes} +% Support code for \cs{FN@makefootnoteparagraph} % \begin{macrocode} - \def\makehboxofhboxes{\setbox\FN@tempboxa=\hbox{}% + \def\FN@makehboxofhboxes{\setbox\FN@tempboxa=\hbox{}% \loop \setbox\FN@tempboxb=\lastbox \ifhbox\FN@tempboxb \setbox\FN@tempboxa=\hbox{\box\FN@tempboxb\unhbox\FN@tempboxa}% \repeat } - \def\removehboxes{\setbox\FN@tempboxa=\lastbox + \def\FN@removehboxes{\setbox\FN@tempboxa=\lastbox \ifhbox - \FN@tempboxa{\removehboxes}% + \FN@tempboxa{\FN@removehboxes}% \unhbox\FN@tempboxa \fi } @@ -1357,363 +1745,42 @@ % \end{macro} % % -% \subsection{The other footnote commands}\label{sec:perpage-code} -% -% \begin{macro}{\ifFN@pp@footnotehint} -% A conditional needed by the perpage code: must be defined outside -% the \textsl{perpage} conditional -% \begin{macrocode} -\newif\ifFN@pp@footnotehint -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\c@pp@next@reset} -% Counter used to store information about the next reset of the -% footnote number, in perpage mode. -% \begin{macrocode} -\newcounter{pp@next@reset}% -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\ifFN@pp@towrite} -% A conditional that mediates the interaction between the -% \texttt{perpage} option and the \texttt{multiple} option. -% \begin{macrocode} -\newif\ifFN@pp@towrite -\FN@pp@towritefalse -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\ifFN@pp@lastseq} -% We prevent endless processions of diagnostics `footnote sequence -% lost' by using this conditional (again, needs to be defined outside -% the \textsl{perpage} conditional: -% \begin{macrocode} -%<*PPdebug> -\newif\ifFN@pp@lastseq -\global\FN@pp@lastseqfalse -%</PPdebug> -% \end{macrocode} -% \end{macro} -% -% Now, do we need to patch \cs{footnote} for per-page footnotes? -% \begin{macrocode} -\ifFN@perpage - \CheckCommand*\footnote{\@ifnextchar [%] - \@xfootnote - {% - \stepcounter\@mpfn \protected@xdef\@thefnmark{\thempfn}% - \@footnotemark \@footnotetext - }% - } - \renewcommand*\footnote{\@ifnextchar [%] - \@xfootnote - {% - \stepcounter\@mpfn \protected@xdef\@thefnmark{\thempfn}% - \FN@pp@footnote\@footnotemark -% \end{macrocode} -% -% In case that we're \emph{not} running \texttt{multiple} option, -% \cs{@footnotemark} \emph{won't} have written details to the |.aux| -% file, so do it now: -% \begin{macrocode} - \ifFN@pp@towrite - \FN@pp@writetemp - \FN@pp@towritefalse - \fi - \@footnotetext - }% - } -% \end{macrocode} -% -% And the analagous change for \cs{footnotemark} -% \begin{macrocode} - \CheckCommand*\footnotemark{% - \@ifnextchar [%] - \@xfootnotemark - {% - \stepcounter{footnote}% - \protected@xdef\@thefnmark{\thefootnote}% - \@footnotemark - }% - } - \renewcommand*\footnotemark{% - \@ifnextchar [%] - \@xfootnotemark - {% - \stepcounter{footnote}% - \protected@xdef\@thefnmark{\thefootnote}% - \FN@pp@footnote\@footnotemark -% \end{macrocode} -% -% again, tidy up if we're not doing \texttt{multiple} option -% \begin{macrocode} - \ifFN@pp@towrite - \FN@pp@writetemp - \FN@pp@towritefalse - \fi - }% - } -% \end{macrocode} -% -% \begin{macro}{\FN@pp@initialstab} -% Now the supporting commands\dots -% -% if we encounter no information in the |.aux| file, we make a first -% stab resetting footnote on the page number counter -% \begin{macrocode} - \gdef\FN@pp@initial@stab{\@addtoreset{footnote}{page}} - \AtBeginDocument{\FN@pp@initial@stab} -% \end{macrocode} -% \end{macro} -% -% We use a counter to keep pace with the footnotes: this counter is -% used in the data that's written to the |.aux| file, and matched to -% create the correct footnote numbers on the second and subsequent -% passes. -% \begin{macrocode} - \newcounter{@fnserial} -% \end{macrocode} -% -% \begin{macro}{\FN@pp@cpage} -% The package requires a ``knowledge'' of the current page number. -% It's kept in \cs{FN@pp@cpage} -% \begin{macrocode} - \def\FN@pp@cpage{0} -% \end{macrocode} -% \end{macro} % -% \begin{macro}{\footnotehint} -% However, the progress of page numbers isn't predictable, so we have -% a flag saying `reset footnote number'. The flag is for indirect use -% by people who diddle with the page number, via the \cs{footnotehint} -% command, as well as various places where we \emph{know} there could -% be a discontinuity. -% \begin{macrocode} - \FN@pp@footnotehinttrue - \newcommand{\footnotehint}{% - \setcounter{footnote}{0}% - \protected@writeaux\relax{\protect\FN@pp@footnotehinttrue}% - \@tempcnta\c@@fnserial - \advance\@tempcnta\@ne - \global\c@pp@next@reset\@tempcnta - } - \AtBeginDocument{\protected@writeaux\relax{% - \protect\providecommand{\protect\FN@pp@footnotehinttrue}{}% - }% - } -% \end{macrocode} -% \end{macro} % -% \begin{macro}{\FN@pp@lastfoot} -% Dummy value for the number of the last footnote we came across. -% \begin{macrocode} -\def\FN@pp@lastfoot{-1} -% \end{macrocode} -% \end{macro} % -% \begin{macro}{\FN@pp@footnote@aux} -% The command \cs{FN@pp@footnote@aux} is written to the |.aux| file -% for every footnote counter allocated (other than in minipages):\\ -% |#1| is the footnote serial number\\ -% |#2| is the page the footnote was actually written on -% \begin{macrocode} - \newcommand{\FN@pp@footnote@aux}[2]{% - \ifnum\FN@pp@lastfoot<#1 - \ifFN@pp@footnotehint - \FN@pp@resetfn{#1}{#2}% - \FN@pp@footnotehintfalse - \else - \gdef\@tempa{#2}% - \ifx\@tempa\FN@pp@cpage - \else - \FN@pp@resetfn{#1}{#2}% - \fi - \fi - \def\FN@pp@lastfoot{#1}% -%<*PPdebug> - \else - \ifFN@pp@debug - \typeout{not considering footnote serial number #1 - (last valid was \FN@pp@lastfoot)}% - \fi -%</PPdebug> - \fi -% \end{macrocode} +% \begin{macro}{\FN@setfootnoteparawidth} +% What we have to use as the width for the footnote paragraph +% depends on whether or not we typeset in several columns. If single +% column or normal two-column is used then the right value is +% \cs{columnwidth}. However, inside a \texttt{multicols} environment +% we need to use \cs{textwidth} as the footnotes there will span +% across all columns. % -% Since we've now had at least one item of footnote information from -% a |.aux| file, we can't allow footnote resetting per page. +% To detect if we are inside such an environment we look at +% \cs{doublecolnumber} which is only positive if inside such an +% environment. % \begin{macrocode} - \global\let\FN@pp@initial@stab\relax - } +\@ifpackageloaded{multicol} + {\def\FN@setfootnoteparawidth + {\hsize\ifnum\doublecol@number>\@ne + \textwidth + \else \columnwidth \fi}} + {\def\FN@setfootnoteparawidth{\hsize\columnwidth}} % \end{macrocode} % \end{macro} % -% \begin{macro}{\FN@pp@resetfn} -% Set the flag to reset the footnote number; this constructs a chain -% through the footnote serial numbers at the start of each page -% \begin{macrocode} - \newcommand{\FN@pp@resetfn}[2]{% - \gdef\FN@pp@cpage{#2}% - \expandafter\gdef - \csname FN@pp@next-\FN@pp@prev@foot\endcsname{#1}% - \def\FN@pp@prev@foot{#1}% - \expandafter\xdef - \csname FN@pp@next-\FN@pp@prev@foot\endcsname{\the\@MM}% - } -% \end{macrocode} -% \end{macro} % -% \begin{macro}{\FN@pp@prev@foot} -% The base of the footnote serial number chain (this element is never -% looked at: footnote serial 1 must always have number 1) -% \begin{macrocode} - \newcommand{\FN@pp@prev@foot}{root} -% \end{macrocode} -% \end{macro} % -% again, avoid confusion; also establish \cs{FN@pp@footnote@aux} in the -% |.aux| file -% \begin{macrocode} - \AtBeginDocument{\protected@writeaux\relax{% - \protect\providecommand{\protect\FN@pp@footnote@aux}[2]{}}% - \c@pp@next@reset\@ne - } -% \end{macrocode} % -% At end document, establish a new \cs{FN@pp@footnote@aux} which -% checks whether numbers have changed during the scan of the |.aux| -% files for changed labels and the like -% \begin{macrocode} - \AtEndDocument{\let\FN@pp@footnote@aux\FN@pp@footnote@endaux - \def\FN@pp@lastfoot{-1}% - \FN@pp@footnotehintfalse - \renewcommand{\FN@pp@prev@foot}{root} - } -% \end{macrocode} % -% \begin{macro}{\FN@pp@footnote@endaux} -% The footnote analysis command for end document -% \begin{macrocode} - \newcommand{\FN@pp@footnote@endaux}[2]{% - \ifnum\FN@pp@lastfoot<#1 - \ifFN@pp@footnotehint - \FN@pp@resetfn@end{#1}{#2}% - \FN@pp@footnotehintfalse - \else - \gdef\@tempa{#2}% - \ifx\@tempa\FN@pp@cpage - \else - \FN@pp@resetfn@end{#1}{#2}% - \fi - \fi - \def\FN@pp@lastfoot{#1}% -%<*PPdebug> - \else - \ifFN@pp@debug - \typeout{not considering footnote serial number #1 - (last valid was \FN@pp@lastfoot)}% - \fi -%</PPdebug> - \fi - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\FN@pp@resetfn@end} -% Deal with the \verb'.aux' file footnote details, at end document -% \begin{macrocode} - \newcommand{\FN@pp@resetfn@end}[2]{% - \def\@tempa{#1}% - \expandafter\ifx\csname FN@pp@next-\FN@pp@prev@foot\endcsname\@tempa% - \else - \@tempswatrue -%<*PPdebug> - \ifFN@pp@debug - \expandafter\ifx\csname FN@pp@next-\FN@pp@prev@foot\endcsname\relax - \ifFN@pp@lastseq\else - \typeout{footnote sequence lost between pages - \FN@pp@cpage\space and #2}% - \global\FN@pp@lastseqtrue - \fi - \else - \typeout{footnotes changed between pages \FN@pp@cpage\space and #2: - next was \csname FN@pp@next-\FN@pp@prev@foot\endcsname, now #1}% - \global\FN@pp@lastseqfalse - \fi - \fi -%</PPdebug> - \fi - \gdef\FN@pp@prev@foot{#1}% - \gdef\FN@pp@cpage{#2}% - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\clearpage} -% \begin{macro}{\FN@pp@@clearpage} -% Now, how do we cope with \cs{include}d documents? We can't insert -% anything (the |includex| package offers \cs{AtBeginIncludedDocument} -% but there's no corresponding command for files included by the -% kernel \cs{include}. So we insert a footnote hint at every -% \cs{clearpage} -% \begin{macrocode} -\let\FN@pp@@clearpage\clearpage -\renewcommand{\clearpage}{\footnotehint\FN@pp@@clearpage} -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\FN@pp@footnote} -% The business end of the option: a macro to decide on footnote -% numbers, called from \cs{footnote} and \cs{footnotemark} (see -% above). -% \begin{macrocode} -\def\FN@pp@footnote{% - \if@minipage\else - \global\advance\c@@fnserial\@ne - \if@filesw -% \end{macrocode} -% -% In case we're also doing \texttt{multiple} option, we now save up -% the command to write to the |.aux| file, and mark we've done so -% \begin{macrocode} - \xdef\FN@pp@writetemp{% - \noexpand\protected@writeaux\relax{% - \string\FN@pp@footnote@aux - {\the\c@@fnserial}{\noexpand\thepage}% - }% - }% - \FN@pp@towritetrue - \fi - \ifnum\c@pp@next@reset>\c@@fnserial - \else - \global\expandafter\csname c@\@mpfn\endcsname\@ne - \protected@xdef\@thefnmark{\thempfn}% -% \end{macrocode} +% \subsection{The other footnote commands}\label{sec:perpage-code} % -% Now look at the next element in the chain: -% \begin{macrocode} - \expandafter\let\expandafter\@tempa - \csname FN@pp@next-\number\c@pp@next@reset\endcsname -% \end{macrocode} % -% If the chain is broken here, set the next reset point to something -% (one hopes) infeasibly large\dots{} a weak point? -% \begin{macrocode} - \ifx\@tempa\relax - \global\c@pp@next@reset\@MM - \else - \global\c@pp@next@reset\@tempa - \fi - \fi - \fi -} -% \end{macrocode} -% \end{macro} -% -% End of code loaded when \texttt{perpage} option is given +% We delegate the perpage option to a different package \ldots % \begin{macrocode} +\ifFN@perpage + \RequirePackage{perpage} + \MakePerPage{footnote} \fi % \end{macrocode} % @@ -1808,13 +1875,13 @@ % % \begin{macro}{\multiplefootnotemarker} % \begin{macro}{\multfootsep} -% \begin{macro}{\@footnotemark} +% \begin{macro}{\FN@footnotemark} % \begin{macro}{\FN@mf@prepare} % \begin{macro}{\FN@mf@check} % This (revised) code derives from a suggestion by Alexander Rozhenko % (the author of the \textit{manyfoot} package): the intention is that % \textit{footmisc} and \textit{manyfoot} should be able to -% `interwork', in the sense that each would recognise the other's +% `interwork', in the sense that each would recognize the other's % footnote marks and behave appropriately. The trick is that % both \cs{footnote} and \cs{footnotemark} insert a marker (a % cancelling pair of kerns of \cs{multiplefootnotemarker} (of opposite @@ -1826,14 +1893,17 @@ \ifFN@multiplefootnote \providecommand*{\multiplefootnotemarker}{3sp} \providecommand*{\multfootsep}{,} - \CheckCommand*\@footnotemark{% - \leavevmode - \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi - \@makefnmark - \ifhmode\spacefactor\@x@sf\fi - \relax - } - \renewcommand*\@footnotemark{% +% +% FMi: not checking, more harm than gain +% \CheckCommand*\@footnotemark{% +% \leavevmode +% \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi +% \@makefnmark +% \ifhmode\spacefactor\@x@sf\fi +% \relax +% } +% + \newcommand*\FN@footnotemark{% \leavevmode \ifhmode \edef\@x@sf{\the\spacefactor}% @@ -1841,16 +1911,6 @@ \nobreak \fi \@makefnmark -% \end{macrocode} -% -% if we're also doing option \texttt{perpage}, write its stuff to the -% |.aux| file for it, so the \emph{wotsit} node doesn't interfere with -% our \cs{kern} detection. -% \begin{macrocode} - \ifFN@pp@towrite - \FN@pp@writetemp - \FN@pp@towritefalse - \fi \FN@mf@prepare \ifhmode\spacefactor\@x@sf\fi \relax @@ -1873,6 +1933,10 @@ % \begin{macrocode} \else \let\FN@mf@prepare\relax +% \end{macrocode} +% Need to provide a definition for \cs{FN@footnotemark} in that case. +% \begin{macrocode} + \let\FN@footnotemark\@footnotemark \fi % \end{macrocode} % \end{macro} @@ -1946,10 +2010,10 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\setfnsymbol} -% \begin{macro}{\FN@fnsymbol@lamport} % \section{Symbol option variants} % +% \begin{macro}{\setfnsymbol} +% \begin{macro}{\FN@fnsymbol@lamport} % Lamport's choice of symbols for \cs{fnsymbol} wasn't entirely % ``traditional'', so we (now) provide alternatives. The % \cs{setfnsymbol} command offers a small number of choices, and the @@ -2021,26 +2085,18 @@ % Note that doubled-up (and worse\,---\,see below) symbols need braces % around them. % \begin{macrocode} -\newcommand{\DefineFNsymbols}{% - \@ifstar{\@tempswbtrue\@DefineFNsymbols}% - {\@tempswbfalse\@DefineFNsymbols}% -} -\newcommand{\@DefineFNsymbols}[1]{% - \@ifnextchar[% ] - {\@DefineFNsymbols@{#1}}{\@DefineFNsymbols@{#1}[text]}% -} -\def\@DefineFNsymbols@#1[#2]#3{% - \expandafter\ifx\csname FN@fnsymbol@#1\endcsname\relax - \PackageInfo{footmisc}{Declaring symbol style #1}% +\DeclareDocumentCommand\DefineFNsymbols {smO{text}m}{% + \expandafter\ifx\csname FN@fnsymbol@#2\endcsname\relax + \PackageInfo{footmisc}{Declaring symbol style #2}% \else - \PackageWarning{footmisc}{Redeclaring symbol style #1}% + \PackageWarning{footmisc}{Redeclaring symbol style #2}% \fi \toks@{}% \def\@tempb{\end}% - \FN@build@symboldef#3\end + \FN@build@symboldef#4\end \def\@tempc{math}% - \def\@tempd{#2}% - \expandafter\xdef\csname FN@fnsymbol@#1\endcsname##1{% + \def\@tempd{#3}% + \expandafter\xdef\csname FN@fnsymbol@#2\endcsname##1{% \ifx\@tempc\@tempd \noexpand\ensuremath \else @@ -2050,15 +2106,15 @@ \noexpand\ifcase##1% \the\toks@ \noexpand\else - \if@tempswb - \noexpand\@ctrerr - \else - \noexpand\@arabic##1\noexpand\FN@orange##1% - \fi + \IfBooleanTF#1{\noexpand\@ctrerr}% + {\noexpand\FN@orange##1}% \noexpand\fi }% }% } +% \end{macrocode} +% +% \begin{macrocode} \def\FN@build@symboldef#1{% \def\@tempa{#1}% \ifx\@tempa\@tempb @@ -2080,30 +2136,24 @@ % Now do the same job for the ``modern'' way of having both text and % maths variants of everything. % \begin{macrocode} -\newcommand{\DefineFNsymbolsTM}{% - \@ifstar{\@tempswbtrue\@DefineFNsymbolsTM}% - {\@tempswbfalse\@DefineFNsymbolsTM}}% -\newcommand{\@DefineFNsymbolsTM}[2]{% - \expandafter\ifx\csname FN@fnsymbol@#1\endcsname\relax - \PackageInfo{footmisc}{Declaring symbol style #1}% +\DeclareDocumentCommand\DefineFNsymbolsTM {smm}{% + \expandafter\ifx\csname FN@fnsymbol@#2\endcsname\relax + \PackageInfo{footmisc}{Declaring symbol style #2}% \else - \PackageWarning{footmisc}{Redeclaring symbol style #1}% + \PackageWarning{footmisc}{Redeclaring symbol style #2}% \fi \toks@{}% \def\@tempb{\end}% - \FN@build@symboldefTM#2\end\@null - \expandafter\xdef\csname FN@fnsymbol@#1\endcsname##1{% + \FN@build@symboldefTM#3\end\@null + \expandafter\xdef\csname FN@fnsymbol@#2\endcsname##1{% \noexpand\ifcase##1% \the\toks@ \noexpand\else - \if@tempswb - \noexpand\@ctrerr - \else - \noexpand\@arabic##1\noexpand\FN@orange##1% - \fi - \noexpand\fi + \IfBooleanTF#1{\noexpand\@ctrerr}% + {\noexpand\FN@orange##1}% + \noexpand\fi }% -}% +} % \end{macrocode} % Note that this version has two variants of every definition, so % needs two stopper codes above. @@ -2121,29 +2171,6 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\TextOrMath} -% This is a stripped down (e-\TeX{} only) version of what appears in -% fixltx2e. If the command's already defined, we assume it's that -% version. -% \begin{macrocode} -\@ifundefined{TextOrMath}{% - \@ifundefined{eTeXversion}{% - \PackageError{footmisc}{Can't define commands for footnote symbol}% - {Use e-LaTeX, or load package fixltx2e before - footmisc}% - }{% - \protected\expandafter\def\csname TextOrMath\space\endcsname{% - \ifmmode \expandafter\@secondoftwo - \else \expandafter\@firstoftwo \fi - } - \edef\TextOrMath#1#2{% - \expandafter\noexpand\csname TextOrMath\space\endcsname - {#1}{#2}% - }% - }% -}{} -% \end{macrocode} -% \end{macro} % % \begin{macro}{\FN@orange} % \begin{macro}{\@fnsymbol@orange} @@ -2152,10 +2179,13 @@ % they're allowed to\,--\,e.g., in the \texttt{symbol*} option). % \begin{macrocode} \def\FN@orange#1{% - \@bsphack - \PackageInfo{footmisc}{Footnote number \number#1 out of range}% - \protect\@fnsymbol@orange - \@esphack + \ifFN@robust + \@arabic#1% + \@bsphack + \PackageInfo{footmisc}{Footnote number \number#1 out of range}% + \protect\@fnsymbol@orange + \@esphack + \else \@ctrerr \fi } \global\let\@diagnose@fnsymbol@orange\relax \AtEndDocument{\@diagnose@fnsymbol@orange} @@ -2173,18 +2203,6 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\textbardbl} -% This is defined in recent \LaTeX{} releases, but not in (for -% example) that distributed with the last release of te\TeX{}. Since -% it's needed in some symbol set definitions (including Lamport's) we -% define it here. -% \begin{macrocode} -\@ifundefined{textbardbl}{% - \DeclareTextSymbol{\textbardbl}{OMS}{107}% - \DeclareTextSymbolDefault{\textbardbl}{TS1}}{}% -% \end{macrocode} -% (This definition comes from the \LaTeX{} sources.) -% \end{macro} % % \begin{macro}{\FN@fnsymbol@bringhurst} % \begin{macro}{\FN@fnsymbol@chicago} @@ -2195,24 +2213,24 @@ % footnote symbols, plus a robust version of the original Lamport set, % and an extended version of Lamport's original % \begin{macrocode} -\DefineFNsymbolsTM*{bringhurst}{% - \textasteriskcentered * +\DefineFNsymbolsTM{bringhurst}{% + \textasteriskcentered *% \textdagger \dagger \textdaggerdbl \ddagger \textsection \mathsection \textbardbl \|% \textparagraph \mathparagraph }% -\DefineFNsymbolsTM*{chicago}{% - \textasteriskcentered * +\DefineFNsymbolsTM{chicago}{% + \textasteriskcentered *% \textdagger \dagger \textdaggerdbl \ddagger \textsection \mathsection \textbardbl \|% \#\#% }% -\DefineFNsymbolsTM*{wiley}{ - \textasteriskcentered * +\DefineFNsymbolsTM{wiley}{% + \textasteriskcentered *% {\textasteriskcentered\textasteriskcentered}{**}% \textdagger \dagger \textdaggerdbl \ddagger @@ -2220,8 +2238,8 @@ \textparagraph \mathparagraph \textbardbl \|% }% -\DefineFNsymbolsTM{lamport-robust}{ - \textasteriskcentered * +\DefineFNsymbolsTM{lamport-robust}{% + \textasteriskcentered *% \textdagger \dagger \textdaggerdbl \ddagger \textsection \mathsection @@ -2232,7 +2250,7 @@ {\textdaggerdbl\textdaggerdbl}{\ddagger\ddagger}% } \DefineFNsymbolsTM*{lamport*}{% - \textasteriskcentered * + \textasteriskcentered *% \textdagger \dagger \textdaggerdbl \ddagger \textsection \mathsection @@ -2253,7 +2271,7 @@ } \setfnsymbol{lamport*} \DefineFNsymbolsTM{lamport*-robust}{% - \textasteriskcentered * + \textasteriskcentered *% \textdagger \dagger \textdaggerdbl \ddagger \textsection \mathsection @@ -2281,29 +2299,6 @@ % % \section{Other miscellaneous commands} % -% \subsection{Footnote references} -% -% \begin{macro}{\footref} -% Syntax: \cs{footref}\marg{label-name} -% -% One often wishes to refer to a footnote; in some circumstances, -% \cs{footnotemark} just isn't good enough (for example, inside a -% |minipage|, when \cs{footnotemark} creates a reference to footnotes -% outside the minipage). -% -% \cs{footref} addresses this problem by making a label reference that -% actually looks like a \cs{footnotemark}. (The command is available -% in the |memoir| class, and we therefore \cs{providecommand} it -% rather than defining it ``outright''.) -% \begin{macrocode} -\providecommand*{\footref}[1]{% - \begingroup - \unrestored@protected@xdef\@thefnmark{\ref{#1}}% - \endgroup - \@footnotemark -} -% \end{macrocode} -% \end{macro} % % \subsection{Minipage \cs{footnotemark}s} % @@ -2333,6 +2328,26 @@ % \end{macrocode} % \end{macro} % +% +% If \textsf{hyperref} was loaded first, it has saved +% \cs{@footnotetext} and \cs{@footnotemark} away and then redefined +% them. The saved versions are now wrong, so we reassign them. +% \begin{macrocode} +\@ifpackageloaded{hyperref}{% + \let\H@@footnotetext\FN@footnotetext + \let\H@@footnotemark\FN@footnotemark +}{% +% \end{macrocode} +% If \textsf{hyperref} wasn't loaded we copy our new definitions to +% \cs{@footnotetext} and \cs{@footnotemark} for actual use. If +% \textsf{hyperref} is loaded later it will do its magic and save +% our definitions. +% \begin{macrocode} + \let \@footnotetext \FN@footnotetext + \let\@footnotemark \FN@footnotemark +} +% \end{macrocode} +% % \begin{macrocode} \endinput %</package> @@ -2340,19 +2355,3 @@ % % \Finale % -% -%% \CharacterTable -%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z -%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z -%% Digits \0\1\2\3\4\5\6\7\8\9 -%% Exclamation \! Double quote \" Hash (number) \# -%% Dollar \$ Percent \% Ampersand \& -%% Acute accent \' Left paren \( Right paren \) -%% Asterisk \* Plus \+ Comma \, -%% Minus \- Point \. Solidus \/ -%% Colon \: Semicolon \; Less than \< -%% Equals \= Greater than \> Question mark \? -%% Commercial at \@ Left bracket \[ Backslash \\ -%% Right bracket \] Circumflex \^ Underscore \_ -%% Grave accent \` Left brace \{ Vertical bar \| -%% Right brace \} Tilde \~} |