summaryrefslogtreecommitdiff
path: root/macros/generic/misc/endnote.tex
blob: 6ca4cd8df93538c7eaa27f79ab6b289ed092436c (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
% Use \endnote{1}{text}. At the end of your document, type
% \producenotes to actually flush all end notes to be printed.
%
% macros for making endnotes instead of footnotes
% We make @ signs act like letters, temporarily, to avoid conflict
% between user names and internal control sequences of plain format.
\catcode`@=11
\newbox\endnotebox
\def\setendnotefont#1{\gdef\endnotefont{#1}}
\setendnotefont{\rm}
\def\endnote#1{\let\@sf\empty
  \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  #1\@sf\vendnote{{#1}}}
\def\vendnote#1{\global\setbox\endnotebox=
   \vbox{\parindent=0pt\endnotefont\unvbox\endnotebox\bgroup
   \indent\llap#1\ignorespaces\futurelet\next\aftergroup\no@te\relax}}
\def\no@te{\ifcat\bgroup\noexpand\next \let\next\n@@te
  \else\let\next\n@t\fi \next}
\def\n@@te{\bgroup\aftergroup\@endnote\let\next}
\def\n@t#1{#1\@endnote}
\def\@endnote{\strut\egroup}
%
\newcount\enotecounter
\def\resetenotecount{\global\enotecounter=0 } \resetenotecount
\def\setenotecount#1{\global\enotecounter=#1 }
%
\def\setendnoteflagfont#1{\gdef\endnoteflagfont{#1}}
\setendnoteflagfont{\sevenrm}
\def\enote{\unskip
  \global\advance \enotecounter by 1  % First bump the counter.
  % Now convert the current value of the counter into a superscripted numeral
  \endnote{{$^{\hbox{\endnoteflagfont\the\enotecounter}}$}}}
%
\def\producenotes{%
\ifvoid\endnotebox\else\medskip\unvbox\endnotebox\par\fi}
\catcode`@=12 % at signs are no longer letters