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
|
% -*- coding: utf-8; time-stamp-format: "%02d-%02m-%:y at %02H:%02M:%02S %Z" -*-
%<*none>
\def\dtxtimestamp {Time-stamp: <21-04-2016 at 11:40:54 CEST>}
%</none>
%<*!readme>
%%
%% Package: footnotehyper
%% Version: 0.9d (2016/04/21)
%% License: LPPL 1.3c
%% Copyright (C) 2016 Jean-Francois Burnol <jfbu at free dot fr>.
%%
%</!readme>
%<*insfile|tex>
\def\pkgname {footnotehyper}
\def\pkgdate {2016/04/21}
\def\docdate {2016/04/21}
\def\pkgversion {v0.9d}
\def\pkgdescription {hyperref aware footnote.sty (JFB)}
%</insfile|tex>
%<*none>
% Definition of \pkgLicense
\begingroup% cette méthode ne marcherait pas avec caractères en dehors de 32-127
\long\def\firstofone #1{#1}\catcode1=14\catcode2=0
\catcode`\%=12\catcode`\_=12\endlinechar13\catcode13=13 ^^A
\catcode32=13\catcode`\\=12^^Brelax^^A
^^Bfirstofone{^^Bendgroup^^Bdef^^BpkgLicense^^A
{% Package: footnotehyper
% Version: 0.9d (2016/04/21)
% License: LPPL 1.3c
% Copyright (C) 2016 Jean-Francois Burnol <jfbu at free dot fr>.
%
% This Work may be distributed and/or modified under the conditions
% of the LaTeX Project Public License, version 1.3c. This version of
% this license is in:
%
% > <http://www.latex-project.org/lppl/lppl-1-3c.txt>
%
% and the latest version of this license is in:
%
% > <http://www.latex-project.org/lppl.txt>
%
% Version 1.3 or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% The Author of this Work is: Jean-Francois Burnol `<jfbu at free dot fr>`
%
% This Work consists of the main source file footnotehyper.dtx and the
% derived files footnotehyper.sty, footnotehyper.ins, footnotehyper.tex,
% footnotehyper.pdf, footnotehyper.dvi.
}}%
\begingroup\catcode1 0 \catcode`\\ 12
^^Aiffalse
%</none>
%<*readme>
<!-- -->
Source: footnotehyper.dtx (v0.9d 2016/04/21)
Author: Jean-Francois Burnol
Info: hyperref aware footnote.sty
License: LPPL 1.3c or later
Copyright (C) 2016 Jean-Francois Burnol <jfbu at free dot fr>.
ABSTRACT
========
The `footnote` package by Mark Wooding dates back to 1997 and has
not been made `hyperref` compatible. The aim of the present
package is to do that. It is barely tested and its state is what I
found sufficiently well-working on a current LaTeX document of
mine.
For those who don't know: the `footnote` package allows via
`\savenotes` to gather footnotes and later release them via
`\spewnotes` (one can also use a `savenotes` environment.)
Thus footnotes emitted from tabulars or minipages
are not separated from the general document stream of footnotes,
and are printed with the others at bottom of page. This works also
for environments like `framed` (1) from the eponymous package and
avoids the `\footnotemark/\footnotetext` approach, which anyhow is
not immediately `hyperref` compatible. The `footnote` package has
a facility to patch any user-chosen environment to do the
`\savenotes/\spewnotes` automatically.
This package provides no facility for handling footnotes from floating
environments.
Some issues from `footnote.sty` made it incompatible with the
`color` and `xcolor` packages; this is corrected by `footnotehyper`. The
compatibility with `babel-frenchb` is improved, too.
The loading of `hyperref` (either before or after) is mandatory
but left to the user.
(1): in case of multi-page content, the footnotes are delivered in
the last page.
INSTALLATION
============
To extract the package (.sty) and driver (.tex) files from
footnotehyper.dtx:
- if footnotehyper.ins is present: etex footnotehyper.ins
- without footnotehyper.ins: etex footnotehyper.dtx
- or run latex or pdflatex directly on footnotehyper.dtx
At least three ways to produce footnotehyper.pdf (method (1) is
preferred):
1. latex footnotehyper.tex (thrice), then dvipdfmx
2. pdflatex footnotehyper.dtx (thrice)
3. latex footnotehyper.dtx (thrice), then dvips, then ps2pdf
Method (1) produces the smallest pdf files.
Options can be set in footnotehyper.tex:
- scrdoc class options (paper size, font size, ...)
- with or without source code,
- with dvipdfmx or with latex+dvips or pdflatex.
Installation:
footnotehyper.sty -> TDS:tex/latex/footnotehyper/footnotehyper.sty
footnotehyper.dtx -> TDS:source/latex/footnotehyper/footnotehyper.dtx
footnotehyper.pdf -> TDS:doc/latex/footnotehyper/footnotehyper.pdf
README.md -> TDS:doc/latex/footnotehyper/README.md
The other files may be discarded.
LICENSE
=======
This Work may be distributed and/or modified under the conditions
of the LaTeX Project Public License, version 1.3c. This version of
this license is in:
> <http://www.latex-project.org/lppl/lppl-1-3c.txt>
and the latest version of this license is in:
> <http://www.latex-project.org/lppl.txt>
Version 1.3 or later is part of all distributions of
LaTeX version 2005/12/01 or later.
The Author of this Work is:
- Jean-Francois Burnol `<jfbu at free dot fr>`
This Work consists of the main source file footnotehyper.dtx and the
derived files footnotehyper.sty, footnotehyper.ins, footnotehyper.tex,
footnotehyper.pdf, footnotehyper.dvi.
%</readme>
%<*tex>-------------------------------------------------------------------------
%%
%% run latex thrice on this file footnotehyper.tex then dvipdfmx on
%% footnotehyper.dvi to produce the documentation footnotehyper.pdf, with
%% source code included.
%%
\chardef\Withdvipdfmx 1 % replace 1 by 0 for using latex+dvips or pdflatex
\chardef\NoSourceCode 0 % replace 0 by 1 for the doc *without* the source code
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile {\pkgname.tex}[Driver for \pkgname\space documentation]%
\PassOptionsToClass {a4paper,fontsize=11pt,oneside}{scrdoc}
\PassOptionsToPackage {english}{babel}
\input \pkgname.dtx
%%% Local Variables:
%%% mode: latex
%%% End:
%</tex>-------------------------------------------------------------------------
%<*insfile>---------------------------------------------------------------------
%%
%% Run etex on this file to extract from footnotehyper.dtx:
%% footnotehyper.sty, footnotehyper.tex, and README.md
%%
%% Refer to README.md for installation instructions, if needed.
%%
\input docstrip.tex
\askforoverwritefalse
\def\pkgpreamble{\defaultpreamble^^J\MetaPrefix^^J%
\string\NeedsTeXFormat{LaTeX2e}^^J%
\string\ProvidesPackage{\pkgname}\perCent^^J%
\space[\pkgdate\space\pkgversion\space\pkgdescription]}%
\generate{\nopreamble\nopostamble
\file{README.md}{\from{\pkgname.dtx}{readme}}%
\usepostamble\defaultpostamble
\file{\pkgname.tex}{\from{\pkgname.dtx}{tex}}%
\usepreamble\pkgpreamble
\file{\pkgname.sty}{\from{\pkgname.dtx}{package}}}%
\catcode32=13\relax% active space
\let =\space%
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{* \pkgname.sty}
\Msg{*}
\Msg{* To produce the documentation run latex thrice on file \pkgname.tex}
\Msg{* and then run dvipdfmx on file \pkgname.dvi.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}
\ifx\numexpr\undefined
\Msg{* warning: to get correct utf-8 encoded README.md}%
\Msg{* do 'etex \pkgname.ins' and not 'tex \pkgname.ins'}%
\Msg{************************************************************************}
\fi
\endbatchfile
%</insfile>---------------------------------------------------------------------
%<*none>------------------------------------------------------------------------
^^Afi^^Aendgroup
%
\chardef\noetex 0
\ifx\numexpr\undefined\chardef\noetex 1 \fi
\ifnum\noetex=1 \chardef\extractfiles 0 % extract files, then stop
\else
\ifx\ProvidesFile\undefined
\chardef\extractfiles 0 % etex etc.. on \pkgname.dtx, only file extraction.
\else % latex/pdflatex on \pkgname.tex or on \pkgname.dtx
\ifx\Withdvipdfmx\undefined
% latex/pdflatex run is on \pkgname.dtx
\chardef\extractfiles 1 % 1 = extract files and typeset manual, 2 = only typeset
\chardef\Withdvipdfmx 0 % 0 = pdflatex or latex+dvips, 1 = dvipdfmx
\chardef\NoSourceCode 0 % 0 = include source code, 1 = do not
\NeedsTeXFormat {LaTeX2e}%
\PassOptionsToClass {a4paper,fontsize=11pt,oneside}{scrdoc}%
\PassOptionsToPackage {english}{babel}%
\else % latex run is on \pkgname.tex
\chardef\extractfiles 2 % do not extract files, only typeset
\fi
\ProvidesFile{\pkgname.dtx}%
[\pkgname\space source and documentation (\dtxtimestamp)]%
\fi
\fi
\ifnum\extractfiles<2 % extract files
\def\MessageDeFin{\newlinechar10 \let\Msg\message
\Msg{********************************************************************^^J}%
\Msg{*^^J}%
\Msg{* To finish the installation you have to move the following^^J}%
\Msg{* file into a directory searched by TeX:^^J}%
\Msg{*^^J}%
\Msg{*\space\space\space\space \pkgname.sty^^J}%
\Msg{*^^J}%
\Msg{* To produce the documentation with source code included run latex^^J}%
\Msg{* thrice on file \pkgname.tex and then dvipdfmx on \pkgname.dvi^^J}%
\Msg{*^^J}%
\Msg{* Happy TeXing!^^J}%
\Msg{*^^J}%
\Msg{********************************************************************^^J}%
}%
\begingroup
\input docstrip.tex
\askforoverwritefalse
\def\pkgpreamble{\defaultpreamble^^J\MetaPrefix^^J%
\string\NeedsTeXFormat{LaTeX2e}^^J%
\string\ProvidesPackage{\pkgname}\perCent^^J%
\space[\pkgdate\space\pkgversion\space\pkgdescription]}%
\generate{\nopreamble\nopostamble
\file{README.md}{\from{\pkgname.dtx}{readme}}%
\usepostamble\defaultpostamble
\file{\pkgname.ins}{\from{\pkgname.dtx}{insfile}}%
\file{\pkgname.tex}{\from{\pkgname.dtx}{tex}}%
\usepreamble\pkgpreamble
\file{\pkgname.sty}{\from{\pkgname.dtx}{package}}}%
\endgroup
\fi % end of file extraction (from etex/latex/pdflatex run on \pkgname.dtx)
\ifnum\noetex=1 % warning for README.md
\expandafter\def\expandafter\MessageDeFin\expandafter
{\MessageDeFin
\Msg{* warning: to get correct utf-8 encoded README.md ^^J}%
\Msg{* do 'etex \pkgname.dtx' and not 'tex \pkgname.dtx' ^^J}%
\Msg{********************************************************************^^J}}%
\fi
\ifnum\extractfiles=0 % tex/etex/xetex/etc on \pkgname.dtx, files extracted, stop
\MessageDeFin\expandafter\end
\fi
% From this point on, run is necessarily with e-TeX.
% Check if \MessageDeFin got defined, if yes put it at end of run.
\ifdefined\MessageDeFin\AtEndDocument{\MessageDeFin}\fi
%-------------------------------------------------------------------------------
% START OF USER MANUAL TEX SOURCE
\documentclass[abstract]{scrdoc}
\ifnum\NoSourceCode=1 \OnlyDescription\fi
\usepackage{ifpdf}
\ifpdf\chardef\Withdvipdfmx 0 \fi
\makeatletter
\ifnum\Withdvipdfmx=1
\@for\@tempa:=hyperref,bookmark,graphicx,xcolor,pict2e\do
{\PassOptionsToPackage{dvipdfmx}\@tempa}
%
\PassOptionsToPackage{dvipdfm}{geometry}
\PassOptionsToPackage{bookmarks=true}{hyperref}
\PassOptionsToPackage{dvipdfmx-outline-open}{hyperref}
\PassOptionsToPackage{dvipdfmx-outline-open}{bookmark}
%
\def\pgfsysdriver{pgfsys-dvipdfm.def}
\else
\PassOptionsToPackage{bookmarks=true}{hyperref}
\fi
\makeatother
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage {babel}
\usepackage[hscale=0.72,vscale=0.7]{geometry}
\def\MacroFont{\ttfamily\small\hyphenchar\font45 \baselineskip11pt\relax}
\usepackage{amsmath}
\usepackage{newtxtext, newtxmath}
\usepackage[straightquotes, scaled=0.97]{newtxtt}
\usepackage{xspace}
\usepackage[dvipsnames]{xcolor}
\definecolor{joli}{RGB}{225,95,0}
\definecolor{JOLI}{RGB}{225,95,0}
\definecolor{BLUE}{RGB}{0,0,255}
\colorlet{niceone}{green!35!blue!75}
\usepackage{framed}
\usepackage[pdfencoding=pdfdoc]{hyperref}
\hypersetup{%
linktoc=all,%
breaklinks=true,%
colorlinks,%
linkcolor=RoyalBlue,%
urlcolor=OliveGreen,%
pdfauthor={Jean-Fran\c cois Burnol},%
pdftitle={The \pkgname\space package},%
pdfsubject={\pkgdescription},%
pdfkeywords={LaTeX, footnotes},%
pdfstartview=FitH,%
pdfpagemode=UseNone}
% added usage of package bookmark 2013/10/10
\usepackage{bookmark}
\usepackage{\pkgname}
\newcommand\fnh{%
\texorpdfstring{{\color{joli}\ttfamily\bfseries \pkgname}}{\pkgname}\xspace}
\frenchspacing
\renewcommand\familydefault\sfdefault
\pagestyle{headings}
\begin{document}\thispagestyle{empty}
% the \MacroFont valid at begin document will be the one used in Implementation
% the one defined here will be used by verbatim (not by \verb)
\def\MacroFont{\ttfamily\small}
\rmfamily
\bookmark[named=FirstPage,level=1]{Title page}
\begin{center}
{\normalfont\LARGE The \fnh package}\\
\textsc{\small Jean-François Burnol}\par
\footnotesize \ttfamily
jfbu (at) free (dot) fr\par
Package version: \pkgversion\ (\pkgdate)\par
From source file \texttt{\pkgname.dtx} of \dtxtimestamp.\par
\end{center}
\MakeShortVerb{\`}% global effect !
\begin{abstract}
The `footnote` package by \textsc{Mark Wooding} dates back to 1997 and
has not been made `hyperref` compatible. The aim of the present
package is to do that. It is barely tested and its state is what
I found sufficiently well-working on a current LaTeX document of
mine.
For those who don't know: the `footnote` package allows via
`\savenotes` to gather footnotes and later release them via
`\spewnotes` (one can also use a `savenotes` environment.) Thus
footnotes emitted from tabulars or minipages are not separated
from the general document stream of footnotes, and are printed
with the others at bottom of page. This works also for
environments like `framed`%
%
%\footnote
\space({in case of multi-page content, the footnotes are delivered in the last
page})
%
from the eponymous package and avoids the `\footnotemark/\footnotetext`
approach, which anyhow is not immediately `hyperref` compatible. The
`footnote` package has a facility to patch any user-chosen environment to
do the `\savenotes/\spewnotes` automatically.
Some issues from `footnote.sty` made it incompatible with the
`color` and `xcolor` packages; this is corrected by \fnh. The
compatibility with `babel-frenchb` has been improved, too.
The loading of `hyperref` (either before or after) is mandatory
but left to the user.
\end{abstract}
\DeleteShortVerb{\`}
\section{License}
\begingroup\ttfamily\footnotesize\hyphenchar\font -1
\parindent0pt
\obeyspaces\obeylines %
\pkgLicense\endgroup
\section{Usage}
Do \emph{not} load |footnote|, leave that job to \fnh. You \emph{must} load
|hyperref|.
Then you can use |\savenotes/\spewnotes| or the equivalent |savenotes|
environment; there is also a |footnote| environment, but its set-up during
\fnh loading is more delicate and it could well fail depending on how
|\@makefntext| has been customized by the class or other packages; a warning
is issued in that case. A functional |footnote| environment allows footnotes
with verbatim material.
\savenotes
\begin{framed}
Please refer to the documentation of the |footnote| package.%
\footnote{\url{http://ctan.org/pkg/footnote}}
Particularly you may check its |\makesavenoteenv| command.%
\footnote{This won't handle floating environments, though.}
\end{framed}
\spewnotes
We can try some normal footnote.\footnote{Here it is.}
\begin{savenotes}
\begin{framed}
\DeleteShortVerb{\|}\MakeShortVerb{\*}%
{\centering
\begin{tabular}{|c|c|}
\hline
\strut The above\footnote{Notice that if the present frame
extended to next page,
the end of the *savenotes* environment would then (try to) deliver its
footnotes to that
page.} was & coded\footnote{Alternatively a savenotes environment
could have been used.} as:\\\hline
\end{tabular}\par}
\DeleteShortVerb{\*}\MakeShortVerb{\|}%
\begin{verbatim}
\savenotes
\begin{framed}
Please refer to the documentation of the |footnote| package.%
\footnote{\url{http://ctan.org/pkg/footnote}}
Particularly you may check its |\makesavenoteenv| command.%
\footnote{This won't handle floating environments, though.}
\end{framed}
\spewnotes
\end{verbatim}
and the present frame has \cs{footnote}'s from inside a |tabular| and is
inside a |savenotes| environment.%
%
% plus maintenant, \small pour le \MacroFont utilisé par verbatim
%\footnote{Well, I end up on next page. Not
% much I can do about this, ask why to |framed.sty| and the output routine I
% guess.}
%
\footnote{Here is an issue which has nothing (as I finally figured out) to do
with |footnote|, and only indirectly with \LaTeX: if you embed a
\emph{full-width} minipage (with initial \cs{noindent}) in any environment
not doing \cs{ignorespacesafterend}, be careful to add a \% after the
minipage (or after the surrounding environment; or a \cs{par} immediately),
else the output will have an extra blank line if the source has itself a
blank line there. I hesitated adding that to
\cs{spewnotes}/\cs{endsavenotes}. Finally I left as is.} Let's test an
|amsmath| environment with |\intertext|. As
\begin{align}
E&=mc^2\;,
\intertext{was too easy,\footnote{There is also $E=h\nu$.}, let's
try:}
F&=nd^3\;.
\end{align}
\end{framed}
\end{savenotes}
Use of the \texttt{footnote} \emph{environment} with some verbatim material%
\begin{footnote}
\verb|&$^%\[}$|
\end{footnote}
which was coded as:
\begin{verbatim}
Use of the \texttt{footnote} \emph{environment} with some verbatim material%
\begin{footnote}
\verb|&$^%\[}$|
\end{footnote}
\end{verbatim}
And one more normal footnote.\footnote{You didn't want a footnote from
\emph{inside} the verbatim I hope ...}
\StopEventually{\end{document}\endinput}
\makeatletter
\let\check@percent\original@check@percent
\makeatother
%\clearpage
\section{Implementation}
\small
\makeatletter
\noindent
\begingroup
\topsep\MacrocodeTopsep
\trivlist\parskip\z@\item[]
\macro@font
\leftskip\@totalleftmargin \advance\leftskip\MacroIndent
\rightskip\z@ \parindent\z@ \parfillskip\@flushglue
\global\@newlistfalse \global\@minipagefalse
\ifcodeline@index
\everypar{\global\advance\c@CodelineNo\@ne
\llap{\theCodelineNo\ \hskip\@totalleftmargin}}%
\fi
\string\NeedsTeXFormat\string{LaTeX2e\string}\par
\string\ProvidesPackage\string{\pkgname\string}\@percentchar\par
\noindent\space [\pkgdate\space\pkgversion\space\pkgdescription]\par
\nointerlineskip
\global\@inlabelfalse
\endtrivlist
\endgroup
\makeatother
% The catcode hackery next is to avoid to have <*package> to be listed
% in the commented source code...
% (c) 2012/11/19 jf burnol ;-)
\MakePercentIgnore
%
% \catcode`\<=0 \catcode`\>=11 \catcode`\*=11 \catcode`\/=11
% \let</none>\relax
% \def<*package>{\catcode`\<=12 \catcode`\>=12 \catcode`\*=12 \catcode`\/=12}
%
%</none>
%<*package>
% \begin{macro}{no options}
% \begin{macrocode}
\DeclareOption*{\PackageWarning{footnotehyper}{Option `\CurrentOption' is unknown}}%
\ProcessOptions\relax
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@makefntext}
% \begin{macro}{\footnote}
% \begin{macro}{\footnotetext}
% We load |footnote| but leave the |hyperref| handling to the user.
%
% As we need to intercept some re-definitions done by |footnote| we will first
% check if it is already loaded.
%
% If \cs{@makefntext} has been customized and its argument is not visible at
% top level in its meaning, then loading |footnote.sty| will fail with a low
% level \TeX\ error. We save its meaning and replace it by an innocuous one
% for the time being. We will come back to this at begin document.
%
% We also postpone to at begin document the redefinitions of \cs{footnote} and
% \cs{footnotetext}.
% \begin{macrocode}
\@ifpackageloaded{footnote}
{\PackageWarning{footnotehyper}{Please next time do not load footnote,^^J
but leave that to me, that is much safer.}}
{\let\FNH@@makefntext\@makefntext\let\@makefntext\@firstofone
\RequirePackage{footnote}\relax
\let\@makefntext\FNH@@makefntext
}%
\let\FNH@fn@footnote \footnote
\let\FNH@fn@footnotetext\footnotetext
\let\footnote \fn@latex@@footnote
\let\footnotetext\fn@latex@@footnotetext
\AtBeginDocument{\@ifpackageloaded{hyperref}{}{\PackageError{footnotehyper}%
{hyperref package not loaded!^^Jhow many errors will you get ?...}%
{...I am sure you know what to do next time!}}}%
% \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% \begin{macro}{\fn@fntext}
% Some |amsmath| complications. I change the coding, but same effect as
% original.
% \begin{macrocode}
\def\fn@fntext {\ifx\ifmeasuring@\undefined\expandafter\@secondoftwo
\else\expandafter\@firstofone\fi
{\ifmeasuring@\expandafter\@gobbletwo\fi}%
\FNH@fn@fntext }%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\FNH@fn@fntext}
% Note: original \cs{fn@fntext} had no \cs{long}, which looks wrong.
%
% We do the \cs{ifHy@nesting} test although hyperref's manual
% says ``Allows links to be nested; no drivers currently support this.''
% \begin{macrocode}
\long\def\FNH@fn@fntext #1{\global\setbox\fn@notes\vbox
{\unvbox\fn@notes
\fn@startnote
\@makefntext
{\rule\z@\footnotesep\ignorespaces
\ifHy@nesting\expandafter\ltx@firstoftwo
\else\expandafter\ltx@secondoftwo
\fi
{\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}{#1}}%
{\Hy@raisedlink
{\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}%
{\relax}}%
\let\@currentHref\Hy@footnote@currentHref
\let\@currentlabelname\@empty
#1}%
\@finalstrut\strutbox }%
\fn@endnote }%
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\spewnotes}
% \begin{macro}{endsavenotes}
% The final touch in our hack is to patch the original \cs{spewnotes} for it
% to use the original, non-hyperref modified, version of \cs{@footnotetext}.
% And let's not forget \cs{endsavenotes}.
% \begin{macrocode}
\def\spewnotes {\endgroup
\if@savingnotes\else\ifvoid\fn@notes\else
\begingroup\let\@makefntext\@empty
\let\@finalstrut\@gobble
\let\rule\@gobbletwo
\H@@footnotetext{\unvbox\fn@notes}%
\endgroup\fi\fi
}%
\let\endsavenotes\spewnotes
% \end{macrocode}
% \end{macro}\end{macro}
% \begin{macro}{\fn@endfntext}
% \begin{macro}{\fn@endnote}
% We now take care of |footnote.sty|'s |footnote| environment. The original
% \cs{fn@endfntext} is lacking a \cs{fn@endnote}, and this meant that
% |footnote.sty| was incompatible with |color/xcolor| packages. Also this
% \cs{fn@endnote} was |\let| to |\color@endgroup| which is wrong.
%
% And we need our usual replacement of \cs{@footnotetext} by
% \cs{H@@footnotetext}. And this time (|v0.9d|) let's not forget the hyperlink
% target.
% \begin{macrocode}
\def\fn@endnote {\color@endgroup}%
\def\fn@endfntext{%
\@finalstrut\strutbox
\fn@postfntext
\fn@endnote
\egroup
\begingroup
\let\@makefntext\@empty
\let\@finalstrut\@gobble
\let\rule\@gobbletwo
\H@@footnotetext
{\ifHy@nesting\expandafter\ltx@firstoftwo
\else\expandafter\ltx@secondoftwo
\fi
{\expandafter\hyper@@anchor
\expandafter{\Hy@footnote@currentHref}{\unvbox\z@}}%
{\Hy@raisedlink
{\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}%
{\relax}}%
\let\@currentHref\Hy@footnote@currentHref
\let\@currentlabelname\@empty
\unvbox\z@}
}%
\endgroup
}%
\let\endfootnote \fn@endfntext
\let\endfootnotetext \endfootnote
% \end{macrocode}
% \end{macro}\end{macro}
% There are some |\let|'s done by |footnote.sty| in what appears to be
% premature ways.
% \begin{macrocode}
\AtBeginDocument {%
\let\fn@latex@@footnote \footnote
\let\fn@latex@@footnotetext\footnotetext
\let\footnote \FNH@fn@footnote
\let\footnotetext\FNH@fn@footnotetext
}%
% \end{macrocode}
% \begin{macro}{\@makefntext}
% \begin{macro}{\fn@prefntext}
% \begin{macro}{\fn@postfntext}
% The |footnote.sty|'s mechanism for setting up a |footnote| environment is
% doomed to failure if the parameter in |\@makefntext| is not visible at top
% level in its meaning. This is the case with babel-frenchb at begin
% document. It is also wrong if the parameter is used multiple times. Let's
% figure it out; and a special rescue for |footnote+babel+frenchb|... notice
% that these checks will fail (rather, they are skipped) if |footnote|'s
% loading was done by the user and not by |footnotehyper|.
% \begin{macrocode}
\ifx\FNH@@makefntext\undefined\expandafter\@gobble
\else\expandafter\AtBeginDocument\fi
{%
\ifx\@makefntextFB\undefined
\expandafter\@gobble\else\expandafter\@firstofone\fi
{\ifFBFrenchFootnotes \let\FNH@@makefntext\@makefntextFB \else
\let\FNH@@makefntext\@makefntextORI\fi}%
\expandafter\FNH@check@a\FNH@@makefntext{1.2!3?4,}\FNH@@@1.2!3?4,\FNH@@@\relax
}%
\long\def\FNH@check@a #11.2!3?4,#2\FNH@@@#3%
{%
\ifx\relax#3\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
\FNH@bad@footnote@env
{\def\fn@prefntext{#1}\def\fn@postfntext{#2}\FNH@check@b}%
}%
\def\FNH@check@b #1\relax
{%
\expandafter\expandafter\expandafter\FNH@check@c
\expandafter\meaning\expandafter\fn@prefntext
\meaning\fn@postfntext1.2!3?4,\FNH@check@c\relax
}%
\def\FNH@check@c #11.2!3?4,#2#3\relax
{\ifx\FNH@check@c#2\expandafter\@gobble\fi\FNH@bad@footnote@env}%
\def\FNH@bad@footnote@env
{%
\PackageWarning{footnotehyper}%
{The footnote environment from package footnote^^J%
will be dysfunctional, sorry (not my fault...). You may try to mail
me^^Jthe preamble and/or only the next lines:}%
\typeout{\meaning\@makefntext}%
\let\fn@prefntext\@empty\let\fn@postfntext\@empty
}%
\endinput
% \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% Let me say again I have barely tested on a few examples that it
% does at all work! One of the main tests being the present documentation\dots
% \MakePercentComment
\Finale
%%
%% End of file `footnotehyper.dtx'.
|