Debian Codegraph @

texmf-dist/source/latex/footmisc/footmisc.dtx

raw
1 % \iffalse meta-comment
2 %
3 %% File: footmisc.dtx (C) Copyright 1995-2011 Robin Fairbairns
4 %% (C) Copyright 2018-2025 Frank Mittelbach
5 %
6 % It may be distributed and/or modified under the conditions of the
7 % LaTeX Project Public License (LPPL), either version 1.3c of this
8 % license or (at your option) any later version. The latest version
9 % of this license is in the file
10 %
11 % https://www.latex-project.org/lppl.txt
12 %
13 % This bundle has the status "maintained" and the current maintainer
14 % is Frank Mittelbach.
15 %
16 % The development version of the bundle can be found at
17 %
18 % https://github.com/FrankMittelbach/fmitex-footmisc/
19 %
20 % for those people who are interested or want to report an issue.
21 %
22 %
23 %
24 % We use the same body for the \cs{ProvidesFile} as for the
25 % \cs{ProvidesPackage} command.
26 %
27 % \begin{macrocode}
28 %<*!debugins>
29 \NeedsTeXFormat{LaTeX2e}
30 %</!debugins>
31 %<*dtx>
32 \ProvidesFile{footmisc.dtx}%
33 %</dtx>
34 %<+package>\providecommand\DeclareRelease[3]{}
35 %<+package>\providecommand\DeclareCurrentRelease[2]{}
36 %<+package>
37 %<+package>\DeclareRelease{v5}{2011-06-06}{footmisc-2011-06-06.sty}
38 %<+package>\DeclareRelease{v6}{2022-02-14}{footmisc-2022-02-14.sty}
39 %<+package>\DeclareCurrentRelease{}{2025-03-10}
40 %<package>\ProvidesPackage{footmisc}%
41 %<*!debugins>
42 [2025/05/09 v7.0b
43 %</!debugins>
44 %<package> a miscellany of footnote facilities%
45 %<*dtx>
46 footmisc package source file%
47 %</dtx>
48 %<*!debugins>
49 ]
50 %</!debugins>
51 % \end{macrocode}
52 %
53 % Code to enable LaTeX processing of the file without the intervention
54 % of a driver file.
55 % \begin{macrocode}
56 %<*driver>
57 \setcounter{errorcontextlines}{999}
58 \documentclass{ltxdoc}
59 \usepackage{hyperref}
60 % \end{macrocode}
61 %
62 % We limit the things that we will index
63 % \begin{macrocode}
64 \DoNotIndex{\#,\@MM,\@cclv,\@gobble,\@ifnextchar,\@ifundefined}
65 \DoNotIndex{\|,\advance,\begingroup,\bgroup,\box,\csname}
66 \DoNotIndex{\dagger,\ddagger,\def,\divide,\dp}
67 \DoNotIndex{\edef,\egroup,\ifx,\else,\fi,\endcsname,\endgroup,\end}
68 \DoNotIndex{\endinput,\ensuremath,\expandafter}
69 \DoNotIndex{\gdef,\global,\hbox,\hskip,\hss,\ht}
70 \DoNotIndex{\ifcase,\or,\ifdim,\ifhbox,\ifhmode,\ifnum,\ifvbox,
71 \fi ,\fi ,\fi ,\fi ,\fi ,\fi }
72 \DoNotIndex{\ifvoid,\fi,\kern,\let,\long,\loop}
73 \DoNotIndex{\MessageBreak,\newbox,\newcommand,\newcounter}
74 \DoNotIndex{\newdimen,\newif,\newskip,\newtoks,\noexpand}
75 \DoNotIndex{\P,\p@,\par,\penalty,\protect,\providecommand}
76 \DoNotIndex{\relax,\renewcommand,\S,\setbox,\setcounter}
77 \DoNotIndex{\skip,\space,\the,\typeout,\vbox,\vskip}
78 \DoNotIndex{\wd,\xdef,\@}
79 \GetFileInfo{footmisc.dtx}
80 \EnableCrossrefs
81 % To get documented source of the package, comment out the next line,
82 % and uncomment the following one; otherwise, create yourself
83 % (somewhere on your LaTeX input path) a file ltxdoc.cfg that contains
84 % simply \AtBeginDocument{\AlsoImplementation}
85 \OnlyDescription
86 %\AlsoImplementation
87 \CodelineIndex
88 \setcounter{StandardModuleDepth}{1}
89 \begin{document}
90 \DocInput{footmisc.dtx}
91 \end{document}
92 %</driver>
93 % \end{macrocode}
94 %
95 % \fi
96 %
97 %
98 %
99 % \title{\texttt{footmisc} ---\\
100 % a portmanteau package\\
101 % for customizing footnotes in \LaTeX\thanks{This file has
102 % version number \fileversion, last revised \filedate}}
103 % \author{Robin Fairbairns\thanks{Formerly: University of Cambridge Computer
104 % Laboratory, Cambridge, UK} \and
105 % Frank Mittelbach\thanks{Responsible maintainer since 2018}}
106 % \maketitle
107 %
108 %
109 % \newcommand\fmi[1]{\begin{quote} NOTE: \itshape #1\end{quote}}
110 % \newcommand\NEW[1]{\marginpar{\mbox{}\hfill\fbox{New: #1}}}
111 % \providecommand\pkg[1]{\texttt{#1}}
112 %
113 %
114 % \section*{Copyright statement}
115 %
116 % \noindent Program: \texttt{footmisc.dtx}\par
117 % \noindent Copyright 1995--2011 Robin Fairbairns\par
118 % \noindent Copyright 2018--2025 Robin Fairbairns, Frank Mittelbach
119 %
120 % This program is offered under the terms
121 % of the \LaTeX{} Project Public License, version 1.3c of this license or
122 % (at your option) any later version. The latest version of this
123 % license is in \texttt{https://www.latex-project.org/lppl.txt}, and version
124 % 1.3c or later is part of all distributions of \LaTeX{} version
125 % 2008 or later.
126 %
127 % This work has the LPPL maintenance status `maintained'.
128 %
129 %
130 % \tableofcontents
131 %
132 %
133 % \section*{History}
134 %
135 % This package originated as support of a personal project, which I (Robin)
136 % was switching to \LaTeX{} 2e over the Christmas holiday period of
137 % 1993, using the first \ensuremath{\beta} release.
138 %
139 % In its first form, it was known as the ``footnote'' package, but by
140 % the time I had released it to CTAN, that name had already been
141 % used by a package written by Mark Wooding. So the package is now
142 % known (as you can see) as ``footmisc''.
143 %
144 % Frank took over maintenance in 2018 but due to other commitments never
145 % got around finishing the changes he started to make in 2018.
146 %
147 % In 2022 a few new options (\texttt{abovefloats},
148 % \texttt{belowfloats}, and \texttt{bottomfloats}
149 % got introduced and the package now works
150 % with \textsf{hyperref} regardless of loading order. There are
151 % however, still a few restrictions when using both packages together,
152 % in particular the \texttt{multiple} option does not fully work.
153 %
154 %
155 %
156 %
157 % \section{User interface~--- package options}
158 %
159 % The \textsf{footmisc} package provides several different
160 % customizations of the way footnotes are represented in \LaTeXe{}
161 % documents (the sources of the code in this package are various, but
162 % all of it has been massaged by the author; where the code comes from
163 % elsewhere, there are attributions given below, somewhere or other).
164 %
165 % The interface to the
166 % package's options is mostly rather simple~--- each one is presented as an
167 % option in the |\usepackage| command, and for most, nothing else
168 % needs to be done. For example, to use a useful
169 % and consistent set, the author invokes the package with the
170 % command |\usepackage[perpage,para,symbol*]{footmisc}|.
171 %
172 % For a small number of options, there are additional parameters
173 % available; these are described in the subsections below.
174 %
175 % \subsection{Option \texttt{perpage}}
176 % \label{sec:perpagedoc}
177 %
178 % This option resets footnote numbering for each page of the document.
179 % It needs at least two passes to do this correctly (though it comes
180 % as close as possible on the first pass). You generally have to make
181 % two passes with \LaTeX{} anyway, to get the cross-references right,
182 % so an additional pass for this purpose shouldn't cause any
183 % additional problem. The option includes code to report that
184 % `\emph{Label(s) may have changed}', which will help the poor user to
185 % realize that (yet) another run is in order.
186 %
187 % \subsection{Option \texttt{para}}
188 %
189 % This option (derived from code by Dominik Wujastyk and Chris Rowley)
190 % causes footnotes to be typeset as a single paragraph at the bottom
191 % of the page on which they occur. In the case that there is only one
192 % footnote on the page, no effect will be observed. However, if there
193 % are several footnotes on the page, they will be run together in the
194 % page foot, each introduced by its footnote mark. The original
195 % demand for the option came from the needs of those preparing
196 % critical editions; such documents typically have large numbers of
197 % small footnotes, which look ridiculous if each is typeset in a
198 % paragraph of its own; in most other disciplines, such multiplicities
199 % of footnotes represent mere self-indulgence: the author of this
200 % package is disgracefully guilty of this.
201 %
202 % Please note that ``old'' \LaTeX{} installations may have problems
203 % with the algorithm for \texttt{para} footnotes on very wide pages
204 % (for example, those used by the \textsf{a0poster} class). Recent
205 % \LaTeX{} installations use an improved technique that is believed
206 % not to be susceptible to this problem.
207 %
208 % \subsection{Option \texttt{side}}
209 %
210 % This option (suggested by Frank Mittelbach) causes footnotes to be
211 % typeset using the \cs{marginpar} command: this has the advantage
212 % that the note appears close to its ``call-up'', but has all the
213 % disadvantages associated with the \cs{marginpar} command (which
214 % consumes `float' slots, and doesn't always place itself correctly at
215 % the top of pages in two-sided documents). Since the measure in
216 % which the footnote is to be typeset is likely to be pretty narrow,
217 % users of the \texttt{side} option are recommended also to use the
218 % \texttt{ragged} option, to avoid ugly spacing and line breaks.
219 %
220 % There is a further problem (apart from the occasional failure to
221 % place the marginal note on the correct side of the page) in
222 % two-sided documents: one would like `raggedness' to appear
223 % differently in different margins (setting the left, rather than the
224 % right, side ragged in the left margin). (The author would welcome
225 % suggestions on means of addressing the problem.)
226 %
227 % \subsection{Option \texttt{ragged} and \cs{footnotelayout}}
228 %
229 % The package provides facilities for ragged right setting of
230 % footnotes (so long as the \texttt{para} option isn't in effect).
231 % The change is effected by use of the command \cs{footnotelayout};
232 % the package inserts this command into the start of the argument of
233 % \cs{footnotetext} (in effect: \cs{footnote} works, roughly, by
234 % calling the guts of \cs{footnotetext} at its end).
235 %
236 % If you want to use some special effect other than ragged right, feel
237 % free to change \cs{footnotelayout} yourself: some intriguing (and
238 % completely undesirable) results are no doubt available. Change the
239 % setting simply by use of
240 % \cs{renewcommand}\cs{footnotelayout}\texttt{\dots}\@. The
241 % \texttt{ragged} option simply sets \cs{footnotelayout} to set
242 % \cs{raggedright} or \cs{RaggedRight} as appropriate. (If you intend
243 % to use the \textsf{ragged2e} package, load it before
244 % \textsf{footmisc}~--- if \textsf{footmisc} finds \cs{RaggedRight} is
245 % available, it automatically uses it in place of \cs{raggedright}.)
246 %
247 % \subsection{Option \texttt{symbol}}
248 %
249 % This option simply establishes that footnotes are `labelled' by
250 % a symbol sequence. The command used is equivalent to that
251 % suggested in \LaTeX{} manuals such as Lamport's (the job performed
252 % by the option is very simple, and doesn't really need a package).
253 %
254 % Using symbols to `number' your footnotes can be problematic: there
255 % is a limited number of symbols, and \LaTeX{} will report an error if
256 % your footnotes exceed that limit. To avoid such problems, consider
257 % the \texttt{symbol*} option, or the \cs{setfnsymbol} command (see
258 % the next two sections), or number your footnotes by the page (see
259 % section~\ref{sec:perpagedoc}).
260 %
261 % \subsection{Option \texttt{symbol*}}
262 % \label{doc-symbol*}
263 %
264 % This is the \texttt{symbol} option, but with protection against the
265 % tedium that arises because of the instability of the
266 % \texttt{perpage} option. When executing the \texttt{perpage}
267 % option, the package often allocates footnotes to the wrong pages,
268 % only to correct itself on a later run (having warned the user of the
269 % need for the later run with a `\emph{Label(s) may have changed}'
270 % message). In these circumstances the \texttt{symbol} option is
271 % prone to producing \LaTeX{} errors, which stop processing, and
272 % confound automatic generation procedures. In the same situation,
273 % the \texttt{symbol*} option produces information messages and a
274 % warning message at end document, and the user may scan the log for
275 % those messages \emph{after} processing has stabilized. The option
276 % produces numbers (17 and higher, in the case of the default symbol
277 % set) in place of symbols, when the footnote number is too large.
278 %
279 % \subsection{The \cs{setfnsymbol} and \cs{DefineFNsymbols} commands}
280 % \label{footnote-symbols}
281 %
282 % \fmi{At some point in the past this interface got extended, but the
283 % documentation lags behind so this needs updating.}
284 %
285 % These commands permit the definition and use of alternative
286 % (ordered) sets of symbols for numbering footnotes. \LaTeX{} of
287 % course comes with such a set ready-defined, but the choice of
288 % symbols isn't universally loved.
289 %
290 % You may define a set of symbols with the \cs{DefineFNsymbols}
291 % command. \LaTeX{}'s default set would be defined by the command:
292 % \begin{center}
293 % \verb|\DefineFNsymbols*{lamport}|%
294 % \unskip\verb|{*\dagger\ddagger\S\P|\texttt{\char`\\\char`\|\%}\\
295 % \unskip\verb| {**}{\dagger\dagger}{\ddagger\ddagger}}|
296 % \end{center}
297 % Defined this way, the symbol set produces a ``counter too large''
298 % error; a robust version of the set (cf.~the \texttt{symbol*} option
299 % (see \ref{doc-symbol*})) is established by using the \cs{DefineFNsymbols} command
300 % without the optional |*|.
301 % You may select a set of symbols by use of the \cs{setfnsymbol}
302 % command; so to restore use of the default set, you would type:
303 % \begin{center}
304 % \verb|\setfnsymbol{lamport}|
305 % \end{center}
306 %
307 % This package defines a small selection of alternative sets of
308 % symbols, using \cs{DefineFNsymbols}:
309 % \begin{center}
310 % \begin{tabular}{ll}
311 % \texttt{bringhurst} & $*\,\dagger\,\ddagger\,\S\,\|\,\P$ \\
312 % \texttt{chicago} & $*\,\dagger\,\ddagger\,\S\,\|\,\#$ \\
313 % \texttt{wiley} & $*\,\mathop{**}\,\dagger\,\ddagger\,\S\,\P\,\|$
314 % \end{tabular}
315 % \end{center}
316 % together with a version of Lamport's original set that, with doubled
317 % versions of $\S$ and $\P$, and tripled versions of everything but
318 % the vertical bars, provides a symbol range to cover counters up to
319 % 16.
320 %
321 % This last set, known as \texttt{lamport*} is selected as the default
322 % symbol set by the package.
323 %
324 %
325 % \subsection{Options altering the footnotes/floats relationship}
326 %
327 % In \LaTeX{} the default order on a page is ``page text'' followed by
328 % ``footnotes'' (if any) followed by ``bottom floats'' (if any). The
329 % spacing between the three components depends of whether pages are
330 % always stretched to the same height (\cs{flushbottom} as used by the
331 % book class) or if they
332 % can run short (\cs{raggedbottom} as used by the article or report
333 % class).
334 % If \cs{raggedbottom} is in force, then
335 % \LaTeX{} would normally set the footnotes a mere
336 % \cs{skip}\cs{footins} distant from the bottom of the text and bottom
337 % floats follow separated by \cs{textfloatsep}. Both spaces might get
338 % stretched if \cs{flushbottom} is in force.
339 %
340 % If\NEW{2022-02}
341 % you want to diverge from this default placement, then there are
342 % a number of alterations that can be made:
343 % \begin{itemize}
344 % \item the order of footnotes and floats can be swapped; and
345 % \item both footnotes and floats can be forced to the bottom (i.e.,
346 % \cs{raggedbottom} then only applies to pages with neither), or
347 % \item only one of them is forced to the bottom, the other stays
348 % close to the text.
349 % \end{itemize}
350 % These can be achieved by applying one or more of the options
351 % discussed below.
352 %
353 %
354 %
355 % \subsubsection{Option \texttt{bottom}}
356 %
357 % This option forces footnotes (but not the floats) to the bottom of the page and
358 % therefore by default also implies \texttt{belowfloats}. If
359 % \cs{raggedbottom} is in force then the excess space goes above the
360 % footnotes if any are present. If \cs{flushbottom} is in force there
361 % is no visible difference to just specifying \texttt{belowfloats}.
362
363 % \subsubsection{Option \texttt{bottomfloats}}
364 %
365 % If\NEW{2022-02}
366 % you want force only floats to the bottom while the footnotes stay close to the text
367 % use the option \texttt{bottomfloats}. If not overwritten this
368 % implies \texttt{abovefloats}.
369 %
370 % \subsubsection{Options \texttt{abovefloats} and \texttt{belowfloats}}
371 %
372 % These\NEW{2022-02}
373 % two options describe the footnote placement with respect to
374 % floats on the page. \LaTeX's default is \texttt{abovefloats}, but it
375 % can still be useful to specify it because it fixes the bug discussed
376 % in section~\ref{sec:spacebug}.
377 %
378 %
379 % \subsubsection{Combining the four options}
380 %
381 % By\NEW{2022-02}
382 % default, \texttt{bottom} and \texttt{bottomfloats} options put any excess
383 % space (i.e., when \cs{raggedbottom} is in force) between floats
384 % and footnotes if both are present on a given page. If only one of
385 % them is present, the excess space goes below the text. If you prefer
386 % both footnotes and floats at the bottom instead, you can achieve this as follows:
387 % \begin{description}
388 % \item[\normalfont\texttt{bottom,abovefloats}] This puts the footnotes above any
389 % floats and both at the bottom when present.
390 % \item[\normalfont\texttt{bottomfloats,belowfloats}] This puts
391 % floats and footnotes at the bottom but
392 % footnotes last if both are present. If there are only footnotes
393 % they are still placed at the very bottom (think of them as being
394 % placed below the float ``area'' even if that has no floats inside).
395 % \end{description}
396 % The other combinations are duplicates, e.g.,
397 % \texttt{bottom,belowfloats} is the same as just specifying \texttt{bottom}.
398 %
399 %
400 % \subsubsection{Fixing a strange behavior of \LaTeX}
401 % \label{sec:spacebug}
402 %
403 % In\NEW{2022-02}
404 % the default case (if \pkg{footmisc} is not loaded) \LaTeX{} shows
405 % a somewhat strange discrepancy: on most pages the
406 % footnotes are attached a distance of \cs{skip}\cs{footins} from the
407 % main text, even if that page is run short (i.e., with
408 % \cs{raggedbottom} in force). However, whenever there is some
409 % infinite stretch at the end of the page, e.g., from using \cs{newpage} or
410 % \cs{clearpage} the footnotes are pushed to the bottom (in particular
411 % on the last page of a document or chapter).
412 %
413 % This is automatically corrected if \pkg{footmisc} is loaded with any
414 % of the options that deal with footnote placement, i.e.,
415 % \texttt{abovefloats}, \texttt{belowfloats}, \texttt{bottom}, or
416 % \texttt{bottomfloats}. In particular,
417 % if you want to have the standard \LaTeX{} placement (but with this
418 % strange behavior fixed, apply \texttt{abovefloats} (which is the
419 % normal order but with the bug fixed).
420 %
421 %
422 % \subsection{Option \texttt{marginal}}
423 %
424 % This option adjusts the position of footnote mark relative to the
425 % start of the line in which they appear (the option is
426 % incompatible with option \texttt{para}, for obvious reasons).
427 %
428 % When this option is in effect, the footnote is set
429 % \cs{footnotemargin} relative to the left margin of the page; the
430 % default setting for \cs{footnotemargin} is -0.8em, which means that
431 % the footnote mark will be set jutting 0.8em into the margin. If
432 % \cs{footnotemargin} is a positive length, the footnote mark will be
433 % set with its right edge \cs{footnotemargin} from the margin. (In
434 % the absence of the option, \cs{footnotemargin} is set to 1.8em; you
435 % may change that value with a \cs{setlength} command.)
436 %
437 % \subsection{Option \texttt{flushmargin}}
438 %
439 % This option is as option marginal, but sets the footnote marker
440 % flush with, but just inside the margin from, the text of the
441 % footnote.
442 %
443 % \subsection{Option \texttt{hang}}
444 %
445 % This option sets the footnote mark flush with the margin, and makes
446 % the body of the footnote hang at an indentation of
447 % \cs{footnotemargin} (if that is a positive distance), or the width
448 % of the marker (if \cs{footnotemargin} $\leq0$). The option code
449 % itself leaves \cs{footnotemargin} at its default value of 1.8em.
450 %
451 % The footnote itself may of course be longer than one paragraph; if
452 % so, the paragraphs will be separated by the vertical space specified
453 % by \cs{hangfootparskip}, and the second and subsequent paragraphs
454 % are indented by \cs{hangfootparindent}. Default values are:
455 % \begin{center}
456 % \begin{tabular}{ll}
457 % \cs{hangfootparskip} & 0.5\cs{baselineskip} \\
458 % \cs{hangfootparindent} & 0em
459 % \end{tabular}
460 % \end{center}
461 % The user may redefine these values (using
462 % \cs{renewcommand}): it is best to use the font-size-dependent
463 % measures (multiples of \cs{baselineskip} for the skip, multiples of
464 % |em| for the indent). Note that the default has only one of the two
465 % values non-zero; both zero may result in easily-missed paragraph
466 % breaks, and both non-zero is not generally thought to be a
467 % good-looking option.
468 %
469 % \subsection{Option \texttt{norule}}
470 %
471 % This option suppresses the `normal' footnote rule, and advances
472 % \cs{skip}\cs{footins} a bit to compensate
473 %
474 % \subsection{Option \texttt{splitrule}}
475 %
476 % This option makes puts a full-width rule above the split-off part of
477 % a split footnote. (Remember that split footnotes don't happen if
478 % you're doing paragraph footnotes.)
479 %
480 % The option provides three different \cs{footnoterule} commands:
481 % \begin{center}
482 % \begin{tabular}{ll}
483 % \cs{mpfootnoterule} & for use in minipages \\
484 % \cs{pagefootnoterule} & for normal footnotes on regular pages \\
485 % \cs{splitfootnoterule} & for the tail of a split footnote
486 % \end{tabular}
487 % \end{center}
488 % By default, \cs{mpfootnoterule} and \cs{pagefootnoterule} retain the
489 % original definition of \cs{footnoterule} (which may have been
490 % modified by a \texttt{norule} option), while \cs{splitfootnoterule}
491 % becomes a full-width rule.
492 %
493 % \subsection{The \texttt{stable} option}
494 %
495 % This option deals with the problem of placing footnotes in section
496 % titles (and so on). While there is (sometimes, just) justification
497 % for putting footnotes in titles, \LaTeX's treatment of the content
498 % of titles militates against them. Of course, the title argument is
499 % ordinarily a moving one, and \cs{footnote} is a fragile command, but
500 % the real problem comes from the way the argument actually moves~---
501 % which is to two places. The argument moves to the table of
502 % contents, where the footnote will (at least) look odd. But the
503 % argument also moves to the marks that make up page headers, etc.,
504 % and \emph{there} it creates havoc, since page headers are executed
505 % in page make-up, and page make-up \emph{must not} create footnotes.
506 %
507 % If you use the \texttt{stable} option, the footnote won't move to
508 % the table of contents or the page headers, but it will be typeset
509 % correctly within the title itself.
510 %
511 % The situation with \cs{footnotemark} is less dire (it could in
512 % principle appear in page headers, for example); footnote marks
513 % appearing on pages other than where their text appears are none the
514 % less confusing, and the stable option treats \cs{footnotemark} in
515 % the same way that it treats \cs{footnote}.
516 %
517 % \subsection{The \texttt{multiple} option}
518 %
519 % This option deals with the case where the author needs to type
520 % things like
521 % \begin{verbatim}
522 % mumble\footnote{blah}\footnote{grumble}
523 % \end{verbatim}
524 % Without special treatment, \LaTeX{} would output something like
525 % \begin{quote}
526 % mumble\textsuperscript{1314}
527 % \end{quote}
528 % \noindent What the \texttt{multiple} option makes of the above is
529 % \begin{quote}
530 % mumble\textsuperscript{13,14}
531 % \end{quote}
532 % which is what most people would expect. The comma separator
533 % actually derives from the definition of \cs{multfootsep}, which
534 % may be changed by \cs{renewcommand} if the option is in effect.
535 %
536 % The option also treats \cs{footnotemark} in the same way.
537 %
538 % \subsection{User interface~--- miscellaneous commands}
539 %
540 % The package also defines some miscellaneous footnote-related
541 % commands. The present group provides alternative means of producing
542 % footnote marks: \cs{footref} and \cs{mpfootnotemark}.
543 %
544 % When you're in a minipage, \cs{footnote} numbers run according to the
545 % minipage's own footnote counter, and the marks are set in italic
546 % letters. However, the numbers used by \cs{footnotemark} make
547 % reference to the `main'
548 % footnote counter, and are set in whatever is the current style for
549 % that: this behavior often surprises, and there's no obvious way in
550 % standard \LaTeX{} to ``get around'' it. The command
551 % \cs{mpfootnotemark} gets around this problem in a minipage, by
552 % generating footnote marks in the same way as those used by
553 % \cs{footnote}.
554 %
555 % In fact, making reference to footnotes in
556 % general can be problematic: it can be done by noting down the
557 % value of the footnote
558 % marker in a counter (or the like) and then using the value in a
559 % subsequent \cs{footnotemark} or \cs{mpfootnotemark}. This is a
560 % tedious way of going about things, and doesn't allow representation
561 % of all possible forms of footnote mark; \cs{footref} is a form of
562 % reference command that sets the reference as if it were
563 % a footnote.\footnote{This command is already provided by the \LaTeX{} format.}
564 % The label should be set \emph{within} the argument of the footnote
565 % command that is being labelled:
566 % \begin{verbatim}
567 % ...\footnote{Note text\label{fnlabel}}
568 % ...
569 % ... potato head\footref{fnlabel}
570 % \end{verbatim}
571 %
572 % \section{User interface~--- interactions with other packages}
573 %
574 % The \textsf{footmisc} package modifies several parts of the \LaTeX{}
575 % kernel; what gets modified depends on the options you select. This
576 % behavior can cause problems with other packages, particularly those
577 % that also modify the kernel.
578 %
579 % Known interactions are:
580 % \begin{description}
581 % \item[\normalfont\textsf{setspace}] The \textsf{setspace} package
582 % modifies the way line spacing is calculated in footnotes.
583 % \textsf{Footmisc} knows about this, and preserves the change.
584 % However, you \emph{must} load \textsf{setspace} \emph{before}
585 % \textsf{footmisc}.
586 % \item[\normalfont\textsf{memoir} class] The class emulates
587 % \textsf{setspace}, and we detect that emulation and deal with it
588 % in the same way as \textsf{setspace}.
589 %
590 % \iffalse FMi: this should now work!
591 % \item[\normalfont\textsf{hyperref}] The \textsf{hyperref} package
592 % has ambitions to make hyperlinks from footnote marks to the
593 % corresponding footnote body; naturally this causes grief to
594 % \textsf{footmisc}, and unfortunately no remedy is currently
595 % known. If you use \textsf{footmisc}, suppress hyperref's
596 % hyper-footnotes, by loading it as:\\
597 % \quad\verb|\usepackage[hyperfootnotes=false,...]{hyperref}|\\
598 % Further work on the interaction between the two packages is
599 % proposed, but not yet scheduled.
600 % \fi
601 %
602 % \item[\normalfont\textsf{manyfoot}] The \textsf{manyfoot} package
603 % permits several independent sequences of footnotes. Some
604 % preliminary work towards interworking with \textsf{footmisc} has
605 % been completed, but more remains to be done at the time of
606 % writing.
607 %
608 % \item[\normalfont\textsf{hyperref}] The \textsf{hyperref} package
609 % works together with \textsf{footmisc} (as proved by this
610 % documentation), but at this point in time not all options of
611 % \textsf{footmisc} can be used --- this will change over time.
612 % \end{description}
613 %
614 % \MaybeStop{\PrintIndex}
615 %
616 % \section{Code: Preliminaries}
617 %
618 % Well~--- here we go: let's make the package file:
619 %
620 % \begin{macrocode}
621 %<*package>
622 % \end{macrocode}
623 %
624 % Now declare what environment we need: version 6 needs a fairly recent \LaTeX.
625 % \begin{macrocode}
626 \NeedsTeXFormat{LaTeX2e}[2020/10/01]
627 % \end{macrocode}
628 %
629 % Version 7 makes use of the new sockets in the \LaTeX{} output
630 % routine, which are available starting with release 2025-06. So if
631 % this file runs with an earlier kernel, we use version 6 instead and
632 % the current file ends with the next line.
633 % \changes{v7.0a}{2025/03/10}{Make use of the new sockets in \LaTeX{} 2025-06-01}
634 % \changes{v7.0b}{2025/05/09}{Use \cs{IfFormatAtLeastTF} because
635 % \cs{IfFormatAtLeastF} was introduced only fairly recently (gh/20)}
636 % \begin{macrocode}
637 \IfFormatAtLeastTF{2025-06-01}{}{\input{footmisc-2022-02-14.sty}\endinput}
638 % \end{macrocode}
639 % The rest is the code for version 7.
640 %
641 % We need a token register in case we have to patch \cs{@makecol}:
642 % \begin{macrocode}
643 \newtoks\FN@temptoken
644 % \end{macrocode}
645 %
646 % \begin{macro}{\protected@writeaux}
647 % This command is defined for future compatibility with Matt Swift's
648 % \textsf{newclude} package (still, after all this time, not out of
649 % beta status).
650 % \begin{macrocode}
651 \providecommand\protected@writeaux{%
652 \protected@write\@auxout
653 }
654 % \end{macrocode}
655 % \end{macro}
656 %
657 % \begin{macro}{\l@advance@macro}
658 % \begin{macro}{\@@dvance@macro}
659 % \begin{macro}{\@advance@macro}
660 % We make the following (\cs{@@dvance@macro}) generalizable as follows
661 % (the global form isn't used in this package \dots\ yet):
662 %
663 % \begin{macrocode}
664 \def\l@advance@macro{\@@dvance@macro\edef}
665 \def\@@dvance@macro#1#2#3{\expandafter\@tempcnta#2\relax
666 \advance\@tempcnta#3\relax
667 #1#2{\the\@tempcnta}%
668 }
669 % \end{macrocode}
670 %
671 % Now we define a jolly little macro to advance a macro count (|#1|)
672 % by a given amount (|#2|).
673 % \begin{macrocode}
674 \let\@advance@macro\l@advance@macro
675 % \end{macrocode}
676 % \end{macro}
677 % \end{macro}
678 % \end{macro}
679 %
680 % \begin{macro}{\footnotemargin}
681 % Finally, we define the length used by the \texttt{marginal} option,
682 % and initialize it as if we've not had the option.
683 % \begin{macrocode}
684 \newdimen\footnotemargin
685 \footnotemargin1.8em\relax
686 % \end{macrocode}
687 % \end{macro}
688 %
689 % \section{Package options}
690 %
691 % Most of the code of the package is contained within the option
692 % processing, one way or another (that which isn't, is executed after
693 % \cs{ProcessOptions} as a result of flags set in the option
694 % processing).
695 %
696 % \subsection{The \texttt{symbol} option}
697 %
698 % This is a declaration that appears in the original \LaTeX{} book.
699 % Since it appeared in the old |pagefoots.sty| (presumably since it
700 % goes so naturally with the |perpage| option), I've added this
701 % trivial piece of customization to the package.
702 %
703 % \begin{macrocode}
704 \DeclareOption{symbol}{\renewcommand\thefootnote{\fnsymbol{footnote}}}
705 % \end{macrocode}
706 %
707 % \subsection{The \texttt{symbol*} option}
708 %
709 % The robust version of the \texttt{symbol} option: if the current
710 % `symbol' option doesn't provide enough variants, use arabic footnote
711 % number. We use a robust version of the ``extended ordinary'' symbol set,
712 % described later (in section~\ref{footnote-symbols}).
713 % \begin{macrocode}
714 \newif\ifFN@robust \FN@robustfalse
715 \DeclareOption{symbol*}{%
716 \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
717 \FN@robusttrue
718 \AtEndOfPackage{\setfnsymbol{lamport*-robust}}%
719 }
720 % \end{macrocode}
721 %
722 % \subsection{The \texttt{para} option}
723 %
724 % The basis of the code for this option comes from \TeX{}book, p.398
725 % ff.~(``Dirty Tricks''), though it does (of course) avoid
726 % redefining |\\| which has some other (somewhat significant) uses in
727 % \LaTeX{}! The user should be aware of
728 % Knuth's note on the limitations of this method of doing the job: the
729 % \TeX{} stack is used four times per footnote, and the stack is
730 % limited (see the \TeX{}book, p.300 ff.). If you have very large
731 % numbers of footnotes (in the hundreds), and encounter the error
732 % ``|! TeX capacity exceeded, sorry (... save size ...)|'', you may
733 % need to break your text into smaller sections and compile the
734 % separately. Fortunately (say the comments on the original
735 % |fnpara.sty|) this is very easy to do with \LaTeX{}, provided that
736 % you reset the footnote counter to make the joins seamless.
737 %
738 % \begin{macro}{\ifFN@para}
739 % Define the |para| option: now simply sets a marker for use later
740 % when defining the option's auxiliary code and when patching the
741 % output routine and so on.
742 % \begin{macrocode}
743 \newif\ifFN@para \FN@parafalse
744 \DeclareOption{para}{\ifFN@sidefn
745 \PackageError{footmisc}{Option "\CurrentOption" incompatible with
746 option "side"}%
747 {I shall ignore "\CurrentOption"}%
748 \else
749 \FN@paratrue
750 \fi
751 }
752 % \end{macrocode}
753 % \end{macro}
754 %
755 % \subsection{The \texttt{side} option}
756 %
757 % \begin{macro}{\ifFN@sidefn}
758 % Simply changes the behavior of \cs{@footnotetext}; incompatible
759 % with paragraph footnotes.
760 % \begin{macrocode}
761 \newif\ifFN@sidefn \FN@sidefnfalse
762 \DeclareOption{side}{\ifFN@para
763 \PackageError{footmisc}{Option "\CurrentOption" incompatible with
764 option "para"}%
765 {I shall ignore "\CurrentOption"}%
766 \else
767 \FN@sidefntrue
768 \fi
769 }
770 % \end{macrocode}
771 % \end{macro}
772 %
773 % \subsection{The \texttt{ragged} option}
774 %
775 % \begin{macro}{\footnotelayout}
776 % A very simple option that merely changes the definition of one
777 % macro. Note detection of the presence of the \textsf{ragged2e}
778 % package.
779 % \begin{macrocode}
780 \let\footnotelayout\@empty
781 \DeclareOption{ragged}{%
782 \@ifundefined{RaggedRight}%
783 {\renewcommand\footnotelayout{\linepenalty50 \raggedright}}%
784 {\renewcommand\footnotelayout{\linepenalty50 \RaggedRight}}%
785 }
786 % \end{macrocode}
787 % \end{macro}
788 %
789 % \subsection{The \texttt{perpage} option}
790 %
791 % \begin{macro}{\ifFN@perpage}
792 % A footnote-numbering modification: a new algorithm replacing one
793 % from Brian T. Schellenberger, which has proved to be flawed. We
794 % simply set a marker here, and define code later depending on the
795 % state of the marker (see section \ref{sec:perpage-code}).
796 % \begin{macrocode}
797 \newif\ifFN@perpage
798 \FN@perpagefalse
799 \DeclareOption{perpage}{%
800 \FN@perpagetrue
801 }
802 % \end{macrocode}
803 % \end{macro}
804 %
805 % \subsection{The \texttt{PPdebug} option}
806 %
807 % \begin{macro}{\ifFN@pp@debug}
808 % Sets a flag; the messages are generated in various places throughout
809 % the code. The option is not available in the package as
810 % distributed: modify the |.ins| file to generate a version of the
811 % package that includes the option, if you feel you need it.
812 % \begin{macrocode}
813 %<*PPdebug>
814 \newif\ifFN@pp@debug \FN@pp@debugfalse
815 \DeclareOption{PPdebug}{\FN@pp@debugtrue}
816 %</PPdebug>
817 % \end{macrocode}
818 % \end{macro}
819 %
820 %
821 % \subsection{Fixing the \LaTeX{} misbehavior with respect to spacing}
822 %
823 %
824 % \begin{macro}{\ifFN@fixskip}
825 % We maintain a boolean to decide if we want to fix that, by
826 % default we don't but if any placement option is given we apply the fix.
827 % \begin{macrocode}
828 \newif\ifFN@fixskip \FN@fixskipfalse
829 % \end{macrocode}
830 % \end{macro}
831 %
832 % \subsection{The footnote/float placement options}
833 %
834 % We have up to three blocks on a page (four if you count
835 % top-floats but they don't matter here). If there is any excess space that needs to be added the
836 % question is where that goes:
837 % \begin{enumerate}
838 % \item above footnotes and floats;
839 % \item between footnotes and floats;
840 % \item after footnotes and floats;
841 % \item nowhere in particular (everything is equally spaced out if
842 % \cs{flushbottom} is in force and close together otherwise).
843 % \end{enumerate}
844 % We handle that with a 3-way switch differenciating the different
845 % bottom cases: \texttt{bottom}, \texttt{bottomfloats} or neither of
846 % the two options. Within those with split the coding based on whether
847 % or not \texttt{abovefloats} was given (explicitly or implicitly).
848
849 %
850 % \begin{macro}{\FN@bottomcases}
851 % We record in which case we want to be in
852 % \cs{FN@bottomcases}. The default is case 3 (no option).
853 % \begin{macrocode}
854 \let\FN@bottomcases\thr@@
855 % \end{macrocode}
856 % \end{macro}
857 %
858 %
859 % \subsubsection{The \texttt{abovefloats}, \texttt{belowfloats} options}
860 %
861 % \begin{macro}{\ifFN@abovefloats}
862 % All this needs to do is to set a flag to say that it should happen.
863 % \begin{macrocode}
864 \newif\ifFN@abovefloats \FN@abovefloatstrue
865 % \end{macrocode}
866 % \end{macro}
867 %
868 %
869 % \subsubsection{The \texttt{bottom} option}
870 %
871 % \begin{macro}{\ds@bottom}
872 % The \texttt{bottom} option implements case 1 and puts the footnotes
873 % by default below the floats.
874 % \begin{macrocode}
875 \DeclareOption{bottom}{%
876 \let\FN@bottomcases\@ne
877 \FN@abovefloatsfalse
878 % \end{macrocode}
879 % We also state that we want to fix \LaTeX{} space issue (as we do
880 % in all other options.
881 % \begin{macrocode}
882 \FN@fixskiptrue
883 }
884 % \end{macrocode}
885 % \end{macro}
886 %
887 %
888 % \subsubsection{The \texttt{bottomfloats} option}
889 %
890 % \begin{macro}{ds@bottomfloats}
891 % This option is for case 2. By default the footnotes are above
892 % (close to the text).
893 % \begin{macrocode}
894 \DeclareOption{bottomfloats}{%
895 \let\FN@bottomcases\tw@
896 \FN@abovefloatstrue \FN@fixskiptrue
897 }
898 % \end{macrocode}
899 % \end{macro}
900 %
901 % \begin{macro}{ds@abovefloats,ds@belowfloats}
902 % These options change the order and that's it. The important
903 % aspect is that they are declared after the last two, otherwise
904 % they can't overwrite them.
905 % \begin{macrocode}
906 \DeclareOption{abovefloats}{\FN@abovefloatstrue \FN@fixskiptrue}
907 \DeclareOption{belowfloats}{\FN@abovefloatsfalse \FN@fixskiptrue}
908 % \end{macrocode}
909 % \end{macro}
910 %
911 %
912 %
913 % \subsection{The \texttt{marginal} option}
914 %
915 % Again, the processing of the option is pretty trivial:
916 % \begin{macrocode}
917 \DeclareOption{marginal}{%
918 \footnotemargin-0.8em\relax
919 }
920 % \end{macrocode}
921 %
922 % \subsection{The \texttt{flushmargin} option}
923 %
924 % Again, the processing of the option is pretty trivial:
925 % \begin{macrocode}
926 \DeclareOption{flushmargin}{%
927 \footnotemargin0pt\relax
928 }
929 % \end{macrocode}
930 %
931 % \subsection{The \texttt{hang} option}
932 %
933 % \begin{macro}{\ifFN@hangfoot}
934 % We need a switch, since \cs{@makefntext} needs to be patched.
935 % \begin{macrocode}
936 \newif\ifFN@hangfoot \FN@hangfootfalse
937 \DeclareOption{hang}{%
938 \FN@hangfoottrue
939 }
940 % \end{macrocode}
941 % \end{macro}
942 %
943 % \begin{macro}{\hangfootparskip}
944 % \begin{macro}{\hangfootparindent}
945 % Layout parameters for hanging footnotes; \cs{hangfootparskip} and
946 % \cs{hangfootparindent} are (respectively) values to use for
947 % \cs{parskip} and \cs{parindent} when in hanging footnotes.
948 % \begin{macrocode}
949 \newcommand*\hangfootparskip{0.5\baselineskip}
950 \newcommand*\hangfootparindent{0em}%
951 % \end{macrocode}
952 % \end{macro}
953 % \end{macro}
954 %
955 % \subsection{The \texttt{norule} option}
956 %
957 % Pretty simple too\dots
958 %
959 % \begin{macrocode}
960 \DeclareOption{norule}{%
961 \renewcommand\footnoterule{}%
962 \advance\skip\footins 4\p@\@plus2\p@\relax
963 }
964 % \end{macrocode}
965 %
966 % \subsection{The \texttt{splitrule} option}
967 %
968 % \begin{macro}{\split@prev}
969 % This is from a posting by Donald Arseneau dated 13 November 1996.
970 % The code relies on the fact that \LaTeX{} only uses inserts for
971 % footnotes, so that if any insert is going to be split, it's going to
972 % be a footnote.
973 % \begin{macrocode}
974 \DeclareOption{splitrule}{%
975 \gdef\split@prev{0}
976 % \end{macrocode}
977 % \end{macro}
978 %
979 % \begin{macro}{\pagefootnoterule}
980 % \begin{macro}{\mpfootnoterule}
981 % \begin{macro}{\splitfootnoterule}
982 % Define defaults for the three footnote rules: note, we inherit the
983 % current state of \cs{footnoterule} for the two `regular' footnote
984 % defaults, and if we've been preceded by option \texttt{norule}, they
985 % will both become null\dots
986 % \begin{macrocode}
987 \let\pagefootnoterule\footnoterule
988 \let\mpfootnoterule\footnoterule
989 \def\splitfootnoterule{\kern-3\p@ \hrule \kern2.6\p@}
990 % \end{macrocode}
991 % \end{macro}
992 % \end{macro}
993 % \end{macro}
994 %
995 % Now redefine \cs{footnoterule} to distinguish the three situations.
996 % \begin{macrocode}
997 \def\footnoterule{\relax
998 \ifx \@listdepth\@mplistdepth
999 % \end{macrocode}
1000 %
1001 % In a minipage
1002 % \begin{macrocode}
1003 \mpfootnoterule
1004 \else
1005 \ifnum\split@prev=\z@
1006 % \end{macrocode}
1007 %
1008 % Normal footnote on a regular page
1009 % \begin{macrocode}
1010 \pagefootnoterule
1011 \else
1012 % \end{macrocode}
1013 %
1014 % Second part of a split footnote
1015 % \begin{macrocode}
1016 \splitfootnoterule
1017 \fi
1018 % \end{macrocode}
1019 %
1020 % Remember a split for next page
1021 % \begin{macrocode}
1022 \xdef\split@prev{\the\insertpenalties}%
1023 \fi
1024 }%
1025 }
1026 % \end{macrocode}
1027 %
1028 % \begin{macro}{\ifFN@stablefootnote}
1029 % \subsection{The \texttt{stable} option}
1030 %
1031 % Simply set a flag: the code of this gets executed at the very end of
1032 % the package.
1033 % \begin{macrocode}
1034 \newif\ifFN@stablefootnote \FN@stablefootnotefalse
1035 \DeclareOption{stable}{\FN@stablefootnotetrue}
1036 % \end{macrocode}
1037 % \end{macro}
1038 %
1039 % \subsection{The \texttt{multiple} option}
1040 %
1041 % \begin{macro}{\ifFN@multiplefootnote}
1042 % Again, simply set a flag, for code that gets executed at the very
1043 % very very end of the package.
1044 % \begin{macrocode}
1045 \newif\ifFN@multiplefootnote \FN@multiplefootnotefalse
1046 \DeclareOption{multiple}{\FN@multiplefootnotetrue}
1047 % \end{macrocode}
1048 % \end{macro}
1049 %
1050 % \subsection{The start of the endgame}
1051 %
1052 % Exercise the options that the user has requested\dots
1053 % \begin{macrocode}
1054 \ProcessOptions
1055 % \end{macrocode}
1056 %
1057 % \section{Interfacing with the output routine}
1058 %
1059 % \changes{v7.0a}{2025/03/10}{Make use of the new sockets in \LaTeX{} 2025-06-01}
1060 %
1061 % The different strategies for footnote placements in relationship to
1062 % floast are implemented using the socket
1063 % \texttt{build/column/outputbox}. This is done based on the flags set
1064 % in option processing.
1065 %
1066 % We also have to handle \LaTeX's bottom skip bug and the handling of
1067 % paragraph footnotes if requested.
1068 %
1069 % \subsection{Handling paragraph footnotes}
1070 %
1071 % If the \texttt{para} option is given we implement that by providing
1072 % a plug for the socket \texttt{build/column/footnotes}.
1073 % \begin{macrocode}
1074 \ifFN@para
1075 \NewSocketPlug{build/column/footnotes}{para}{%
1076 \global\setbox\footins\vbox{\FN@makefootnoteparagraph}%
1077 }
1078 \AssignSocketPlug{build/column/footnotes}{para}
1079 \fi
1080 % \end{macrocode}
1081 %
1082 % \subsection{Not fixing the \LaTeX{} bottom skip bug}
1083 %
1084 % If we don't want to fix \LaTeX's bottom skip bug (for compatibility with
1085 % old documents) we do this by simply making two commands do nothing:
1086 % \begin{macrocode}
1087 \ifFN@fixskip \else
1088 \let\@outputbox@removebskip \relax
1089 \let\@outputbox@reinsertbskip\relax
1090 \fi
1091 % \end{macrocode}
1092 %
1093 %
1094 %
1095 % \subsection{The configuration of the \texttt{build/column/outputbox}
1096 % socket based on options}
1097 %
1098 %
1099 % Placement of footnotes in relation to main galley and floats is
1100 % covered by the value of \cs{FN@bottomcases} (type of bottom option)
1101 % and the status of the switch \texttt{@abovefloats}. Depending on
1102 % their settings we assign different plugs (already defined in
1103 % \LaTeX{}) to the socket \texttt{build/column/outputbox}.
1104 %
1105 % \changes{v7.0a}{2025/03/10}{Make use of the new sockets in \LaTeX{} 2025-06-01}
1106 % \begin{macrocode}
1107 \ifcase \FN@bottomcases\relax
1108 %---------------------------------------------------------
1109 % 0 = undefined
1110 %---------------------------------------------------------
1111 \ERROR
1112 \or
1113 %---------------------------------------------------------
1114 % 1 = bottom option given
1115 %---------------------------------------------------------
1116 % \end{macrocode}
1117 % All excess space are above the footnote and bottom float
1118 % blocks. The order of the blocks depend on \texttt{@abovefloats}:
1119 % \begin{macrocode}
1120 \ifFN@abovefloats
1121 %---------------------------------------------------------
1122 % \end{macrocode}
1123 % If footnotes above floats then both are at the bottom:
1124 % \begin{macrocode}
1125 \AssignSocketPlug {build/column/outputbox}{space-footnotes-floats}
1126 %---------------------------------------------------------
1127 \else
1128 % \end{macrocode}
1129 % Otherwise only the footnotes are at the very bottom and floats
1130 % stay close to the text:
1131 % \begin{macrocode}
1132 \AssignSocketPlug {build/column/outputbox}{floats-space-footnotes}
1133 \fi
1134 \or
1135 %---------------------------------------------------------
1136 % 2 = bottomfloats option given
1137 %---------------------------------------------------------
1138 \ifFN@abovefloats
1139 %---------------------------------------------------------
1140 % \end{macrocode}
1141 % Footnotes first then space then floats at bottom:
1142 % \begin{macrocode}
1143 \AssignSocketPlug {build/column/outputbox}{footnotes-space-floats}
1144 %---------------------------------------------------------
1145 \else
1146 % \end{macrocode}
1147 % If \texttt{belowfloats} was given too, then the excess space ends
1148 % up directly below the text
1149 % \begin{macrocode}
1150 \AssignSocketPlug {build/column/outputbox}{space-floats-footnotes}
1151 %---------------------------------------------------------
1152 \fi
1153 \or
1154 %---------------------------------------------------------
1155 % 3 = neither bottom nor bottomfloats given
1156 %---------------------------------------------------------
1157 % \end{macrocode}
1158 % In this case any excess space distribution is handled by
1159 % \cs{raggedbottom} or \cs{flushbottom} settings. In case of
1160 % \cs{raggedbottom} it goes to the bottom but we don't append
1161 % \cs{vfill} there. Instead we make use of the fact that
1162 % \cs{raggedbottom} already puts a stretchable space there, and if
1163 % we are in a \cs{flushbottom} scenario then any excess space is
1164 % supposed to be distributed across the whole page.
1165 % \begin{macrocode}
1166 \ifFN@abovefloats
1167 %---------------------------------------------------------
1168 \AssignSocketPlug {build/column/outputbox}{footnotes-floats}
1169 \else
1170 %---------------------------------------------------------
1171 % \end{macrocode}
1172 % Same thing but with blocks swapped.
1173 % \begin{macrocode}
1174 \AssignSocketPlug {build/column/outputbox}{floats-footnotes}
1175 %---------------------------------------------------------
1176 \fi
1177 \else
1178 %---------------------------------------------------------
1179 % 3 > undefined
1180 %---------------------------------------------------------
1181 % \end{macrocode}
1182 % The \cs{ERROR} here and above should never execute, like ``This
1183 % can't happen'' in the \TeX{} program code. If they execute then code
1184 % is badly broken.
1185 % \begin{macrocode}
1186 \ERROR
1187 \fi
1188
1189 % \end{macrocode}
1190 %
1191 %
1192 % \subsection{The requirements of \cs{@footnotetext}}
1193 %
1194 % Instead of (re)defining \cs{@footnotetext} we define
1195 % \cs{FN@footnotetext} and at the end we check what we do with it,
1196 % depending on whether or not \texttt{hyperref} was loaded.
1197 %
1198 % \begin{macro}{\ifFN@baselinestretch}
1199 % \begin{macro}{\FN@singlespace}
1200 % Whatever we do, we are going to patch \cs{@footnotetext}; so first
1201 % of all, we'll check it's not been hacked by anyone other than
1202 % \texttt{setspace.sty} (while we're at it we also record whether
1203 % \texttt{setspace} is loaded).
1204 % so we do this here:
1205 % \begin{macrocode}
1206 \newif\ifFN@setspace
1207 \@ifpackageloaded{setspace}%
1208 {%
1209 \FN@setspacetrue
1210 \@ifclassloaded{memoir}%
1211 % \end{macrocode}
1212 % We're seeing \textsf{memoir}'s emulation of \textsf{setspace}
1213 % \begin{macrocode}
1214 {%
1215 \let\FN@baselinestretch\m@m@singlespace
1216 }%
1217 % \end{macrocode}
1218 % We're seeing \textsf{setspace} in its own right
1219 % \begin{macrocode}
1220 {%
1221 \let\FN@baselinestretch\setspace@singlespace
1222 }%
1223 }%
1224 {%
1225 \FN@setspacefalse
1226 }
1227 % \end{macrocode}
1228 % \end{macro}
1229 % \end{macro}
1230 %
1231 % There's substantial patching to be done if we're doing paragraph
1232 % footnotes:
1233 % \begin{macrocode}
1234 \ifFN@para
1235 \long\def\FN@footnotetext#1{%
1236 \insert\footins{%
1237 % \end{macrocode}
1238 % insert compatibility code with |setspace.sty| if necessary
1239 % \begin{macrocode}
1240 \ifFN@setspace
1241 \let\baselinestretch\FN@baselinestretch
1242 \fi
1243 \reset@font\footnotesize
1244 \interlinepenalty\interfootnotelinepenalty
1245 \splittopskip\footnotesep
1246 \splitmaxdepth \dp\strutbox
1247 \floatingpenalty\@MM
1248 \hsize\columnwidth
1249 \@parboxrestore
1250 % \end{macrocode}
1251 % \changes{v6.0g}{2024/12/24}{Add \cs{@currentcounter} added to \LaTeX{} a while back (gh/15)}
1252 % \begin{macrocode}
1253 \def\@currentcounter{footnote}%
1254 \protected@edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
1255 \color@begingroup
1256 % \end{macrocode}
1257 %
1258 % We set the paragraph in an \cs{hbox} and apply the fudge factor
1259 % here (these days done with e\TeX{} methods):
1260 %
1261 % \begin{macrocode}
1262 \setbox\FN@tempboxa\hbox{%
1263 % \end{macrocode}
1264 %
1265 % This needs a parameter; the rule should be moved to the beginning of
1266 % the footnote paragraph, but the \cs{ignorespaces} should be left
1267 % here.
1268 %
1269 % \begin{macrocode}
1270 \@makefntext{\ignorespaces#1\strut
1271 % \end{macrocode}
1272 %
1273 % We insert a penalty here to help line breaking in the
1274 % footnote paragraph; the value is taken from the \TeX{}book.
1275 %
1276 % \begin{macrocode}
1277 \penalty-10\relax
1278 \hskip\footglue
1279 }% end of \@makefntext parameter
1280 }% end of \hbox
1281 \dp\FN@tempboxa\z@
1282 \ht\FN@tempboxa\dimexpr\wd\FN@tempboxa *%
1283 \footnotebaselineskip / \columnwidth\relax
1284 \box\FN@tempboxa
1285 \color@endgroup
1286 }%
1287 \FN@mf@prepare
1288 }
1289 % \end{macrocode}
1290 %
1291 % If we're not doing paragraph footnotes, we now simply tag a
1292 % \cs{FN@mf@prepare} command on the end of the definition; of course,
1293 % there are different definitions according as whether we're using
1294 % |side| footnotes\dots
1295 % \begin{macrocode}
1296 \else
1297 \ifFN@sidefn
1298 \long\def\FN@footnotetext#1{%
1299 \marginpar{%
1300 % \end{macrocode}
1301 % insert compatibility code with |setspace.sty| if necessary
1302 % \begin{macrocode}
1303 \ifFN@setspace
1304 \let\baselinestretch\FN@baselinestretch
1305 \fi
1306 \reset@font\footnotesize
1307 % \end{macrocode}
1308 % \changes{v6.0g}{2024/12/24}{Add \cs{@currentcounter} added to \LaTeX{} a while back (gh/15)}
1309 % \begin{macrocode}
1310 \def\@currentcounter{footnote}%
1311 \protected@edef\@currentlabel{%
1312 \csname p@footnote\endcsname\@thefnmark
1313 }%
1314 \color@begingroup
1315 \@makefntext{%
1316 \ignorespaces#1%
1317 }%
1318 \color@endgroup
1319 }%
1320 \FN@mf@prepare
1321 }%
1322 \else
1323 \long\def\FN@footnotetext#1{%
1324 \insert\footins{%
1325 % \end{macrocode}
1326 % insert compatibility code with \textsf{setspace} if necessary
1327 % \begin{macrocode}
1328 \ifFN@setspace
1329 \let\baselinestretch\FN@baselinestretch
1330 \fi
1331 \reset@font\footnotesize
1332 \interlinepenalty\interfootnotelinepenalty
1333 \splittopskip\footnotesep
1334 \splitmaxdepth \dp\strutbox
1335 \floatingpenalty\@MM
1336 \hsize\columnwidth
1337 \@parboxrestore
1338 % \end{macrocode}
1339 % \changes{v6.0g}{2024/12/24}{Add \cs{@currentcounter} added to \LaTeX{} a while back (gh/15)}
1340 % \begin{macrocode}
1341 \def\@currentcounter{footnote}%
1342 \protected@edef\@currentlabel{%
1343 \csname p@footnote\endcsname\@thefnmark
1344 }%
1345 \color@begingroup
1346 \@makefntext{%
1347 \rule\z@\footnotesep
1348 \ignorespaces#1\@finalstrut\strutbox
1349 }%
1350 \color@endgroup
1351 }%
1352 \FN@mf@prepare
1353 }%
1354 \fi
1355 \fi
1356 % \end{macrocode}
1357 %
1358 %
1359 %
1360 %
1361 %
1362 % \subsection{Support code for paragraph footnotes}
1363 %
1364 % This code used (most inefficiently) to be in the argument of the
1365 % \cs{DeclareOption}; this no doubt comes of that code having been
1366 % written over Christmas 1993\dots
1367 %
1368 % Now all executed under the |para| conditional set in the option
1369 % declaration.
1370 % \begin{macrocode}
1371 \ifFN@para
1372 % \end{macrocode}
1373 %
1374 % \begin{macro}{\FN@tempboxa}
1375 % \begin{macro}{\FN@tempboxb}
1376 % \begin{macro}{\FN@tempboxb}
1377 % We need some temporary boxes, and \LaTeX{} only defines one
1378 % \begin{macrocode}
1379 \let\FN@tempboxa\@tempboxa
1380 \newbox\FN@tempboxb
1381 \newbox\FN@tempboxc
1382 % \end{macrocode}
1383 % \end{macro}
1384 % \end{macro}
1385 % \end{macro}
1386 %
1387 % \begin{macro}{\footglue}
1388 % A direct crib from the \TeX{}book:
1389 % \begin{macrocode}
1390 \newskip\footglue \footglue=1em plus.3em minus.3em
1391 % \end{macrocode}
1392 % \end{macro}
1393 %
1394 % \begin{macro}{\@makefntext}
1395 % The standard classes set the footnote mark flush with the text of
1396 % the footnote, but that's not appropriate for paragraph footnotes, we
1397 % find.
1398 %
1399 % There's not much point in patching this code from the original,
1400 % since the only things it has in common with the original are the
1401 % footnote mark and the footnote text (which last is the argument).
1402 % Note that the \cs{leavevmode} isn't necessary except in the case of
1403 % footnotes in minipages, which otherwise end up with the
1404 % \cs{@makefnmark} being executed in restricted vertical mode, which
1405 % results in its \cs{hbox} ending up in a line of its own.
1406 %
1407 % \begin{macrocode}
1408 \long\def\@makefntext#1{\leavevmode
1409 \@makefnmark\nobreak
1410 \hskip.5em\relax#1%
1411 }
1412 % \end{macrocode}
1413 % \end{macro}
1414 %
1415 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1416 %
1417 % \begin{macro}{\footnotebaselineskip}
1418 % We need to record a value for the baseline skip when in footnotes:
1419 % \begin{macrocode}
1420 \newdimen\footnotebaselineskip
1421 {%
1422 \footnotesize
1423 \global
1424 \footnotebaselineskip=\normalbaselineskip
1425 }
1426 % \end{macrocode}
1427 % \end{macro}
1428 %
1429 %
1430
1431 % \begin{macro}{\FN@makefootnoteparagraph}
1432 % For use in the output routine
1433 % \begin{macrocode}
1434 \long\def\FN@makefootnoteparagraph{\unvbox\footins \FN@makehboxofhboxes
1435 \setbox\FN@tempboxa=\hbox{\unhbox\FN@tempboxa \FN@removehboxes}%
1436 % \end{macrocode}
1437 % Now we are ready to set the paragraph:
1438 % \begin{macrocode}
1439 \FN@setfootnoteparawidth
1440 \@parboxrestore
1441 \baselineskip=\footnotebaselineskip
1442 \noindent
1443 \rule{\z@}{\footnotesep}%
1444 \unhbox\FN@tempboxa\par
1445 }
1446 % \end{macrocode}
1447 % \end{macro}
1448 %
1449 % \begin{macro}{\FN@makehboxofhboxes}
1450 % \begin{macro}{\FN@removehboxes}
1451 % Support code for \cs{FN@makefootnoteparagraph}
1452 % \begin{macrocode}
1453 \def\FN@makehboxofhboxes{\setbox\FN@tempboxa=\hbox{}%
1454 \loop
1455 \setbox\FN@tempboxb=\lastbox
1456 \ifhbox\FN@tempboxb
1457 \setbox\FN@tempboxa=\hbox{\box\FN@tempboxb\unhbox\FN@tempboxa}%
1458 \repeat
1459 }
1460 \def\FN@removehboxes{\setbox\FN@tempboxa=\lastbox
1461 \ifhbox
1462 \FN@tempboxa{\FN@removehboxes}%
1463 \unhbox\FN@tempboxa
1464 \fi
1465 }
1466 \fi
1467 % \end{macrocode}
1468 % \end{macro}
1469 % \end{macro}
1470 %
1471 %
1472 %
1473 %
1474 %
1475 % \begin{macro}{\FN@setfootnoteparawidth}
1476 % What we have to use as the width for the footnote paragraph
1477 % depends on whether or not we typeset in several columns. If single
1478 % column or normal two-column is used then the right value is
1479 % \cs{columnwidth}. However, inside a \texttt{multicols} environment
1480 % we need to use \cs{textwidth} as the footnotes there will span
1481 % across all columns.
1482 %
1483 % To detect if we are inside such an environment we look at
1484 % \cs{doublecolnumber} which is only positive if inside such an
1485 % environment.
1486 % \begin{macrocode}
1487 \@ifpackageloaded{multicol}
1488 {\def\FN@setfootnoteparawidth
1489 {\hsize\ifnum\doublecol@number>\@ne
1490 \textwidth
1491 \else \columnwidth \fi}}
1492 {\def\FN@setfootnoteparawidth{\hsize\columnwidth}}
1493 % \end{macrocode}
1494 % \end{macro}
1495 %
1496 %
1497 %
1498 %
1499 %
1500 % \subsection{The other footnote commands}\label{sec:perpage-code}
1501 %
1502 %
1503 % We delegate the perpage option to a different package \ldots
1504 % \begin{macrocode}
1505 \ifFN@perpage
1506 \RequirePackage{perpage}
1507 \MakePerPage{footnote}
1508 % \end{macrocode}
1509 % Unfortunately \pkg{perpage} has a bug and doesn't handle founters
1510 % correctly which are part of a reset list of another counter,
1511 % e.g., it doesn't work correctly if you use the report class which
1512 % resets footnotes at each chapter start. As a result the first
1513 % footnote on the first page of a chapter starts with 2. We
1514 % therefore alter one \LaTeX{} internal if \pkg{perpage} is in use:
1515 % \changes{v6.0c}{2022/03/07}{Fix an issue in perpage package (gh/03)}
1516 % \changes{v6.0d}{2022/03/07}{Also support optional arg of \cs{MakePerPage} (gh/03)}
1517 % \begin{macrocode}
1518 \def\@stpelt#1{\global\csname c@#1\endcsname \m@ne
1519 \stepcounter{#1}%
1520 \pp@fix@MakePerPage{#1}%
1521 }
1522 \def\pp@fix@MakePerPage#1{%
1523 \ifnum \value{#1}>\z@
1524 \addtocounter{#1}\m@ne\fi
1525 }
1526 % \end{macrocode}
1527 % The above code may look a bit odd: the \cs{stepcounter} sets the
1528 % counter to zero and then we alter it if it is not zero. The
1529 % reason is that \cs{stepcounter} resets other counters and when
1530 % perpage is loaded this results in updating counters on the reset
1531 % list to 1 (or to a higher starting value if \cs{MakePerPage} is
1532 % used with an optional argument, which is precisely the problem
1533 % here. By subtracting 1 in that case we set it back to 1 lower
1534 % than the starting value.
1535 %
1536 % But to make this fully work we also need to update a support
1537 % command in \pkg{perpage}:
1538 % \begin{macrocode}
1539 \def\pp@cl@end@iii\stepcounter#1\pp@fix@MakePerPage#2{}
1540 % \end{macrocode}
1541 %
1542 % \begin{macrocode}
1543 \fi
1544 % \end{macrocode}
1545 %
1546 % Finally, if we're not doing paragraph footnotes, we redefine
1547 % \cs{@makefntext} to take account of the value of
1548 % \cs{footnotemargin}, to impose \cs{footnotelayout}, and to make the
1549 % footnote body text hang, if appropriate.
1550 % \begin{macrocode}
1551 \ifFN@para
1552 \else
1553 % \end{macrocode}
1554 %
1555 % hanging footnote version:
1556 % \begin{macrocode}
1557 \long\def\@makefntext#1{%
1558 \ifFN@hangfoot
1559 \bgroup
1560 % \end{macrocode}
1561 %
1562 % get the marker so we can measure it:
1563 % \begin{macrocode}
1564 \setbox\@tempboxa\hbox{%
1565 \ifdim\footnotemargin>0pt
1566 \hb@xt@\footnotemargin{\@makefnmark\hss}%
1567 \else
1568 \@makefnmark
1569 \fi
1570 }%
1571 % \end{macrocode}
1572 %
1573 % use the width of the box to set up hanging (potentially for more
1574 % than one paragraph); note that the hanging \cs{parskip} and
1575 % \cs{parindent} are set \emph{after} we've executed \cs{leavevmode}(!)
1576 % \begin{macrocode}
1577 \leftmargin\wd\@tempboxa
1578 \rightmargin\z@
1579 \linewidth \columnwidth
1580 \advance \linewidth -\leftmargin
1581 \parshape \@ne \leftmargin \linewidth
1582 % \end{macrocode}
1583 % We also update \cs{@totalleftmargin} so that display
1584 % environments, such as \texttt{quote} if used inside the footnote
1585 % know about the hanging indentation (otherwise something like
1586 % \texttt{quote} isn't centered in the available space):
1587 % \changes{v6.0f}{2023/07/05}{Account for indentation due to hang option (gh/11)}
1588 % \begin{macrocode}
1589 \@totalleftmargin \leftmargin
1590 \footnotesize
1591 % \end{macrocode}
1592 %
1593 % stop the \cs{parshape} being overwritten:
1594 % \begin{macrocode}
1595 \@setpar{{\@@par}}%
1596 % \end{macrocode}
1597 %
1598 % and finally put the marker in its chosen place:
1599 % \begin{macrocode}
1600 \leavevmode
1601 \llap{\box\@tempboxa}%
1602 \parskip\hangfootparskip\relax
1603 \parindent\hangfootparindent\relax
1604 \else
1605 % \end{macrocode}
1606 %
1607 % ordinary (non-hanging) footnote version:
1608 % \begin{macrocode}
1609 \parindent1em
1610 \noindent
1611 \ifdim\footnotemargin>\z@
1612 \hb@xt@ \footnotemargin{\hss\@makefnmark}%
1613 \else
1614 \ifdim\footnotemargin=\z@
1615 \llap{\@makefnmark}%
1616 \else
1617 \llap{\hb@xt@ -\footnotemargin{\@makefnmark\hss}}%
1618 \fi
1619 \fi
1620 \fi
1621 \footnotelayout#1%
1622 % \end{macrocode}
1623 %
1624 % if we're hanging, close the hang group
1625 % \begin{macrocode}
1626 \ifFN@hangfoot
1627 \par\egroup
1628 \fi
1629 }
1630 \fi
1631 % \end{macrocode}
1632 %
1633 % \section{Remaining requirements}
1634 %
1635 % We have to insert the code that executes the \texttt{stable} and
1636 % \texttt{multiple} options. Since \texttt{stable} may suppress the
1637 % setting of a footnote altogether, we put the \texttt{multiple}
1638 % option first, as otherwise we might get isolated superscripted
1639 % commas that separate footnotes that have otherwise been suppressed.
1640 %
1641 % \subsection{The code that executes the \texttt{multiple} option}
1642 %
1643 % \begin{macro}{\multiplefootnotemarker}
1644 % \begin{macro}{\multfootsep}
1645 % \begin{macro}{\FN@footnotemark}
1646 % \begin{macro}{\FN@mf@prepare}
1647 % \begin{macro}{\FN@mf@check}
1648 % This (revised) code derives from a suggestion by Alexander Rozhenko
1649 % (the author of the \textit{manyfoot} package): the intention is that
1650 % \textit{footmisc} and \textit{manyfoot} should be able to
1651 % `interwork', in the sense that each would recognize the other's
1652 % footnote marks and behave appropriately. The trick is that
1653 % both \cs{footnote} and \cs{footnotemark} insert a marker (a
1654 % cancelling pair of kerns of \cs{multiplefootnotemarker} (of opposite
1655 % signs), which is detected in following \cs{footnote} or
1656 % \cs{footnotemark} commands. Note we have to take special
1657 % precautions to ensure that the kerns are the last things added to
1658 % the horizontal list by the commands.
1659 % \begin{macrocode}
1660 \ifFN@multiplefootnote
1661 \providecommand*{\multiplefootnotemarker}{3sp}
1662 \providecommand*{\multfootsep}{,}
1663 %
1664 % FMi: not checking, more harm than gain
1665 % \CheckCommand*\@footnotemark{%
1666 % \leavevmode
1667 % \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
1668 % \@makefnmark
1669 % \ifhmode\spacefactor\@x@sf\fi
1670 % \relax
1671 % }
1672 %
1673 \newcommand*\FN@footnotemark{%
1674 \leavevmode
1675 \ifhmode
1676 \edef\@x@sf{\the\spacefactor}%
1677 \FN@mf@check
1678 \nobreak
1679 \fi
1680 \@makefnmark
1681 \FN@mf@prepare
1682 \ifhmode\spacefactor\@x@sf\fi
1683 \relax
1684 }
1685 \def\FN@mf@prepare{%
1686 \kern-\multiplefootnotemarker
1687 \kern\multiplefootnotemarker\relax
1688 }
1689 \def\FN@mf@check{%
1690 \ifdim\lastkern=\multiplefootnotemarker\relax
1691 \edef\@x@sf{\the\spacefactor}%
1692 \unkern
1693 \textsuperscript{\multfootsep}%
1694 \spacefactor\@x@sf\relax
1695 \fi
1696 }
1697 % \end{macrocode}
1698 %
1699 % If we're not doing multiple, just create an empty \cs{FN@mf@prepare}
1700 % \begin{macrocode}
1701 \else
1702 \let\FN@mf@prepare\relax
1703 % \end{macrocode}
1704 % Need to provide a definition for \cs{FN@footnotemark} in that case.
1705 % \begin{macrocode}
1706 \let\FN@footnotemark\@footnotemark
1707 \fi
1708 % \end{macrocode}
1709 % \end{macro}
1710 % \end{macro}
1711 % \end{macro}
1712 % \end{macro}
1713 % \end{macro}
1714 %
1715 % \subsection{The code that executes the \texttt{stable} option}
1716 %
1717 % \begin{macro}{\ifFN@stablefootnote}
1718 % \begin{macro}{\FN@sf@@footnote}
1719 % The basic idea is to use the `original' code of \cs{footnote} (which
1720 % this package may have hacked around something chronic) only if we're
1721 % in typesetting mode (as determined by the state of the \cs{protect}
1722 % command. Otherwise, the command becomes an elaborate multistage
1723 % `gobble'.
1724 % \begin{macrocode}
1725 \ifFN@stablefootnote
1726 \let\FN@sf@@footnote\footnote
1727 \def\footnote{\ifx\protect\@typeset@protect
1728 \expandafter\FN@sf@@footnote
1729 \else
1730 \expandafter\FN@sf@gobble@opt
1731 \fi
1732 }
1733 % \end{macrocode}
1734 % \end{macro}
1735 % \end{macro}
1736 %
1737 % \begin{macro}{\FN@sf@gobble@opt}
1738 % \begin{macro}{\FN@sf@gobble@twobracket}
1739 % Define \cs{FN@sf@gobble@opt} as a robust command that gobbles either
1740 % an optional and a mandatory argument, or just a mandatory one.
1741 % \begin{macrocode}
1742 \edef\FN@sf@gobble@opt{\noexpand\protect
1743 \expandafter\noexpand\csname FN@sf@gobble@opt \endcsname}
1744 \expandafter\def\csname FN@sf@gobble@opt \endcsname{%
1745 \@ifnextchar[%]
1746 \FN@sf@gobble@twobracket
1747 \@gobble
1748 }
1749 \def\FN@sf@gobble@twobracket[#1]#2{}
1750 % \end{macrocode}
1751 % \end{macro}
1752 % \end{macro}
1753 %
1754 % \begin{macro}{\FN@sf@@footnotemark}
1755 % \begin{macro}{\FN@sf@gobble@optonly}
1756 % \begin{macro}{\FN@sf@gobble@bracket}
1757 % Now the same for \cs{footnotemark}
1758 % \begin{macrocode}
1759 \let\FN@sf@@footnotemark\footnotemark
1760 \def\footnotemark{\ifx\protect\@typeset@protect
1761 \expandafter\FN@sf@@footnotemark
1762 \else
1763 \expandafter\FN@sf@gobble@optonly
1764 \fi
1765 }
1766 \edef\FN@sf@gobble@optonly{\noexpand\protect
1767 \expandafter\noexpand\csname FN@sf@gobble@optonly \endcsname}
1768 \expandafter\def\csname FN@sf@gobble@optonly \endcsname{%
1769 \@ifnextchar[%]
1770 \FN@sf@gobble@bracket
1771 {}%
1772 }
1773 \def\FN@sf@gobble@bracket[#1]{}
1774 \fi
1775 % \end{macrocode}
1776 % \end{macro}
1777 % \end{macro}
1778 % \end{macro}
1779 %
1780 % \section{Symbol option variants}
1781 %
1782 % \begin{macro}{\setfnsymbol}
1783 % \begin{macro}{\FN@fnsymbol@lamport}
1784 % Lamport's choice of symbols for \cs{fnsymbol} wasn't entirely
1785 % ``traditional'', so we (now) provide alternatives. The
1786 % \cs{setfnsymbol} command offers a small number of choices, and the
1787 % user may define more still, using the \cs{DefineFNsymbols} or
1788 % \cs{DefineFNsymbolsTM} commands, defined below.
1789 % \begin{macrocode}
1790 \newcommand\setfnsymbol[1]{%
1791 \@bsphack
1792 \@ifundefined{FN@fnsymbol@#1}%
1793 {%
1794 \PackageError{footmisc}{Symbol style "#1" not known}%
1795 \@eha
1796 }{%
1797 \expandafter\let\expandafter\@fnsymbol\csname
1798 FN@fnsymbol@#1\endcsname
1799 }%
1800 \@esphack
1801 }
1802 % \end{macrocode}
1803 %
1804 % The default selection is Lamport's original, as represented in
1805 % current \LaTeX{}~--- we preserve it in case we need to ``get back''
1806 % to it.
1807 % \begin{macrocode}
1808 \let\FN@fnsymbol@lamport\@fnsymbol
1809 %</package>
1810 % \end{macrocode}
1811 % \end{macro}
1812 % \end{macro}
1813 %
1814 % \begin{macro}{\if@tempswb}
1815 % \begin{macro}{\@tempswbfalse}
1816 % \begin{macro}{\@tempswbtrue}
1817 % We need another temp conditional
1818 % \begin{macrocode}
1819 \newif\if@tempswb
1820 % \end{macrocode}
1821 % \end{macro}
1822 % \end{macro}
1823 % \end{macro}
1824 %
1825 % \begin{macro}{\DefineFNsymbols}
1826 % \begin{macro}{\@DefineFNsymbols}
1827 % \begin{macro}{\@DefineFNsymbols@}
1828 % \begin{macro}{\FN@build@symboldef}
1829 % The macro \cs{DefineFNsymbols} allows the user to define a set of
1830 % footnote symbols, to be used with the \cs{setfnsymbol} command.
1831 % Syntax:\par\noindent
1832 % \cs{DefineFNsymbols}|[*]|\marg{set name}\oarg{style}\marg{symbol list}
1833 %
1834 % If the optional asterisk is present, the set defined will produce an
1835 % error if the symbol number is too large; otherwise it will quietly
1836 % change to numbering in place of symbol use (a warning is produced at
1837 % the end of the document). The set name is the future argument of
1838 % \cs{setfnsymbol}). The style (default \texttt{text}) gives the style
1839 % the symbols are typeset (this is the \emph{correct} method, but
1840 % unfortunately not all symbols, even for Lamport's original set for
1841 % \LaTeX{} \cs{fnsymbol} may be expressed this way in a sufficiently
1842 % old \LaTeX{} distribution). The symbol list is a set of objects to
1843 % be used when the set is selected.
1844 %
1845 % Example of use:\par\noindent define a direct replacement for
1846 % Lamport's original \cs{fnsymbol} command ---
1847 %\begin{verbatim}
1848 %\DefineFNsymbols*{lamport}[math]{*\dagger\ddagger\mathsection
1849 % \mathparagraph\|{**}{\dagger\dagger}{\ddagger\ddagger}%
1850 %}
1851 %\end{verbatim}
1852 % Note that doubled-up (and worse\,---\,see below) symbols need braces
1853 % around them.
1854 % \begin{macrocode}
1855 \DeclareDocumentCommand\DefineFNsymbols {smO{text}m}{%
1856 \expandafter\ifx\csname FN@fnsymbol@#2\endcsname\relax
1857 \PackageInfo{footmisc}{Declaring symbol style #2}%
1858 \else
1859 \PackageWarning{footmisc}{Redeclaring symbol style #2}%
1860 \fi
1861 \toks@{}%
1862 \def\@tempb{\end}%
1863 \FN@build@symboldef#4\end
1864 \def\@tempc{math}%
1865 \def\@tempd{#3}%
1866 \expandafter\xdef\csname FN@fnsymbol@#2\endcsname##1{%
1867 \ifx\@tempc\@tempd
1868 \noexpand\ensuremath
1869 \else
1870 \noexpand\nfss@text
1871 \fi
1872 {%
1873 \noexpand\ifcase##1%
1874 \the\toks@
1875 \noexpand\else
1876 \IfBooleanTF#1{\noexpand\@ctrerr}%
1877 {\noexpand\FN@orange##1}%
1878 \noexpand\fi
1879 }%
1880 }%
1881 }
1882 % \end{macrocode}
1883 %
1884 % \begin{macrocode}
1885 \def\FN@build@symboldef#1{%
1886 \def\@tempa{#1}%
1887 \ifx\@tempa\@tempb
1888 \else
1889 \toks@\expandafter{\the\toks@\or#1}%
1890 \expandafter\FN@build@symboldef
1891 \fi
1892 }
1893 % \end{macrocode}
1894 % \end{macro}
1895 % \end{macro}
1896 % \end{macro}
1897 % \end{macro}
1898 %
1899 % \begin{macro}{\DefineFNsymbolsTM}
1900 % \begin{macro}{\@DefineFNsymbolsTM}
1901 % \begin{macro}{\FN@build@symboldefTM}
1902 %
1903 % Now do the same job for the ``modern'' way of having both text and
1904 % maths variants of everything.
1905 % \begin{macrocode}
1906 \DeclareDocumentCommand\DefineFNsymbolsTM {smm}{%
1907 \expandafter\ifx\csname FN@fnsymbol@#2\endcsname\relax
1908 \PackageInfo{footmisc}{Declaring symbol style #2}%
1909 \else
1910 \PackageWarning{footmisc}{Redeclaring symbol style #2}%
1911 \fi
1912 \toks@{}%
1913 \def\@tempb{\end}%
1914 \FN@build@symboldefTM#3\end\@null
1915 \expandafter\xdef\csname FN@fnsymbol@#2\endcsname##1{%
1916 \noexpand\ifcase##1%
1917 \the\toks@
1918 \noexpand\else
1919 \IfBooleanTF#1{\noexpand\@ctrerr}%
1920 {\noexpand\FN@orange##1}%
1921 \noexpand\fi
1922 }%
1923 }
1924 % \end{macrocode}
1925 % Note that this version has two variants of every definition, so
1926 % needs two stopper codes above.
1927 % \begin{macrocode}
1928 \def\FN@build@symboldefTM#1#2{%
1929 \def\@tempa{#1}%
1930 \ifx\@tempa\@tempb
1931 \else
1932 \toks@\expandafter{\the\toks@\or\TextOrMath{#1}{#2}}%
1933 \expandafter\FN@build@symboldefTM
1934 \fi
1935 }
1936 % \end{macrocode}
1937 % \end{macro}
1938 % \end{macro}
1939 % \end{macro}
1940 %
1941 %
1942 % \begin{macro}{\FN@orange}
1943 % \begin{macro}{\@fnsymbol@orange}
1944 % \begin{macro}{\@diagnose@fnsymbol@orange}
1945 % Macros to deal with footnote symbols going out of range (when
1946 % they're allowed to\,--\,e.g., in the \texttt{symbol*} option).
1947 % \begin{macrocode}
1948 \def\FN@orange#1{%
1949 \ifFN@robust
1950 \@arabic#1%
1951 \@bsphack
1952 \PackageInfo{footmisc}{Footnote number \number#1 out of range}%
1953 \protect\@fnsymbol@orange
1954 \@esphack
1955 \else \@ctrerr \fi
1956 }
1957 \global\let\@diagnose@fnsymbol@orange\relax
1958 \AtEndDocument{\@diagnose@fnsymbol@orange}
1959 \def\@fnsymbol@orange{%
1960 \gdef\@diagnose@fnsymbol@orange{%
1961 \PackageWarningNoLine{footmisc}{Some footnote number(s)
1962 were out of range
1963 \MessageBreak
1964 see log for details%
1965 }%
1966 }%
1967 }
1968 % \end{macrocode}
1969 % \end{macro}
1970 % \end{macro}
1971 % \end{macro}
1972 %
1973 %
1974 % \begin{macro}{\FN@fnsymbol@bringhurst}
1975 % \begin{macro}{\FN@fnsymbol@chicago}
1976 % \begin{macro}{\FN@fnsymbol@wiley}
1977 % \begin{macro}{\FN@fnsymbol@lamport-robust}
1978 % \begin{macro}{\FN@fnsymbol@lamport}
1979 % These macros provide replacement orderings (and symbol sets) for
1980 % footnote symbols, plus a robust version of the original Lamport set,
1981 % and an extended version of Lamport's original
1982 % \begin{macrocode}
1983 \DefineFNsymbolsTM{bringhurst}{%
1984 \textasteriskcentered *%
1985 \textdagger \dagger
1986 \textdaggerdbl \ddagger
1987 \textsection \mathsection
1988 \textbardbl \|%
1989 \textparagraph \mathparagraph
1990 }%
1991 \DefineFNsymbolsTM{chicago}{%
1992 \textasteriskcentered *%
1993 \textdagger \dagger
1994 \textdaggerdbl \ddagger
1995 \textsection \mathsection
1996 \textbardbl \|%
1997 \#\#%
1998 }%
1999 \DefineFNsymbolsTM{wiley}{%
2000 \textasteriskcentered *%
2001 {\textasteriskcentered\textasteriskcentered}{**}%
2002 \textdagger \dagger
2003 \textdaggerdbl \ddagger
2004 \textsection \mathsection
2005 \textparagraph \mathparagraph
2006 \textbardbl \|%
2007 }%
2008 \DefineFNsymbolsTM{lamport-robust}{%
2009 \textasteriskcentered *%
2010 \textdagger \dagger
2011 \textdaggerdbl \ddagger
2012 \textsection \mathsection
2013 \textparagraph \mathparagraph
2014 \textbardbl \|%
2015 {\textasteriskcentered\textasteriskcentered}{**}%
2016 {\textdagger\textdagger}{\dagger\dagger}%
2017 {\textdaggerdbl\textdaggerdbl}{\ddagger\ddagger}%
2018 }
2019 \DefineFNsymbolsTM*{lamport*}{%
2020 \textasteriskcentered *%
2021 \textdagger \dagger
2022 \textdaggerdbl \ddagger
2023 \textsection \mathsection
2024 \textparagraph \mathparagraph
2025 \textbardbl \|%
2026 {\textasteriskcentered\textasteriskcentered}{**}%
2027 {\textdagger\textdagger}{\dagger\dagger}%
2028 {\textdaggerdbl\textdaggerdbl}{\ddagger\ddagger}%
2029 {\textsection\textsection}{\mathsection\mathsection}%
2030 {\textparagraph\textparagraph}{\mathparagraph\mathparagraph}%
2031 {\textasteriskcentered\textasteriskcentered\textasteriskcentered}{***}%
2032 {\textdagger\textdagger\textdagger}{\dagger\dagger\dagger}%
2033 {\textdaggerdbl\textdaggerdbl\textdaggerdbl}{\ddagger\ddagger\ddagger}%
2034 {\textsection\textsection\textsection}%%
2035 {\mathsection\mathsection\mathsection}%
2036 {\textparagraph\textparagraph\textparagraph}%%
2037 {\mathparagraph\mathparagraph\mathparagraph}%
2038 }
2039 \setfnsymbol{lamport*}
2040 \DefineFNsymbolsTM{lamport*-robust}{%
2041 \textasteriskcentered *%
2042 \textdagger \dagger
2043 \textdaggerdbl \ddagger
2044 \textsection \mathsection
2045 \textparagraph \mathparagraph
2046 \textbardbl \|%
2047 {\textasteriskcentered\textasteriskcentered}{**}%
2048 {\textdagger\textdagger}{\dagger\dagger}%
2049 {\textdaggerdbl\textdaggerdbl}{\ddagger\ddagger}%
2050 {\textsection\textsection}{\mathsection\mathsection}%
2051 {\textparagraph\textparagraph}{\mathparagraph\mathparagraph}%
2052 {\textasteriskcentered\textasteriskcentered\textasteriskcentered}{***}%
2053 {\textdagger\textdagger\textdagger}{\dagger\dagger\dagger}%
2054 {\textdaggerdbl\textdaggerdbl\textdaggerdbl}{\ddagger\ddagger\ddagger}%
2055 {\textsection\textsection\textsection}%%
2056 {\mathsection\mathsection\mathsection}%
2057 {\textparagraph\textparagraph\textparagraph}%%
2058 {\mathparagraph\mathparagraph\mathparagraph}%
2059 }
2060 % \end{macrocode}
2061 % \end{macro}
2062 % \end{macro}
2063 % \end{macro}
2064 % \end{macro}
2065 % \end{macro}
2066 %
2067 % \section{Other miscellaneous commands}
2068 %
2069 %
2070 % \subsection{Minipage \cs{footnotemark}s}
2071 %
2072 % \begin{macro}{\mpfootnotemark}
2073 % Syntax: \cs{mpfootnotemark}\oarg{number}
2074 %
2075 % Here we define \cs{mpfootnotemark}, which has the same syntax as
2076 % \cs{footnotemark}, and which applies the semantics of
2077 % \cs{footnotemark} to the minipage footnote series.
2078 % \begin{macrocode}
2079 \newcommand\mpfootnotemark{%
2080 \@ifnextchar[%
2081 \@xmpfootnotemark
2082 {%
2083 \stepcounter\@mpfn
2084 \protected@xdef\@thefnmark{\thempfn}%
2085 \@footnotemark
2086 }%
2087 }
2088 \def\@xmpfootnotemark[#1]{%
2089 \begingroup
2090 \csname c@\@mpfn\endcsname #1\relax
2091 \unrestored@protected@xdef\@thefnmark{\thempfn}%
2092 \endgroup
2093 \@footnotemark
2094 }
2095 % \end{macrocode}
2096 % \end{macro}
2097 %
2098 %
2099 % If \textsf{hyperref} was loaded first, it has saved
2100 % \cs{@footnotetext} and \cs{@footnotemark} away and then redefined
2101 % them. The saved versions are now wrong, so we reassign them.
2102 % \begin{macrocode}
2103 \@ifpackageloaded{hyperref}{%
2104 \let\H@@footnotetext\FN@footnotetext
2105 \let\H@@footnotemark\FN@footnotemark
2106 }{%
2107 % \end{macrocode}
2108 % If \textsf{hyperref} wasn't loaded we copy our new definitions to
2109 % \cs{@footnotetext} and \cs{@footnotemark} for actual use. If
2110 % \textsf{hyperref} is loaded later it will do its magic and save
2111 % our definitions.
2112 % \begin{macrocode}
2113 \let \@footnotetext \FN@footnotetext
2114 \let\@footnotemark \FN@footnotemark
2115 }
2116 % \end{macrocode}
2117 %
2118 %
2119 % This is only needed until the first aid is in \LaTeX{} or the
2120 % package is fixed.
2121 % \begin{macrocode}
2122 \AddToHook{file/marginfix.sty/after}[footmisc]{%
2123 \FirstAidNeededT{marginfix}{sty}%
2124 {2020/05/06 v1.2 Fix Margin Paragraphs}%
2125 {\let \@outputbox@attachfloats \@combinefloats}%
2126 }
2127 \DeclareHookRule{file/marginfix.sty/after}{firstaid}{voids}{footmisc}
2128 % \end{macrocode}
2129 %
2130 %
2131 %
2132 % \begin{macrocode}
2133 \endinput
2134 %</package>
2135 % \end{macrocode}
2136 %
2137 % \Finale
2138 %