Footmisc Code
Footmisc Code
a portmanteau package
for customizing footnotes in LATEX∗
Robin Fairbairns† Frank Mittelbach‡
December 24, 2024
Copyright statement
Program: footmisc.dtx
Copyright 1995–2011 Robin Fairbairns
Copyright 2018–2023 Robin Fairbairns, Frank Mittelbach
This program is offered under the terms 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 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’.
Contents
1 User interface — package options 3
1.1 Option perpage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Option para . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Option side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Option ragged and \footnotelayout . . . . . . . . . . . . . . . . 4
1.5 Option symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.6 Option symbol* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.7 The \setfnsymbol and \DefineFNsymbols commands . . . . . . . 5
1.8 Options altering the footnotes/floats relationship . . . . . . . . . . 5
1.8.1 Option bottom . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.8.2 Option bottomfloats . . . . . . . . . . . . . . . . . . . . . 6
1.8.3 Options abovefloats and belowfloats . . . . . . . . . . . 6
1.8.4 Combining the four options . . . . . . . . . . . . . . . . . . 6
1.8.5 Fixing a strange behavior of LATEX . . . . . . . . . . . . . . 7
1.9 Option marginal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.10 Option flushmargin . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.11 Option hang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
∗ Thisfile has version number v6.0g, last revised 2024/12/24
† Formerly: University of Cambridge Computer Laboratory, Cambridge, UK
‡ Responsible maintainer since 2018
1
1.12 Option norule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.13 Option splitrule . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.14 The stable option . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.15 The multiple option . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.16 User interface — miscellaneous commands . . . . . . . . . . . . . . 9
3 Code: Preliminaries 10
4 Package options 10
4.1 The symbol option . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.2 The symbol* option . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.3 The para option . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.4 The side option . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.5 The ragged option . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.6 The perpage option . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.7 The PPdebug option . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.8 Fixing the LATEX misbehavior with respect to spacing . . . . . . . 12
4.9 The footnote/float placement options . . . . . . . . . . . . . . . . . 12
4.9.1 The abovefloats, belowfloats options . . . . . . . . . . . 13
4.9.2 The bottom option . . . . . . . . . . . . . . . . . . . . . . . 13
4.9.3 The bottomfloats option . . . . . . . . . . . . . . . . . . . 13
4.10 The marginal option . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.11 The flushmargin option . . . . . . . . . . . . . . . . . . . . . . . . 13
4.12 The hang option . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.13 The norule option . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.14 The splitrule option . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.15 The stable option . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.16 The multiple option . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.17 The start of the endgame . . . . . . . . . . . . . . . . . . . . . . . 15
6 Remaining requirements 28
6.1 The code that executes the multiple option . . . . . . . . . . . . 28
6.2 The code that executes the stable option . . . . . . . . . . . . . . 29
2
History
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 β
release.
In its first form, it was known as the “footnote” package, but by the time I
had released it to CTAN, that name had already been 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 (abovefloats, belowfloats, and bottomfloats got
introduced and the package now works with hyperref regardless of loading order.
There are however, still a few restrictions when using both packages together, in
particular the multiple option does not fully work.
3
Please note that “old” LATEX installations may have problems with the al-
gorithm for para footnotes on very wide pages (for example, those used by the
a0poster class). Recent LATEX installations use an improved technique that is
believed not to be susceptible to this problem.
4
1.6 Option symbol*
This is the symbol option, but with protection against the tedium that arises
because of the instability of the perpage option. When executing the perpage
option, the package often allocates footnotes to the wrong pages, only to correct
itself on a later run (having warned the user of the need for the later run with a
‘Label(s) may have changed ’ message). In these circumstances the symbol option
is prone to producing LATEX errors, which stop processing, and confound auto-
matic generation procedures. In the same situation, the symbol* option produces
information messages and a warning message at end document, and the user may
scan the log for those messages after processing has stabilized. The option pro-
duces numbers (17 and higher, in the case of the default symbol set) in place of
symbols, when the footnote number is too large.
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 symbols isn’t universally loved.
You may define a set of symbols with the \DefineFNsymbols command.
LATEX’s default set would be defined by the command:
\DefineFNsymbols*{lamport}{*\dagger\ddagger\S\P\|%
{**}{\dagger\dagger}{\ddagger\ddagger}}
Defined this way, the symbol set produces a “counter too large” error; a robust
version of the set (cf. the symbol* option (see 1.6)) is established by using the
\DefineFNsymbols command without the optional *. You may select a set of
symbols by use of the \setfnsymbol command; so to restore use of the default
set, you would type:
\setfnsymbol{lamport}
This package defines a small selection of alternative sets of symbols, using
\DefineFNsymbols:
bringhurst ∗ † ‡§∥¶
chicago ∗ † ‡§∥#
wiley ∗ ∗∗ † ‡ § ¶ ∥
together with a version of Lamport’s original set that, with doubled versions of §
and ¶, and tripled versions of everything but the vertical bars, provides a symbol
range to cover counters up to 16.
This last set, known as lamport* is selected as the default symbol set by the
package.
5
depends of whether pages are always stretched to the same height (\flushbottom
as used by the book class) or if they can run short (\raggedbottom as used by the
article or report class). If \raggedbottom is in force, then LATEX would normally
set the footnotes a mere \skip\footins distant from the bottom of the text
and bottom floats follow separated by \textfloatsep. Both spaces might get
stretched if \flushbottom is in force.
New: 2022-02 If you want to diverge from this default placement, then there are a number of
alterations that can be made:
• the order of footnotes and floats can be swapped; and
• both footnotes and floats can be forced to the bottom (i.e., \raggedbottom
then only applies to pages with neither), or
• only one of them is forced to the bottom, the other stays close to the text.
These can be achieved by applying one or more of the options discussed below.
6
1.8.5 Fixing a strange behavior of LATEX
New: 2022-02 In the default case (if footmisc is not loaded) LATEX shows a somewhat strange dis-
crepancy: on most pages the footnotes are attached a distance of \skip\footins
from the main text, even if that page is run short (i.e., with \raggedbottom in
force). However, whenever the is some infinite stretch at the end of the page, e.g.,
from using \newpage or \clearpage the footnotes are pushed to the bottom (in
particular on the last page of a document or chapter).
This is automatically corrected if footmisc is loaded with any of the options
that deal with footnote placement, i.e., abovefloats, belowfloats, bottom, or
bottomfloats. In particular, if you want to have the standard LATEX placement
(but with this strange behavior fixed, apply abovefloats (which is the normal
order but with the bug fixed).
The user may redefine these values (using \renewcommand): it is best to use the
font-size-dependent measures (multiples of \baselineskip for the skip, multiples
of em for the indent). Note that the default has only one of the two values non-
zero; both zero may result in easily-missed paragraph breaks, and both non-zero
is not generally thought to be a good-looking option.
7
1.12 Option norule
This option suppresses the ‘normal’ footnote rule, and advances \skip\footins
a bit to compensate
8
1.16 User interface — miscellaneous commands
The package also defines some miscellaneous footnote-related commands. The
present group provides alternative means of producing footnote marks: \footref
and \mpfootnotemark.
When you’re in a minipage, \footnote numbers run according to the mini-
page’s own footnote counter, and the marks are set in italic letters. However, the
numbers used by \footnotemark make reference to the ‘main’ footnote counter,
and are set in whatever is the current style for that: this behavior often surprises,
and there’s no obvious way in standard LATEX to “get around” it. The command
\mpfootnotemark gets around this problem in a minipage, by generating footnote
marks in the same way as those used by \footnote.
In fact, making reference to footnotes in general can be problematic: it can be
done by noting down the value of the footnote marker in a counter (or the like)
and then using the value in a subsequent \footnotemark or \mpfootnotemark.
This is a tedious way of going about things, and doesn’t allow representation of all
possible forms of footnote mark; \footref is a form of reference command that
sets the reference as if it were a footnote.1 The label should be set within the
argument of the footnote command that is being labelled:
...\footnote{Note text\label{fnlabel}}
...
... potato head\footref{fnlabel}
9
3 Code: Preliminaries
Well — here we go: let’s make the package file:
1 ⟨∗package⟩
Now declare what environment we need: version 6 needs a fairly recent LATEX.
2 \NeedsTeXFormat{LaTeX2e}[2020/10/01]
We need a token register in case we have to patch \@makecol:
3 \newtoks\FN@temptoken
\protected@writeaux This command is defined for future compatibility with Matt Swift’s newclude pack-
age (still, after all this time, not out of beta status).
4\providecommand\protected@writeaux{%
5 \protected@write\@auxout
6}
Now we define a jolly little macro to advance a macro count (#1) by a given
amount (#2).
12 \let\@advance@macro\l@advance@macro
\footnotemargin Finally, we define the length used by the marginal option, and initialize it as if
we’ve not had the option.
13 \newdimen\footnotemargin
14 \footnotemargin1.8em\relax
4 Package options
Most of the code of the package is contained within the option processing, one
way or another (that which isn’t, is executed after \ProcessOptions as a result
of flags set in the option processing).
10
4.2 The symbol* option
The robust version of the symbol option: if the current ‘symbol’ option doesn’t
provide enough variants, use arabic footnote number. We use a robust version of
the “extended ordinary” symbol set, described later (in section 1.7).
16 \newif\ifFN@robust \FN@robustfalse
17 \DeclareOption{symbol*}{%
18 \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
19 \FN@robusttrue
20 \AtEndOfPackage{\setfnsymbol{lamport*-robust}}%
21 }
\ifFN@para Define the para option: now simply sets a marker for use later when defining the
option’s auxiliary code and when patching the output routine and so on.
22 \newif\ifFN@para \FN@parafalse
23 \DeclareOption{para}{\ifFN@sidefn
24 \PackageError{footmisc}{Option "\CurrentOption" incompatible with
25 option "side"}%
26 {I shall ignore "\CurrentOption"}%
27 \else
28 \FN@paratrue
29 \fi
30 }
11
4.5 The ragged option
\footnotelayout A very simple option that merely changes the definition of one macro. Note
detection of the presence of the ragged2e package.
40 \let\footnotelayout\@empty
41 \DeclareOption{ragged}{%
42 \@ifundefined{RaggedRight}%
43 {\renewcommand\footnotelayout{\linepenalty50 \raggedright}}%
44 {\renewcommand\footnotelayout{\linepenalty50 \RaggedRight}}%
45 }
12
We handle that with a 3-way switch differenciating the different bottom cases:
bottom, bottomfloats or neither of the two options. Within those with split the
coding based on whether or not abovefloats was given (explicitly or implicitly).
ds@abovefloats These options change the order and that’s it. The important aspect is that they
ds@belowfloats are declared after the last two, otherwise they can’t overwrite them.
67 \DeclareOption{abovefloats}{\FN@abovefloatstrue \FN@fixskiptrue}
68 \DeclareOption{belowfloats}{\FN@abovefloatsfalse \FN@fixskiptrue}
13
4.12 The hang option
\ifFN@hangfoot We need a switch, since \@makefntext needs to be patched.
75 \newif\ifFN@hangfoot \FN@hangfootfalse
76 \DeclareOption{hang}{%
77 \FN@hangfoottrue
78 }
\pagefootnoterule Define defaults for the three footnote rules: note, we inherit the current state of
\mpfootnoterule \footnoterule for the two ‘regular’ footnote defaults, and if we’ve been preceded
\splitfootnoterule by option norule, they will both become null. . .
87 \let\pagefootnoterule\footnoterule
88 \let\mpfootnoterule\footnoterule
89 \def\splitfootnoterule{\kern-3\p@ \hrule \kern2.6\p@}
14
Remember a split for next page
99 \xdef\split@prev{\the\insertpenalties}%
100 \fi
101 }%
102 }
\@makecol \@makecol is shortened a lot, basically all the hardwired code in the middle has
moved into a configuration point.
108 \def \@makecol {%
109 \@kernel@before@cclv
110 \setbox\@outputbox \box\@cclv
The only real addition is the next command which either does nothing or removes
an infinite glue from the bottom of the \@outputbox.
111 \@outputbox@removebskip
15
Any “here” floats in the \@outputbox are now handled so we recycle their registers
and put them back to the \@freelist.
112 \let\@elt\relax
113 \xdef\@freelist{\@freelist\@midlist}%
114 \global \let \@midlist \@empty
Here we have the configurable part.
NOTE: Interface to configuration points will change in the future
115 \@makecol@appendblocks
The we deal with any \enlargethispage or run the normal code to build a col-
umn.
116 \ifvbox\@kludgeins
117 \@makespecialcolbox
118 \else
119 \@makenormalcolbox
120 \fi
121 \global \maxdepth \@maxdepth
122 }
\@outputbox@depth We need to know the depth of \@outputbox once in a while. Rather than using a
temp dimen (as it was done in the past), we give it a proper register.
123 \newdimen\@outputbox@depth
16
150 \vss}%
151 \fi
152 {\setbox \@tempboxa \box \@kludgeins}%
153 }
\@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 \raggedbottom is in force, footnotes
get attached to the main galley at a distance of \footskip on all pages except on
those that are ended by \newpage or \clearpage where the \vfil from \newpage
pushes the footnotes to the very bottom.
This is kind of a weird difference to a page ending with \pagebreak—in that
case the page is also run short, but the footnotes are not pushed to the bottom.
This is fixed by \@outputbox@removebskip but only if the switch FN@fixskip
is set to true (which is done whenever footmisc is called with with an option
specifying the footnote placement, i.e., not in the default case).
154 \ifFN@fixskip
155 \def\@outputbox@removebskip{%
We first test if we are in a \raggedbottom layout. If not we do nothing, but we
don’t disable the code because \raggedbottom may get used only for some parts
of the document.
156 \ifx\@textbottom\relax \else
We then append some negative glue at the end of \@outputbox provided it has a
glue stretch order of 1 or more (i.e., contains a fil or fill part).
157 \@outputbox@append{%
158 \@tempskipa\lastskip
159 \ifnum \gluestretchorder\@tempskipa>\z@
160 \vskip-\@tempskipa
\@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.
161 \xdef\@outputbox@reinsertbskip
162 {\noexpand\@outputbox@append{\vskip\the\@tempskipa}}%
163 \else
164 \global\let\@outputbox@reinsertbskip\relax
165 \fi
166 }%
167 \fi
168 }
We need a trivial top-level definition for \@outputbox@reinsertbskip in case the
first page has no bottom glue and the command gets called.
169 \let\@outputbox@reinsertbskip\relax
If nothing should get fixed we set both commands to \relax.
170 \else
171 \let\@outputbox@removebskip \relax
172 \let\@outputbox@reinsertbskip\relax
173 \fi
\@kernel@before@cclv These two commands are internal kernel hooks intended for tagging support in
\@kernel@before@footins case that is active. By default they do nothing (and may have been defined already
by \DocumentMetadata).
17
174 \providecommand\@kernel@before@cclv{}
175 \providecommand\@kernel@before@footins{}
\@outputbox@appendfootnotes This command appends the footnotes to the \@outputbox (if there are any). If
not then it does nothing.
184 \def\@outputbox@appendfootnotes {%
185 \ifvoid\footins \else
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 \footins box
before it gets appended.
NOTE: this code will get revised as part of CP handling in the future
186 \@makecol@handlesplitfootnotes
187 \@makecol@preparefootinshook
Then the footnotes are appended:
188 \@outputbox@append{%
189 \vskip \skip\footins
190 \@kernel@before@footins
191 \color@begingroup
192 \normalcolor
193 \footnoterule
Support for pdfcolfoot, eventually this can go once color is properly supported.
194 \csname pdfcolfoot@current\endcsname
195 \unvbox \footins
196 \color@endgroup
197 }%
198 \fi
199 }
\@outputbox@attachfloats Attaching top and bottom floats can usually be done in one go, but for special
\@outputbox@attachtopfloats layouts we might want more control so we provide also separate commands. There
\@outputbox@attachbottomfloats are packages out there that patch \@combinefloats so we are careful to call it
rather than give it a new name.
200 \def \@outputbox@attachfloats {\@combinefloats}
18
201 \def \@outputbox@attachtopfloats {%
202 \ifx \@toplist\@empty \else \@cflt \fi
203 }
204 \def \@outputbox@attachbottomfloats {%
205 \ifx \@botlist\@empty \else \@cflb \fi
206 }
\@makecol@handlesplitfootnotes This is only an early draft and doesn’t do much. Contains incomplete preparation
kecol@splitfootnotemessagehook for tagging commented out.
19
\@if@footnotes@TF Test if footnotes are present on the current page.
233 \def\@if@footnotes@TF{%
234 \ifvoid\footins
235 \expandafter\@secondoftwo
236 \else
237 \expandafter\@firstoftwo
238 \fi
239 }
All excess space are above the footnote and bottom float blocks. The order of the
blocks depend on @abovefloats:
256 \ifFN@abovefloats
257 %---------------------------------------------------------
If footnotes above floats floats both are at the bottom:
258 \def\@makecol@appendblocks {%
259 \@if@footnotes@TF
260 {\@outputbox@append{\vfill}}%
261 {\@if@bfloats@TF{\@outputbox@append{\vfill}}%
262 {\@outputbox@reinsertbskip}}%
263 \@outputbox@appendfootnotes
264 \@outputbox@attachfloats
265 }
266 %---------------------------------------------------------
267 \else
Otherwise only the footnotes are at the very bottom and floats stay close to the
text:
268 \def\@makecol@appendblocks {%
269 \@outputbox@attachfloats
20
270 \@if@footnotes@TF
271 {\@outputbox@append{\vfill}}%
272 {\@outputbox@reinsertbskip}%
273 \@outputbox@appendfootnotes
274 }
275 \fi
276 \or
277 %---------------------------------------------------------
278 % 2 = bottomfloats option given
279 %---------------------------------------------------------
280 \ifFN@abovefloats
281 %---------------------------------------------------------
21
have several \vfil on the page before the \newpage you would alter the space
distribution if one is taken out.
310 \@outputbox@reinsertbskip
311 }
312 \else
313 %---------------------------------------------------------
The \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.
325 \ERROR
326 \fi
327
\ifFN@baselinestretch Whatever we do, we are going to patch \@footnotetext; so first of all, we’ll check
\FN@singlespace it’s not been hacked by anyone other than setspace.sty (while we’re at it we
also record whether setspace is loaded). so we do this here:
328 \newif\ifFN@setspace
329 \@ifpackageloaded{setspace}{%
330 \FN@setspacetrue
331 \@ifclassloaded{memoir}{%
we’re seeing memoir’s emulation of setspace
332 \let\FN@baselinestretch\m@m@singlespace
333 }{%
we’re seeing setspace in its own right
334 \let\FN@baselinestretch\setspace@singlespace
335 }%
336 }{%
337 \FN@setspacefalse
338 }
22
insert compatibility code with setspace.sty if necessary
342 \ifFN@setspace
343 \let\baselinestretch\FN@baselinestretch
344 \fi
345 \reset@font\footnotesize
346 \interlinepenalty\interfootnotelinepenalty
347 \splittopskip\footnotesep
348 \splitmaxdepth \dp\strutbox
349 \floatingpenalty\@MM
350 \hsize\columnwidth
351 \@parboxrestore
352 \def\@currentcounter{footnote}%
353 \protected@edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
354 \color@begingroup
We set the paragraph in an \hbox and apply the fudge factor here (these days
done with eTEX methods):
355 \setbox\FN@tempboxa\hbox{%
This needs a parameter; the rule should be moved to the beginning of the
footnote paragraph, but the \ignorespaces should be left here.
356 \@makefntext{\ignorespaces#1\strut
We insert a penalty here to help line breaking in the footnote paragraph; the
value is taken from the TEXbook.
357 \penalty-10\relax
358 \hskip\footglue
359 }% end of \@makefntext parameter
360 }% end of \hbox
361 \dp\FN@tempboxa\z@
362 \ht\FN@tempboxa\dimexpr\wd\FN@tempboxa *%
363 \footnotebaselineskip / \columnwidth\relax
364 \box\FN@tempboxa
365 \color@endgroup
366 }%
367 \FN@mf@prepare
368 }
If we’re not doing paragraph footnotes, we now simply tag a \FN@mf@prepare
command on the end of the definition; of course, there are different definitions
according as whether we’re using side footnotes. . .
369 \else
370 \ifFN@sidefn
371 \long\def\FN@footnotetext#1{%
372 \marginpar{%
insert compatibility code with setspace.sty if necessary
373 \ifFN@setspace
374 \let\baselinestretch\FN@baselinestretch
375 \fi
376 \reset@font\footnotesize
377 \def\@currentcounter{footnote}%
378 \protected@edef\@currentlabel{%
23
379 \csname p@footnote\endcsname\@thefnmark
380 }%
381 \color@begingroup
382 \@makefntext{%
383 \ignorespaces#1%
384 }%
385 \color@endgroup
386 }%
387 \FN@mf@prepare
388 }%
389 \else
390 \long\def\FN@footnotetext#1{%
391 \insert\footins{%
insert compatibility code with setspace if necessary
392 \ifFN@setspace
393 \let\baselinestretch\FN@baselinestretch
394 \fi
395 \reset@font\footnotesize
396 \interlinepenalty\interfootnotelinepenalty
397 \splittopskip\footnotesep
398 \splitmaxdepth \dp\strutbox
399 \floatingpenalty\@MM
400 \hsize\columnwidth
401 \@parboxrestore
402 \def\@currentcounter{footnote}%
403 \protected@edef\@currentlabel{%
404 \csname p@footnote\endcsname\@thefnmark
405 }%
406 \color@begingroup
407 \@makefntext{%
408 \rule\z@\footnotesep
409 \ignorespaces#1\@finalstrut\strutbox
410 }%
411 \color@endgroup
412 }%
413 \FN@mf@prepare
414 }%
415 \fi
416 \fi
\FN@tempboxa We need some temporary boxes, and LATEX only defines one
\FN@tempboxb 418 \let\FN@tempboxa\@tempboxa
\FN@tempboxb 419 \newbox\FN@tempboxb
420 \newbox\FN@tempboxc
24
\footglue A direct crib from the TEXbook:
421 \newskip\footglue \footglue=1em plus.3em minus.3em
\@makefntext The standard classes set the footnote mark flush with the text of the footnote,
but that’s not appropriate for paragraph footnotes, we find.
There’s not much point in patching this code from the original, since the only
things it has in common with the original are the footnote mark and the footnote
text (which last is the argument). Note that the \leavevmode isn’t necessary
except in the case of footnotes in minipages, which otherwise end up with the
\@makefnmark being executed in restricted vertical mode, which results in its
\hbox ending up in a line of its own.
422 \long\def\@makefntext#1{\leavevmode
423 \@makefnmark\nobreak
424 \hskip.5em\relax#1%
425 }
\footnotebaselineskip We need to record a value for the baseline skip when in footnotes:
426 \newdimen\footnotebaselineskip
427 {%
428 \footnotesize
429 \global
430 \footnotebaselineskip=\normalbaselineskip
431 }
25
\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 \columnwidth. However, inside a multicols environment
we need to use \textwidth as the footnotes there will span across all columns.
To detect if we are inside such an environment we look at \doublecolnumber
which is only positive if inside such an environment.
455 \@ifpackageloaded{multicol}
456 {\def\FN@setfootnoteparawidth
457 {\hsize\ifnum\doublecol@number>\@ne
458 \textwidth
459 \else \columnwidth \fi}}
460 {\def\FN@setfootnoteparawidth{\hsize\columnwidth}}
26
477 \ifFN@hangfoot
478 \bgroup
get the marker so we can measure it:
479 \setbox\@tempboxa\hbox{%
480 \ifdim\footnotemargin>0pt
481 \hb@xt@\footnotemargin{\@makefnmark\hss}%
482 \else
483 \@makefnmark
484 \fi
485 }%
use the width of the box to set up hanging (potentially for more than one
paragraph); note that the hanging \parskip and \parindent are set after we’ve
executed \leavevmode(!)
486 \leftmargin\wd\@tempboxa
487 \rightmargin\z@
488 \linewidth \columnwidth
489 \advance \linewidth -\leftmargin
490 \parshape \@ne \leftmargin \linewidth
We also update \@totalleftmargin so that display environments, such as quote if
used inside the footnote know about the hanging indentation (otherwise something
like quote isn’t centered in the available space):
491 \@totalleftmargin \leftmargin
492 \footnotesize
stop the \parshape being overwritten:
493 \@setpar{{\@@par}}%
and finally put the marker in its chosen place:
494 \leavevmode
495 \llap{\box\@tempboxa}%
496 \parskip\hangfootparskip\relax
497 \parindent\hangfootparindent\relax
498 \else
ordinary (non-hanging) footnote version:
499 \parindent1em
500 \noindent
501 \ifdim\footnotemargin>\z@
502 \hb@xt@ \footnotemargin{\hss\@makefnmark}%
503 \else
504 \ifdim\footnotemargin=\z@
505 \llap{\@makefnmark}%
506 \else
507 \llap{\hb@xt@ -\footnotemargin{\@makefnmark\hss}}%
508 \fi
509 \fi
510 \fi
511 \footnotelayout#1%
if we’re hanging, close the hang group
512 \ifFN@hangfoot
513 \par\egroup
514 \fi
27
515 }
516 \fi
6 Remaining requirements
We have to insert the code that executes the stable and multiple options. Since
stable may suppress the setting of a footnote altogether, we put the multiple
option first, as otherwise we might get isolated superscripted commas that separate
footnotes that have otherwise been suppressed.
28
548 \edef\@x@sf{\the\spacefactor}%
549 \unkern
550 \textsuperscript{\multfootsep}%
551 \spacefactor\@x@sf\relax
552 \fi
553 }
If we’re not doing multiple, just create an empty \FN@mf@prepare
554 \else
555 \let\FN@mf@prepare\relax
Need to provide a definition for \FN@footnotemark in that case.
556 \let\FN@footnotemark\@footnotemark
557 \fi
29
586 {}%
587 }
588 \def\FN@sf@gobble@bracket[#1]{}
589 \fi
Note that doubled-up (and worse — see below) symbols need braces around them.
605 \DeclareDocumentCommand\DefineFNsymbols {smO{text}m}{%
30
606 \expandafter\ifx\csname FN@fnsymbol@#2\endcsname\relax
607 \PackageInfo{footmisc}{Declaring symbol style #2}%
608 \else
609 \PackageWarning{footmisc}{Redeclaring symbol style #2}%
610 \fi
611 \toks@{}%
612 \def\@tempb{\end}%
613 \FN@build@symboldef#4\end
614 \def\@tempc{math}%
615 \def\@tempd{#3}%
616 \expandafter\xdef\csname FN@fnsymbol@#2\endcsname##1{%
617 \ifx\@tempc\@tempd
618 \noexpand\ensuremath
619 \else
620 \noexpand\nfss@text
621 \fi
622 {%
623 \noexpand\ifcase##1%
624 \the\toks@
625 \noexpand\else
626 \IfBooleanTF#1{\noexpand\@ctrerr}%
627 {\noexpand\FN@orange##1}%
628 \noexpand\fi
629 }%
630 }%
631 }
632 \def\FN@build@symboldef#1{%
633 \def\@tempa{#1}%
634 \ifx\@tempa\@tempb
635 \else
636 \toks@\expandafter{\the\toks@\or#1}%
637 \expandafter\FN@build@symboldef
638 \fi
639 }
\DefineFNsymbolsTM Now do the same job for the “modern” way of having both text and maths variants
\@DefineFNsymbolsTM of everything.
\FN@build@symboldefTM 640 \DeclareDocumentCommand\DefineFNsymbolsTM {smm}{%
641 \expandafter\ifx\csname FN@fnsymbol@#2\endcsname\relax
642 \PackageInfo{footmisc}{Declaring symbol style #2}%
643 \else
644 \PackageWarning{footmisc}{Redeclaring symbol style #2}%
645 \fi
646 \toks@{}%
647 \def\@tempb{\end}%
648 \FN@build@symboldefTM#3\end\@null
649 \expandafter\xdef\csname FN@fnsymbol@#2\endcsname##1{%
650 \noexpand\ifcase##1%
651 \the\toks@
652 \noexpand\else
653 \IfBooleanTF#1{\noexpand\@ctrerr}%
654 {\noexpand\FN@orange##1}%
655 \noexpand\fi
656 }%
31
657 }
Note that this version has two variants of every definition, so needs two stopper
codes above.
658 \def\FN@build@symboldefTM#1#2{%
659 \def\@tempa{#1}%
660 \ifx\@tempa\@tempb
661 \else
662 \toks@\expandafter{\the\toks@\or\TextOrMath{#1}{#2}}%
663 \expandafter\FN@build@symboldefTM
664 \fi
665 }
\FN@orange Macros to deal with footnote symbols going out of range (when they’re allowed
\@fnsymbol@orange to – e.g., in the symbol* option).
\@diagnose@fnsymbol@orange 666 \def\FN@orange#1{%
667 \ifFN@robust
668 \@arabic#1%
669 \@bsphack
670 \PackageInfo{footmisc}{Footnote number \number#1 out of range}%
671 \protect\@fnsymbol@orange
672 \@esphack
673 \else \@ctrerr \fi
674 }
675 \global\let\@diagnose@fnsymbol@orange\relax
676 \AtEndDocument{\@diagnose@fnsymbol@orange}
677 \def\@fnsymbol@orange{%
678 \gdef\@diagnose@fnsymbol@orange{%
679 \PackageWarningNoLine{footmisc}{Some footnote number(s)
680 were out of range
681 \MessageBreak
682 see log for details%
683 }%
684 }%
685 }
\FN@fnsymbol@bringhurst These macros provide replacement orderings (and symbol sets) for footnote sym-
\FN@fnsymbol@chicago bols, plus a robust version of the original Lamport set, and an extended version
\FN@fnsymbol@wiley of Lamport’s original
\FN@fnsymbol@lamport-robust 686 \DefineFNsymbolsTM{bringhurst}{%
\FN@fnsymbol@lamport 687 \textasteriskcentered *%
688 \textdagger \dagger
689 \textdaggerdbl \ddagger
690 \textsection \mathsection
691 \textbardbl \|%
692 \textparagraph \mathparagraph
693 }%
694 \DefineFNsymbolsTM{chicago}{%
695 \textasteriskcentered *%
696 \textdagger \dagger
697 \textdaggerdbl \ddagger
698 \textsection \mathsection
699 \textbardbl \|%
700 \#\#%
32
701 }%
702 \DefineFNsymbolsTM{wiley}{%
703 \textasteriskcentered *%
704 {\textasteriskcentered\textasteriskcentered}{**}%
705 \textdagger \dagger
706 \textdaggerdbl \ddagger
707 \textsection \mathsection
708 \textparagraph \mathparagraph
709 \textbardbl \|%
710 }%
711 \DefineFNsymbolsTM{lamport-robust}{%
712 \textasteriskcentered *%
713 \textdagger \dagger
714 \textdaggerdbl \ddagger
715 \textsection \mathsection
716 \textparagraph \mathparagraph
717 \textbardbl \|%
718 {\textasteriskcentered\textasteriskcentered}{**}%
719 {\textdagger\textdagger}{\dagger\dagger}%
720 {\textdaggerdbl\textdaggerdbl}{\ddagger\ddagger}%
721 }
722 \DefineFNsymbolsTM*{lamport*}{%
723 \textasteriskcentered *%
724 \textdagger \dagger
725 \textdaggerdbl \ddagger
726 \textsection \mathsection
727 \textparagraph \mathparagraph
728 \textbardbl \|%
729 {\textasteriskcentered\textasteriskcentered}{**}%
730 {\textdagger\textdagger}{\dagger\dagger}%
731 {\textdaggerdbl\textdaggerdbl}{\ddagger\ddagger}%
732 {\textsection\textsection}{\mathsection\mathsection}%
733 {\textparagraph\textparagraph}{\mathparagraph\mathparagraph}%
734 {\textasteriskcentered\textasteriskcentered\textasteriskcentered}{***}%
735 {\textdagger\textdagger\textdagger}{\dagger\dagger\dagger}%
736 {\textdaggerdbl\textdaggerdbl\textdaggerdbl}{\ddagger\ddagger\ddagger}%
737 {\textsection\textsection\textsection}%%
738 {\mathsection\mathsection\mathsection}%
739 {\textparagraph\textparagraph\textparagraph}%%
740 {\mathparagraph\mathparagraph\mathparagraph}%
741 }
742 \setfnsymbol{lamport*}
743 \DefineFNsymbolsTM{lamport*-robust}{%
744 \textasteriskcentered *%
745 \textdagger \dagger
746 \textdaggerdbl \ddagger
747 \textsection \mathsection
748 \textparagraph \mathparagraph
749 \textbardbl \|%
750 {\textasteriskcentered\textasteriskcentered}{**}%
751 {\textdagger\textdagger}{\dagger\dagger}%
752 {\textdaggerdbl\textdaggerdbl}{\ddagger\ddagger}%
753 {\textsection\textsection}{\mathsection\mathsection}%
754 {\textparagraph\textparagraph}{\mathparagraph\mathparagraph}%
33
755 {\textasteriskcentered\textasteriskcentered\textasteriskcentered}{***}%
756 {\textdagger\textdagger\textdagger}{\dagger\dagger\dagger}%
757 {\textdaggerdbl\textdaggerdbl\textdaggerdbl}{\ddagger\ddagger\ddagger}%
758 {\textsection\textsection\textsection}%%
759 {\mathsection\mathsection\mathsection}%
760 {\textparagraph\textparagraph\textparagraph}%%
761 {\mathparagraph\mathparagraph\mathparagraph}%
762 }
34