-
Notifications
You must be signed in to change notification settings - Fork 0
/
footmisx.dtx
2564 lines (2559 loc) · 81.4 KB
/
footmisx.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*readme>
This package is based on Robin Fairbairns footmisc package.
Copyright 2016 Bastien Roucari\`es
Copyright 1995, 1996, 1998, 1999, 2001--2003, 2008, 2009 Robin Fairbairns
It allow to personnalize footnote on LaTeX.
Last version is found here https://github.com/bastien-roucaries/footmisx
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
\expandafter\begingroup
\fi
%</internal>
%<*install>
\input l3docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
---------------------------------------------------------------
The footmisx package
---------------------------------------------------------------
\endpreamble
\postamble
Copyright
\endpostamble
\generate{
\file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\generate{
\file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\generate{
\file{README.md}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
\expandafter\endbatchfile
\else
\expandafter\endgroup
\fi
%</internal>
%<*driver|package>
\RequirePackage{expl3}[2015/09/11]
\RequirePackage{xparse}
\RequirePackage{filehook}[2011/01/09]
\ProvidesExplPackage{footmisx}{2016/12/12}{20161212}{miscellany of footnote facility}
\ExplSyntaxOff
%</driver|package>
% \end{macrocode}
%
% Code to enable LaTeX processing of the file without the intervention
% of a driver file.
% \begin{macrocode}
%<*driver>
\setcounter{errorcontextlines}{999}
\documentclass{l3doc}
\usepackage{hyperref}
\usepackage{footmisx}
\newcommand{\mailto}[1]{\href{mailto:#1}{\nolinkurl{#1}}}
% \end{macrocode}
%
% we limit the things that we will index
% \begin{macrocode}
\DoNotIndex{\#,\@MM,\@cclv,\@gobble,\@ifnextchar,\@ifundefined}
\DoNotIndex{\|,\advance,\begingroup,\bgroup,\box,\csname}
\DoNotIndex{\dagger,\ddagger,\def,\divide,\dp}
\DoNotIndex{\edef,\egroup,\ifx,\else,\fi,\endcsname,\endgroup,\end}
\DoNotIndex{\endinput,\ensuremath,\expandafter}
\DoNotIndex{\gdef,\global,\hbox,\hskip,\hss,\ht}
\DoNotIndex{\ifcase,\or,\ifdim,\ifhbox,\ifhmode,\ifnum,\ifvbox,
\fi ,\fi ,\fi ,\fi ,\fi ,\fi }
\DoNotIndex{\ifvoid,\fi,\kern,\let,\long,\loop}
\DoNotIndex{\MessageBreak,\newbox,\newcommand,\newcounter}
\DoNotIndex{\newdimen,\newif,\newskip,\newtoks,\noexpand}
\DoNotIndex{\P,\p@,\par,\penalty,\protect,\providecommand}
\DoNotIndex{\relax,\renewcommand,\S,\setbox,\setcounter}
\DoNotIndex{\skip,\space,\the,\typeout,\vbox,\vskip}
\DoNotIndex{\wd,\xdef,\@}
\GetFileInfo{footmisx.dtx}
\EnableCrossrefs
% to get documented source of the package, comment out the next line,
% and uncomment the following one; otherwise, create yourself
% (somewhere on your LaTeX input path) a file ltxdoc.cfg that contains
% simply \AtBeginDocument{\AlsoImplementation}
%\OnlyDescription
\AlsoImplementation
\setcounter{StandardModuleDepth}{1}
\begin{document}
\DocInput{footmisx.dtx}
\end{document}
%</driver>
% \end{macrocode}
% \fi
%
%
%
% \title{\texttt{footmisx} ---\\
% a portmanteau package\\
% for customising footnotes in \LaTeX\thanks{This file has
% version number \fileversion, last revised \filedate}}
% \author{Bastien Roucari\`es\thanks{\mailto{[email protected]}} formerly
% Robin Fairbairns}
% \maketitle
%
% \tableofcontents{}
%
% \section*{Copyright statement}
%
% \noindent Program: \texttt{footmisx.dtx}\par
% \noindent Copyright 2016 Bastien Roucari\`es
% \noindent Copyright 1995 1996 1998 1999 2001--2003 2008 2009 Robin Fairbairns
%
% 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 http://www.latex-project.org/lppl.txt, and version
% 1.3c or later is part of all distributions of LaTeX version
% 2005/12/01 or later.
%
% This work has the LPPL maintenance status `author-maintained'.
%
% \section*{History}
%
% This package is based of Robin Fairbairns footmisc package.
%
% This package originated as support of a personal project, which Robin
% was switching to \LaTeX{} 2e over the Christmas holiday period of
% 1993, using the first \ensuremath{\beta} 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''.
%
% In 2016 it was forked as footmisx. Last version could be found at
% \url{https://github.com/bastien-roucaries/footmisx}
%
% \section{User interface~--- package options}
%
% The \textsf{footmisx} package provides several different
% customisations of the way foonotes are represented in \LaTeXe{}
% documents (the sources of the code in this package are various, but
% all of it has been massaged by the author; where the code comes from
% elsewhere, there are attributions given below, somewhere or other).
%
% The interface to the
% package's options is mostly rather simple~--- each one is presented as an
% option in the |\usepackage| command, and for most, nothing else
% needs to be done. For example, to use a useful
% and consistent set, the author invokes the package with the
% command |\usepackage[perpage,para,symbol*]{footmisx}|.
%
% For a small number of options, there are additional parameters
% available; these are described in the subsections below.
%
% \subsection{Option \texttt{perpage}}
% \label{sec:perpagedoc}
%
% This option resets footnote numbering for each page of the document.
% It needs at least two passes to do this correctly (though it comes
% as close as possible on the first pass). You generally have to make
% two passes with \LaTeX{} anyway, to get the cross-references right,
% so an additional pass for this purpose shouldn't cause any
% additional problem. The option includes code to report that
% `\emph{Label(s) may have changed}', which will help the poor user to
% realise that (yet) another run is in order.
%
% \subsection{Option \texttt{para}}
%
% This option (derived from code by Dominik Wujastyk and Chris Rowley)
% causes footnotes to be typeset as a single paragraph at the bottom
% of the page on which they occur. In the case that there is only one
% footnote on the page, no effect will be observed. However, if there
% are several footnotes on the page, they will be run together in the
% page foot, each introduced by its footnote mark. The original
% demand for the option came from the needs of those preparing
% critical editions; such documents typically have large numbers of
% small footnotes, which look ridiculous if each is typeset in a
% paragraph of its own; in most other disciplines, such multiplicities
% of footnotes represent mere self-indulgence: the author of this
% package is disgracefully guilty of this.
%
% Please note that ``old'' \LaTeX{} installations may have problems
% with the algorithm for \texttt{para} footnotes on very wide pages
% (for example, those used by the \textsf{a0poster} class). Recent
% \LaTeX{} installations use an improved technique that is believed
% not to be susceptible to this problem.
%
% \subsection{Option \texttt{side}}
%
% This option (suggested by Frank Mittelbach) causes footnotes to be
% typeset using the \cs{marginpar} command: this has the advantage
% that the note appears close to its ``call-up'', but has all the
% disadvantages associated with the \cs{marginpar} command (which
% consumes `float' slots, and doesn't always place itself correctly at
% the top of pages in two-sided documents). Since the measure in
% which the footnote is to be typeset is likely to be pretty narrow,
% users of the \texttt{side} option are recommended also to use the
% \texttt{ragged} option, to avoid ugly spacing and line breaks.
%
% There is a further problem (apart from the occasional failure to
% place the marginal note on the correct side of the page) in
% two-sided documents: one would like `raggedness' to appear
% differently in different margins (setting the left, rather than the
% right, side ragged in the left margin). (The author would welcome
% suggestions on means of addressing the problem.)
%
% \subsection{Option \texttt{ragged} and \cs{footnotelayout}}
%
% The package provides facilities for ragged right setting of
% footnotes (so long as the \texttt{para} option isn't in effect).
% The change is effected by use of the command \cs{footnotelayout};
% the package inserts this command into the start of the argument of
% \cs{footnotetext} (in effect: \cs{footnote} works, roughly, by
% calling the guts of \cs{footnotetext} at its end).
%
% If you want to use some special effect other than ragged right, feel
% free to change \cs{footnotelayout} yourself: some intriguing (and
% completely undesirable) results are no doubt available. Change the
% setting simply by use of
% \cs{renewcommand}\cs{footnotelayout}\texttt{\dots}\@. The
% \texttt{ragged} option simply sets \cs{footnotelayout} to set
% \cs{raggedright} or \cs{RaggedRight} as appropriate. (If you intend
% to use the \textsf{ragged2e} package, load it before
% \textsf{footmisx}~--- if \textsf{footmisx} finds \cs{RaggedRight} is
% available, it automatically uses it in place of \cs{raggedright}.)
%
% \subsection{Option \texttt{symbol}}
%
% This option simply establishes that footnotes are `labelled' by
% a symbol sequence. The command used is equivalent to that
% suggested in \LaTeX{} manuals such as Lamport's (the job performed
% by the option is very simple, and doesn't really need a package).
%
% Using symbols to `number' your footnotes can be problematic: there
% is a limited number of symbols, and \LaTeX{} will report an error if
% your footnotes exceed that limit. To avoid such problems, consider
% the \texttt{symbol*} option, or the \cs{setfnsymbol} command (see
% the next two sections), or number your footnotes by the page (see
% section~\ref{sec:perpagedoc}).
%
% \subsection{Option \texttt{symbol*}}
% \label{doc-symbol*}
%
% This is the \texttt{symbol} option, but with protection against the
% tedium that arises because of the instability of the
% \texttt{perpage} option. When executing the \texttt{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 `\emph{Label(s) may have changed}'
% message). In these circumstances the \texttt{symbol} option is
% prone to producing \LaTeX{} errors, which stop processing, and
% confound automatic generation procedures. In the same situation,
% the \texttt{symbol*} option produces information messages and a
% warning message at end document, and the user may scan the log for
% those messages \emph{after} processing has stabilised. The option
% produces numbers (17 and higher, in the case of the default symbol
% set) in place of symbols, when the footnote number is too large.
%
% \subsection{The \cs{setfnsymbol} and \cs{DefineFNsymbols} commands}
% \label{footnote-symbols}
%
% 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 \cs{DefineFNsymbols}
% command. \LaTeX{}'s default set would be defined by the command:
% \begin{center}
% \verb|\DefineFNsymbols*{lamport}|%
% \unskip\verb|{*\dagger\ddagger\S\P|\texttt{\char`\\\char`\|\%}\\
% \unskip\verb| {**}{\dagger\dagger}{\ddagger\ddagger}}|
% \end{center}
% Defined this way, the symbol set produces a ``counter too large''
% error; a robust version of the set (cf.~the \texttt{symbol*} option
% (see \ref{doc-symbol*}) using the \cs{DefineFNsymbols} command
% without the optional |*|.
% You may select a set of symbols by use of the \cs{setfnsymbol}
% command; so to restore use of the default set, you would type:
% \begin{center}
% \verb|\setfnsymbol{lamport}|
% \end{center}
%
% This package defines a small selection of alternative sets of
% symbols, using \cs{DefineFNsymbol}:
% \begin{center}
% \begin{tabular}{ll}
% \texttt{bringhurst} & $*\,\dagger\,\ddagger\,\S\,\|\,\P$ \\
% \texttt{chicago} & $*\,\dagger\,\ddagger\,\S\,\|\,\#$ \\
% \texttt{wiley} & $*\,\mathop{**}\,\dagger\,\ddagger\,\S\,\P\,\|$
% \end{tabular}
% \end{center}
% together with a version of Lamport's original set that, with doubled
% versions of $\S$ and $\P$, and tripled versions of everything but
% the vertical bars, provides a symbol range to cover counters up to
% 16.
%
% This last set, known as \texttt{lamport*} is selected as the default
% symbol set by the package.
%
% \subsection{Option \texttt{bottom}}
%
% This option forces footnotes to the bottom of the page; this is only
% noticeably useful in case that \cs{raggedbottom} is in effect, when
% \LaTeX{} would normally set the footnotes a mere
% \cs{skip}\cs{footins} distant from the bottom of the text.
%
% There's a further infelicity in \LaTeX{}'s placing of footnotes of
% the bottom of pages: if a bottom float appears on a page, \LaTeX{}
% places the footnote \emph{above} it. The \texttt{bottom} option
% places the footnote at the foot of the page.
%
% \subsection{Option \texttt{marginal}}
%
% This option adjusts the position of footnote mark relative to the
% start of the line in which they appear (the the option is
% incompatible with option \texttt{para}, for obvious reasons).
%
% When this option is in effect, the footnote is set
% \cs{footnotemargin} relative to the left margin of the page; the
% default setting for \cs{footnotemargin} is -0.8em, which means that
% the footnote mark will be set jutting 0.8em into the margin. If
% \cs{footnotemargin} is a positive length, the footnote mark will be
% set with its right edge \cs{footnotemargin} from the margin. (In
% the absence of the option, \cs{footnotemargin} is set to 1.8em; you
% may change that value with a \cs{setlength} command.)
%
% \subsection{Option \texttt{flushmargin}}
%
% This option is as option marginal, but sets the footnote marker
% flush with, but just inside the margin from, the text of the
% footnote.
%
% \subsection{Option \texttt{hang}}
%
% This option sets the footnote mark flush with the margin, and makes
% the body of the footnote hang at an indentation of
% \cs{footnotemargin} (if that is a positive distance), or the width
% of the marker (if \cs{footnotemargin}$\leq0$). The option code
% itself leaves \cs{footnotemargin} at its default value of 1.8em.
%
% The footnote itself may of course be longer than one paragraph; if
% so, the paragraphs will be separated by the vertical space specified
% by \cs{hangfootparskip}, and the second and subsequent paragraphs
% are indented by \cs{hangfootparindent}. Default values are:
% \begin{center}
% \begin{tabular}{ll}
% \cs{hangfootparskip} & 0.5\cs{baselineskip} \\
% \cs{hangfootparindent} & 0em
% \end{tabular}
% \end{center}
% The user may redefine these values (using
% \cs{renewcommand}): it is best to use the font-size-dependent
% measures (multiples of \cs{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.
%
% \subsection{Option \texttt{norule}}
%
% This option suppresses the `normal' footnote rule, and advances
% \cs{skip}\cs{footins} a bit to compensate
%
% \subsection{Option \texttt{splitrule}}
%
% This option makes puts a full-width rule above the split-off part of
% a split footnote. (Remember that split footnotes don't happen if
% you're doing paragraph footnotes.)
%
% The option provides three different \cs{footnoterule} commands:
% \begin{center}
% \begin{tabular}{ll}
% \cs{mpfootnoterule} & for use in minipages \\
% \cs{pagefootnoterule} & for normal footnotes on regular pages \\
% \cs{splitfootnoterule} & for the tail of a split footnote
% \end{tabular}
% \end{center}
% By default, \cs{mpfootnoterule} and \cs{pagefootnoterule} retain the
% original definition of \cs{footnoterule} (which nay have been
% modified by a \texttt{norule} option), while \cs{splitfootnoterule}
% becomes a full-width rule.
%
% \subsection{The \texttt{stable} option}
%
% This option deals with the problem of placing footnotes in section
% titles (and so on). While there is (sometimes, just) justification
% for putting footnotes in titles, \LaTeX's treatment of the content
% of titles militates against them. Of course, the title argument is
% ordinarily a moving one, and \cs{footnote} is a fragile command, but
% the real problem comes from the way the argument actually moves~---
% which is to two places. The argument moves to the table of
% contents, where the footnote will (at least) look odd. But the
% argument also moves to the marks that make up page headers, etc.,
% and \emph{there} it creates havoc, since page headers are executed
% in page make-up, and page make-up \emph{must not} create footnotes.
%
% If you use the \texttt{stable} option, the footnote won't move to
% the table of contents or the page headers, but it will be typeset
% correctly within the title itself.
%
% The situation with \cs{footnotemark} is less dire (it could in
% principle appear in page headers, for example); footnote marks
% appearing on pages other than where their text appears are none the
% less confusing, and the stable option treats \cs{footnotemark} in
% the same way that it treats \cs{footnote}.
%
% \subsection{The \texttt{multiple} option}
%
% This option deals with the case where the author needs to type
% things like
% \begin{verbatim}
% mumble\footnote{blah}\footnote{grumble}
% \end{verbatim}
% Without special treatment, \LaTeX{} would output something like
% \begin{quote}
% mumble\textsuperscript{1314}
% \end{quote}
% \noindent What the \texttt{multiple} option makes of the above is
% \begin{quote}
% mumble\textsuperscript{13,14}
% \end{quote}
% which is what most people would expect. The comma separator
% actually derives from the definition of \cs{multfootsep}, which
% may be changed by \cs{renewcommand} if the option is in effect.
%
% The option also treats \cs{footnotemark} in the same way.
%
% \subsection{User interface~--- miscellaneous commands}
%
% The package also defines some miscellaneous footnote-related
% commands. The present group provides alternative means of producing
% footnote marks: \cs{footref} and \cs{mpfootnotemark}.
%
% When you're in a minipage, \cs{footnote} numbers run according to the
% minipage's own footnote counter, and the marks are set in italic
% letters. However, the numbers used by \cs{footnotemark} make
% reference to the `main'
% footnote counter, and are set in whatever is the current style for
% that: this behaviour often surprises, and there's no obvious way in
% standard \LaTeX{} to ``get around'' it. The command
% \cs{mpfootnotemark} gets around this problem in a minipage, by
% generating footnote marks in the same way as those used by
% \cs{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 \cs{footnotemark} or \cs{mpfootnotemark}. This is a
% tedious way of going about things, and doesn't allow representation
% of all possible forms of footnote mark; \cs{footref} is a form of
% reference command that sets the reference as if it were a footnote.
% The label should be set \emph{within} the argument of the footnote
% command that is being labelled:
% \begin{verbatim}
% ...\footnote{Note text\label{fnlabel}}
% ...
% ... potato head\footref{fnlabel}
% ... potato head\footref*{fnlabel} without link.
% \end{verbatim}
%
% \section{User interface~--- interactions with other packages}
%
% The \textsf{footmisx} package modifies several parts of the \LaTeX{}
% kernel; what gets modified depends on the options you select. This
% behaviour can cause problems with other packages, particularly those
% that also modify the kernel.
%
% Known interactions are:
% \begin{description}
% \item[\normalfont\textsf{setspace}] The \textsf{setspace} package
% modifies the way line spacing is calculated in footnotes.
% \textsf{footmisx} knows about this, and preserves the change.
%
% Note that \textsf{setspace} could be loaded anywhere except between
% \textsf{hyperref} and \textsf{footmisx}.
% \item[\normalfont\textsf{memoir} class] The class emulates
% \textsf{setspace}, and we detect that emulation and deal with it
% in the same way as \textsf{setspace}.
% \item[\normalfont\textsf{hyperref}] The \textsf{hyperref} package
% has ambitions to make hyperlinks from footnote marks to the
% corresponding footnote body; \textsf{footmisx} knows about this,
% and preserves hyperlink.
% \item[\normalfont\textsf{manyfoot}] The \textsf{manyfoot} package
% permits several independent sequences of footnotes. Some
% preliminary work towards interworking with \textsf{footmisx} has
% been completed, but more remains to be done at the time of
% writing.
% \end{description}
%
% Know incompatibilities are:
% \begin{description}
% \item[\normalfont\textsf{footnpag}] Replace with option \texttt{perpage}. You could also
% use package \textsf{perpage} and \tn{MakePerPage{footnote}} command.
% \item[\normalfont\textsf{pagefoots}] Replace with option \texttt{perpage}. You could also
% use package \textsf{perpage} and \tn{MakePerPage{footnote}} command.
% \item[\normalfont\textsf{pfnote}] Replace with option \texttt{perpage}. You could also
% use package \textsf{perpage} and \tn{MakePerPage{footnote}} command.
% \item[\normalfont\textsf{fnpara}] Replace with option \texttt{para}.
% \item[\normalfont\textsf{fnpos}] Replace with option \texttt{bottom}.
% \end{description}
% \StopEventually{}
%
% \section{Code: Preliminaries}
%
% Well~--- here we go: let's make the package file:
%
% \begin{macrocode}
%<*driver|package>
% \end{macrocode}
%
% Enable lt3docstrip stripping
% \begin{macrocode}
%<@@=footmisx>
% \end{macrocode}
%
% \subsection{Error messages}
%
% Here we define some error messages:
% \begin{macrocode}
\ExplSyntaxOn
\msg_new:nnn {footmisx} {not expected definition}
{The~macro~#1~is~not~defined~as~expected.\\
The~macro~#1~could~not~be~modified~by~footmisx.\\
Please~report~a~bug. \\
Get:\\
#2\\
Expect:\\
#3\\
}
\msg_new:nnn {footmisx} {too old}
{The~package~#1~is~too~old~and~thus~not~supported.\\
Please~install~a~newer~version~(at~least~version~#2)}
\msg_new:nnn {footmisx} {incompatible}
{The~package~#1~is~incompatible~with~footmisx.\\
Use~the~following~workarround~#2}
% \end{macrocode}
%
% \subsection{Check package loaded and package version}
%
% \subsubsection{Helpers}
%
% Protect against too old package by checking version if package is loaded.
% \begin{function}{\__@@_error_if_too_old:NN}
% \begin{syntax}
% \cs{__@@_error_if_too_old:NN} \Arg{package} \Arg{version}
% \end{syntax}
% Check minimal version and raise an error in case of too old.
% \begin{macrocode}
\cs_new_nopar:Nn \__@@_error_if_too_old:NN {
\AtBeginDocument{
\ExplSyntaxOn
\@ifpackageloaded{#1}{
\@ifpackagelater{#1}{#2}{}
{\msg_error:nnnn{footmisx}{too old}{#1}{#2}}
}{}
\ExplSyntaxOff
}
}
% \end{macrocode}
% \end{function}
% Protect against incompatible package.
% \begin{function}{\__@@_error_if_incompatible:NN}
% \begin{syntax}
% \cs{__@@_error_if_incompatible:NN} \Arg{package} \Arg{version}
% \end{syntax}
% Check minimal version and raise an error in case of too old.
% \begin{macrocode}
\cs_new_nopar:Nn \__@@_error_if_incompatible:NN {
\@ifpackageloaded{#1}{
\msg_error:nnnn{footmisx}{incompatible}{#1}{#2}
}{}
\AtBeginOfPackageFile{#1}{
\msg_error:nnnn{footmisx}{incompatible}{#1}{#2}
}
\AtBeginDocument{
\ExplSyntaxOn
\@ifpackageloaded{#1}{
\msg_error:nnnn{footmisx}{incompatible}{#1}{#2}
}{}
\ExplSyntaxOff
}
}
% \end{macrocode}
% \end{function}
%
% \subsubsection{Checks}
%
% Check now some minimal supported version
% \begin{macrocode}
\__@@_error_if_too_old:NN{hyperref}{2016/06/24}
\__@@_error_if_too_old:NN{setspace}{2011/12/19}
\__@@_error_if_incompatible:NN{footnpag}{Use footmisx with option perpage}
\__@@_error_if_incompatible:NN{pagefoots}{Use footmisx with option perpage}
\__@@_error_if_incompatible:NN{pfnotes}{Use footmisx with option perpage}
\__@@_error_if_incompatible:NN{fnpara}{Use footmisx with option para}
\__@@_error_if_incompatible:NN{fnpos}{Use footmisx with option bottom}
% \end{macrocode}
%
% \subsection{Check definition}
%
% \subsubsection{Helper}
%
% We check definition of some overwriten function. Protect against too recent package.
% \begin{function}{\__@@msg_if_neq:NNc}
% \begin{syntax}
% \cs{__@@msg_if_neq:NNc} \Arg{sequence_1} \Arg{sequence_2} \marg{csname}
% \end{syntax}
% Compare \Arg{sequence_1} and \Arg{sequence_2}. Call \marg{csname} if not
% equal in \cs{cs_if_eq:NNTF} sense.
%
% \marg{csname} should be a \cs{foo:nnxxx} function like \cs[module=l3basics]{msg_critical:nnxxx}
% \begin{macrocode}
\cs_new:Npn \__@@_msg_if_neq:NNc #1#2#3 {
\cs_if_eq:NNTF {#1} {#2} {}
{\use:c{#3}
{footmisx}
{not expected definition}
{\exp_not:N #1}
{\exp_not:N {\cs_meaning:N #1}}
{\exp_not:N {\cs_meaning:N #2}}
}
}
% \end{macrocode}
% \end{function}
% \begin{function}{\__@@_fatal_if_neq:NN}
% \begin{syntax}
% \cs{__@@_fatal_if_neq:NN} \Arg{sequence_1} \Arg{sequence_2}
% \end{syntax}
% Compare \Arg{sequence_1} and \Arg{sequence_2}. Call \cs[module=l3basics]{msg_fatal:nnxxx} if not
% equal in \cs{cs_if_eq:NNTF} sense.
% \begin{macrocode}
\cs_new:Nn \__@@_fatal_if_neq:NN {
\__@@_msg_if_neq:NNc {#1} {#2} {msg_fatal:nnxxx}
}
% \end{macrocode}
% \end{function}
% \begin{function}{\__@@_critical_if_neq:NN}
% \begin{syntax}
% \cs{__@@_critical_if_neq:NN} \Arg{sequence_1} \Arg{sequence_2}
% \end{syntax}
% Compare \Arg{sequence_1} and \Arg{sequence_2}. Call \cs[module=l3basics]{msg_critical:nnxxx} if not
% equal in \cs{cs_if_eq:NNTF} sense.
% \begin{macrocode}
\cs_new:Nn \__@@_critical_if_neq:NN {
\__@@_msg_if_neq:NNc {#1} {#2} {msg_critical:nnxxx}
}
% \end{macrocode}
% \end{function}
% \begin{function}{\__@@error_if_neq:NN}
% \begin{syntax}
% \cs{__@@error_if_neq:NN} \Arg{sequence_1} \Arg{sequence_2}
% \end{syntax}
% Compare \Arg{sequence_1} and \Arg{sequence_2}. Call \cs[module=l3basics]{msg_error:nnxxx} if not
% equal in \cs{cs_if_eq:NNTF} sense.
% \begin{macrocode}
\cs_new:Nn \__@@error_if_neq:NN {
\__@@_msg_if_neq:NNc {#1} {#2} {msg_error:nnxxx}
}
% \end{macrocode}
% \end{function}
% \begin{function}{\__@@_warning_if_neq:NN}
% \begin{syntax}
% \cs{__@@_warning_if_neq:NN} \Arg{sequence_1} \Arg{sequence_2}
% \end{syntax}
% Compare \Arg{sequence_1} and \Arg{sequence_2}. Call \cs[module=l3basics]{msg_warning:nnxxx} if not
% equal in \cs{cs_if_eq:NNTF} sense.
% \begin{macrocode}
\cs_new:Nn \__@@_warning_if_neq:NN {
\__@@_msg_if_neq:NNc {#1} {#2} {msg_warning:nnxxx}
}
% \end{macrocode}
% \end{function}
% \begin{function}{\@@_note_if_neq:NN}
% \begin{syntax}
% \cs{@@_note_if_neq:NN} \Arg{sequence_1} \Arg{sequence_2}
% \end{syntax}
% Compare \Arg{sequence_1} and \Arg{sequence_2}. Call \cs[module=l3basics]{msg_note:nnxxx} if not
% equal in \cs{cs_if_eq:NNTF} sense.
% \begin{macrocode}
\cs_new:Nn \__@@_note_if_neq:NN {
\__@@_msg_if_neq:NNc {#1} {#2} {msg_note:nnxxx}
}
% \end{macrocode}
% \end{function}
% \begin{function}{\__@@_log_if_neq:NN}
% \begin{syntax}
% \cs{__@@_log_if_neq:NN} \Arg{sequence_1} \Arg{sequence_2}
% \end{syntax}
% Compare \Arg{sequence_1} and \Arg{sequence_2}. Call \cs[module=l3basics]{msg_log:nnxxx} if not
% equal in \cs{cs_if_eq:NNTF} sense.
% \begin{macrocode}
\cs_new:Nn \__@@_log_if_neq:NN {
\__@@_msg_if_neq:NNc {#1} {#2} {msg_log:nnxxx}
}
% \end{macrocode}
% \end{function}
%
% \subsubsection{Checks}
%
% Now we check if \tn{@makefnmark} has been modified. Do it between group in
% order to not pollute namespace.
%
% \begin{macrocode}
\group_begin:
\def\__@@_copy_@makefnmark{\hbox{\@textsuperscript{\normalfont\@thefnmark}}}
\__@@_warning_if_neq:NN {\@makefnmark} {\__@@_copy_@makefnmark}
\group_end:
% \end{macrocode}
%
% Now we check if \tn{@footnotemark} has been modified. Do it between group in
% order to not pollute namespace.
% \begin{macrocode}
\group_begin:
\@ifpackageloaded{hyperref}
%%hyperef case
{
\def\__@@_copy_@footnotemark{%
\leavevmode
\ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
\stepcounter{Hfootnote}%
\global\let\Hy@saved@currentHref\@currentHref
\hyper@makecurrent{Hfootnote}%
\global\let\Hy@footnote@currentHref\@currentHref
\global\let\@currentHref\Hy@saved@currentHref
\hyper@linkstart{link}{\Hy@footnote@currentHref}%
\@makefnmark
\hyper@linkend
\ifhmode\spacefactor\@x@sf\fi
\relax
}%
}
%% latex case
{
\def\__@@_copy_@footnotemark{
\leavevmode
\ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
\@makefnmark
\ifhmode\spacefactor\@x@sf\fi
\relax
}
}
\__@@error_if_neq:NN {\@footnotemark} {\__@@_copy_@footnotemark}
\group_end:
% \end{macrocode}
% Now we check if \tn{footnotemark} has been modified. Do it between group in
% order to not pollute namespace.
% \begin{macrocode}
\group_begin:
\def\__@@_copy_footnotemark{\@ifnextchar [%]
\@xfootnotemark
{%
\stepcounter{footnote}%
\protected@xdef\@thefnmark{\thefootnote}%
\@footnotemark
}%
}
\__@@error_if_neq:NN {\footnotemark} {\__@@_copy_footnotemark}
\group_end:
% \end{macrocode}
%
% \subsection{Load hook now and at end of some package}
%
% \begin{function}{\__@@_AtEndOfPackageFile_and_now:NN}
% \begin{syntax}
% \cs{__@@_AtEndOfPackageFile_and_now:NN} \Arg{package} \Arg{code}
% \end{syntax}
% Run \Arg{code} now and at end of package \Arg{package}.
% \begin{macrocode}
\cs_new:Npn \__@@_AtEndOfPackageFile_and_now:NN #1#2 {
#2
\AtEndOfPackageFile{#1}{#2}
}
% \end{macrocode}
% \end{function}
%
% \subsection{Disable patching in some package}
%
% \begin{function}{\__@@_disablepatchinginpackage:cN}
% \begin{syntax}
% \cs{__@@_disablepatchinginpackage:cN} \Arg{function} \Arg{package}
% \end{syntax}
% Save function at beginning of package and restore at end.
% Create two global token list:
% \begin{itemize}
% \item \cs{@@_save_function@package_tl} that save \marg{function} to
% \cs{\@@_saved_function@package_tl}.
% \item \cs{@@_save_function@package_tl} that restore \marg{function} from
% \cs{\@@_saved_function@package_tl}.
% \end{itemize}
% \begin{macrocode}
\cs_new:Npn \__@@_disablepatchinginpackage:cN #1#2 {
\tl_const:cn {@@_save_ #1 @ #2 _tl}{
\cs_gset_eq:cc {@@_saved_ #1 @ #2 _tl} {#1}
}
\tl_const:cn {@@_restore_ #1 @ #2 _tl}{
\cs_gset_eq:cc {#1} {@@_saved_ #1 @ #2 _tl}
}
\AtBeginOfPackageFile{#2}{\use:c{@@_save_ #1 @ #2 _tl}}
\AtEndOfPackageFile{#2}{\use:c{@@_restore_ #1 @ #2 _tl}}
}
% \end{macrocode}
% \end{function}
%
% \subsection{Generalities}
%
% We save a private macro using csname in order to use lt3doc
% \begin{macrocode}
\cs_set_eq:cc {@@_par} {@ @ par}
\ExplSyntaxOff
% \end{macrocode}
% We need a token register in case we have to patch \cs{@makecol}:
% \begin{macrocode}
\newtoks\FN@temptoken
% \end{macrocode}
%
% \begin{macro}{\protected@writeaux}
% This command is defined for future compatibility with Matt Swift's
% \textsf{newclude} package (still, after all this time, not out of
% beta status).
% \begin{macrocode}
\providecommand\protected@writeaux{%
\protected@write\@auxout
}% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\footnotemargin}
% Finally, we define the length used by the \texttt{marginal} option,
% and initialise it as if we've not had the option.
% \begin{macrocode}
\newdimen\footnotemargin
\footnotemargin1.8em\relax
% \end{macrocode}
% \end{macro}
%
% \section{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
% \cs{ProcessOptions} as a result of flags set in the option
% processing).
%
% \subsection{The \texttt{symbol} option}
%
% This is a declaration that appears in the original \LaTeX{} book.
% Since it appeared in the old |pagefoots.sty| (presumably since it
% goes so naturally with the |perpage| option), I've added this
% trivial piece of customisation to the package.
%
% \begin{macrocode}
\DeclareOption{symbol}{\renewcommand\thefootnote{\fnsymbol{footnote}}}
% \end{macrocode}
%
% \subsection{The \texttt{symbol*} option}
%
% The robust version of the \texttt{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~\ref{footnote-symbols}).
% \begin{macrocode}
\DeclareOption{symbol*}{%
\renewcommand\thefootnote{\@fnsymbol\c@footnote}%
\AtEndOfPackage{\setfnsymbol{lamport*-robust}}%
}
% \end{macrocode}
%
% \subsection{The \texttt{para} option}
%
% The basis of the code for this option comes from \TeX{}book, p.398
% ff.~(``Dirty Tricks''), though it does (of course) avoid
% redefining |\\| which has some other (somewhat significant) uses in
% \LaTeX{}! The user should be aware of
% Knuth's note on the limitations of this method of doing the job: the
% \TeX{} stack is used four times per footnote, and the stack is
% limited (see the \TeX{}book, p.300 ff.). If you have very large
% numbers of footnotes (in the hundreds), and encounter the error
% ``|! TeX capacity exceeded, sorry (... save size ...)|'', you may
% need to break your text into smaller sections and compile the
% separately. Fortunately (say the comments on the original
% |fnpara.sty|) this is very easy to do with \LaTeX{}, provided that
% you reset the footnote counter to make the joins seamless.
%
% \begin{macro}{\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.
% \begin{macrocode}
\newif\ifFN@para \FN@parafalse
\DeclareOption{para}{\ifFN@sidefn
\PackageError{footmisx}{Option "\CurrentOption" incompatible with
option "side"}%
{I shall ignore "\CurrentOption"}%
\else
\FN@paratrue
\fi
}
% \end{macrocode}
% \end{macro}
%
% \subsection{The \texttt{side} option}
%
% \begin{macro}{\ifFN@sidefn}
% Simply changes the behaviour of \cs{@footnotetext}; incompatible
% with paragraph footnotes.
% \begin{macrocode}
\newif\ifFN@sidefn \FN@sidefnfalse
\DeclareOption{side}{\ifFN@para
\PackageError{footmisx}{Option "\CurrentOption" incompatible with
option "para"}%
{I shall ignore "\CurrentOption"}%
\else
\FN@sidefntrue
\fi
}
% \end{macrocode}
% \end{macro}
%
% \subsection{The \texttt{ragged} option}
%
% \begin{macro}{\footnotelayout}
% A very simple option that merely changes the definition of one
% macro. Note detection of the presence of the \textsf{ragged2e}
% package.
% \begin{macrocode}
\let\footnotelayout\@empty
\DeclareOption{ragged}{%
\@ifundefined{RaggedRight}%
{\renewcommand\footnotelayout{\linepenalty50 \raggedright}}%
{\renewcommand\footnotelayout{\linepenalty50 \RaggedRight}}%
}
% \end{macrocode}
% \end{macro}
%
% \subsection{The \texttt{perpage} option}
%
% \begin{macro}{\ifFN@perpage}
% A footnote-numbering modification: a new algorithm replacing one
% from Brian T. Schellenberger, which has proved to be flawed. We
% simply set a marker here, and define code later depending on the
% state of the marker (see section \ref{sec:perpage-code}).
% \begin{macrocode}
\newif\ifFN@perpage
\FN@perpagefalse
\DeclareOption{perpage}{%
\FN@perpagetrue
}
% \end{macrocode}
% \end{macro}
%
% \subsection{The \texttt{bottom} option}
%
% \begin{macro}{\ifFN@bottom}
% All this needs to do is to set a flag to say that it should happen
% \begin{macrocode}
\newif\ifFN@bottom \FN@bottomfalse
\DeclareOption{bottom}{%
\FN@bottomtrue
}
% \end{macrocode}
% \end{macro}
%
% \subsection{The \texttt{marginal} option}
%
% Again, the processing of the option is pretty trivial:
% \begin{macrocode}
\DeclareOption{marginal}{%
\footnotemargin-0.8em\relax
}
% \end{macrocode}
%
% \subsection{The \texttt{flushmargin} option}
%
% Again, the processing of the option is pretty trivial:
% \begin{macrocode}
\DeclareOption{flushmargin}{%
\footnotemargin0pt\relax
}
% \end{macrocode}
%
% \subsection{The \texttt{hang} option}
%
% \begin{macro}{\ifFN@hangfoot}
% We need a switch, since \cs{@makefntext} needs to be patched.
% \begin{macrocode}
\newif\ifFN@hangfoot \FN@hangfootfalse
\DeclareOption{hang}{%