summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/fn2end/fn2end.sty
blob: c8ed8478ac7a58f27126413f83b9009f750c82f4 (plain)
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
%  fn2end.sty	Convert footnotes into end notes.
%  LaTeXable documentation at end (after \endinput)
%  LaTeX 2.09 users, should comment out this line:
\ProvidesPackage{fn2end}[1995/05/31 Convert footnotes into end notes.]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file may be freely copied, and distributed.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Author:
% Kim C. Border, 
% Division of the Humanities and Social Sciences,
% Caltech, Pasadena, CA 91125 USA
% e-mail: kcb@hss.caltech.edu

% I gratefully acknowledge the help of J. E. Burke
% <jeburke@jhuvms.hcf.jhu.edu>  at Johns Hopkins, who fixed
% the handling of long footnotes.  
% The main idea is from Knuth's \answer macro in the TeXbook.

% version 1.1, May 31, 1995
% Changed \endnoteshere to \theendnotes, since you
% shouldn't use commands that begin with \end
% Also added user renewable parameters

% Based on my old endnotes.sty, version 3
% (Sep 4, 1990, rev. Jul 28, 1994), which was never posted.
% It appears to work with both LaTeX2e and LaTeX2.09

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% User redefinable parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newlength{\noteskip}
\setlength{\noteskip}{1em}
\newcommand{\notenumberformat}[1]{$#1$}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Save the original definition of \@footnotetext
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\let\original@footnotetext\@footnotetext


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define \makeendnotes to open a new file 
% for the endnotes and to redefine \@footnotetext
% (\newlinechar courtesy of J E Burke)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\makeendnotes}{\newwrite\n@tefile
  \immediate\openout\n@tefile=\jobname.end
  \immediate\write\n@tefile{\relax}
  \long\gdef\@footnotetext{\immediate\write\n@tefile{}
	\begingroup\newlinechar=`\^^M 
  \catcode`\^^M=12\@setupcopy\@copynote}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The verbatim copying definitions
% based on the TeXbook's \answer macro
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\@setupcopy}{\@sanitize}
\newcommand{\@copynote}{}
\long\gdef\@copynote#1{%
	\immediate\write\n@tefile{\notenumberformat{\@thefnmark}%
		\hskip\noteskip}%
	\immediate\write\n@tefile{#1}\endgroup}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define \theendnotes to retrieve them
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\theendnotes}{\immediate\closeout\n@tefile
    \input\jobname.end\relax}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define \restorefootnotes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\restorefootnotes}{\long\gdef\@footnotetext{\original@footnotetext}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\endinput