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
1001
1002
1003
|
% \iffalse meta-comment
%
% Copyright (C) 2012 Eduardo C. Lourenço de Lima
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 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.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% \fi
% \iffalse
%
%<package>\NeedsTeXFormat{LaTeX2e}[1996/06/01]
%<package>\ProvidesPackage{sepfootnotes}[2012/03/06 v0.1 Footnotes in separate file]
%<*driver>
\documentclass{ltxdoc}
\usepackage{sepfootnotes}
\newenvironment{Description}
{\par\medskip\noindent\ignorespaces}{}
\newenvironment{synopsis}
{\begin{list}{}
{\setlength\parsep{0pt}
\setlength\itemsep{0pt}}}
{\end{list}}
\newenvironment{Example}[1]
{\if#1\else\paragraph{Example.}#1\fi}
{}
\newenvironment{page}
{\begin{center}\begin{minipage}[t]{0.5\linewidth}}
{\end{minipage}\end{center}}
\newcommand\TODO{\texttt{Todo:}}
\begin{document}
\DocInput{sepfootnotes.dtx}
\end{document}
%</driver>
% \fi
% \changes{0.1}{2012/03/06}{Initial version}
% \GetFileInfo{sepfootnotes.sty}
% \CheckSum{185}
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
% \DoNotIndex{\,,\@addtoreset,\begin,\closeout,\csname,\end,\endcsname}
% \DoNotIndex{\expandafter,\fnsymbol,\@footnotemark,\footnotesep,\footnotesize}
% \DoNotIndex{\@footnotetext,\@ifundefined,\immediate,\input,\jobname,\label}
% \DoNotIndex{\@makebox,\makebox,\mbox,\MessageBreak,\@namedef,\@nameuse}
% \DoNotIndex{\newcommand,\newcounter,\newenvironment,\newwrite,\noindent}
% \DoNotIndex{\normalfont,\openout,\PackageError, \par,\parskip,\ref}
% \DoNotIndex{\refstepcounter,\relax,\renewcommand,\setlength,\string}
% \DoNotIndex{\@thefnmark\write}
% \title{The \textsf{sepfootnotes} package,\thanks{This document
% corresponds to \textsf{sepfootnotes}~\fileversion,
% dated~\filedate.}\\{or a footnote to Plato}}
% \author{Eduardo C. Louren\c{c}o de Lima \\ \texttt{elourenco@phi.pro.br}}
% \maketitle
%
%
% \begin{abstract}\noindent This package allows the content of footnotes
% to be defined before their marks are inserted in a document.
% Footnotes and endnotes can, thus, be easily grouped together
% in a separate file, so that the main body is less
% cluttered.\end{abstract}
%
%
% \section*{Introduction}
%
% Footnotes and endnotes can be a problem when reading {\LaTeX} code. If there
% are many notes to a document, or if some of them are too long, as is often
% the case with philosophers and people from the humanities in general, reading
% and editing the main body may be quite difficult.
%
% They can be a problem for the simple reason that standard |\footnote| and
% |\endnote| both take the text of a note as a mandatory argument. For one
% thing, a verb and its complement may be\footnote{Notice that this footnote
% does precisely that to the main body of this document. There are ten or more
% lines of code between `may be' and `severed' in such an otherwise short
% paragraph. In a posting to \texttt{texhax.tug.org} in April 2010, someone
% complained that using footnotes ``tends to disrupt the flow of the document
% on the screen and makes editing the text itself harder'', and asked about the
% possibility of ``putting all of the footnotes in a separate file''~\cite{Nicholas Cole}.
% Another user, back in 2004, remarked that the ``only thing I
% missed about word processors was the ability to keep footnote text at the
% bottom of the page, or in a separate window. I often have extensive
% footnotes, and don't want them cluttering up my main body text when I'm
% composing''~\cite{Luecking}. Some people circumvent that issue by
% other artful maneuvering, such as indenting or folding footnote code lines.}
% severed by a dozen lines of code.
%
% This package aims to get around this inconvenience by means of
% macros that take as arguments mere \emph{identifiers,} instead of text, thus
% allowing the content of footnotes and endnotes to be defined \emph{before}
% their marks are inserted in a document. Notes can, thus, be easily grouped
% together in a \emph{separate file,} so that the main body is less
% cluttered.
%
% The point is not to prevent writers from indulging in footnotes. Quite the
% contrary.
%
%
% \section*{Synopsis}
%
% \begin{synopsis}
% \item |\newfootnotes| \marg{prefix}
% \item |\newendnotes| \marg{prefix}
% \item |\newsymbolfootnotes| \oarg{master counter} \marg{prefix}\medskip
% \item |\|\meta{prefix}|note| \marg{id}
% \item |\|\meta{prefix}|notemark| \marg{id}
% \item |\|\meta{prefix}|notetext| \marg{id}
% \item |\|\meta{prefix}|notecontent| \marg{id} \marg{text}\medskip
% \item |\|\meta{prefix}|notes| \marg{id}
% \end{synopsis}
%
% \setcounter{tocdepth}{2}
% \tableofcontents
% \newpage
% \section{Basic Usage}
%
% \subsection{Footnotes}
%
% \begin{Description}
% \DescribeMacro{\newfootnotes}
% The first step is to create a new footnote apparatus.
% \begin{synopsis}
% \item |\newfootnotes| \marg{prefix}
% \end{synopsis}
% The
% argument \meta{prefix} can be any sequence of letters, such as `a'
% or `dog', except `foot' and other names that have already been taken.
% For example, executing |\newfootnotes{a}| creates a number of new commands, the
% names of which all begin with~`a-': |\anotemark|, |\anotetext|, |\anote|, and |\anotecontent|.
% \end{Description}
% \begin{Description}
% \DescribeMacro{\<prefix>notemark}
% \DescribeMacro{\<prefix>notetext}
% The first two correspond to {\LaTeX}
% |\footnotemark|, and |\footnotetext|.
% They also produce a footnote, or rather, a mark without a footnote, and a footnote without a mark. But the important difference
% to their analogues is that they do not have the text of the footnote as
% arguments. They take a \emph{identifier} instead.
% \begin{synopsis}
% \item |\|\meta{prefix}|notemark| \marg{id}
% \item |\|\meta{prefix}|notetext| \marg{id}
% \end{synopsis}
% \end{Description}
% \begin{Description}
% \DescribeMacro{\<prefix>notecontent}
% The identifier \meta{id} identifies the text of a footnote.
% It can be any arbitrary sequence of letters, numbers, space and punctuation marks.
% But it is not
% itself the text
% of the footnote; it is more like a tag, or a name. This naming is brought
% about by:
% \begin{synopsis}
% \item |\|\meta{prefix}|notecontent| \marg{id} \marg{text}
% \end{synopsis}
% \end{Description}
% \begin{Description}
% \DescribeMacro{\<prefix>note}
% And once \meta{text} bears a name it can be identified
% by |\|\meta{prefix}|note| to produce a footnote.
% \begin{synopsis}
% \item |\|\meta{prefix}|note| \marg{id}
% \end{synopsis}
% \end{Description}
% \begin{Example}
% {How to typeset `Aristotle's master' as a footnote.}
% \iffalse
%<*example>
% \fi
\begin{verbatim}
\newfootnotes{a}
\anotecontent{Plato}{Aristotle's master.}
This was first brought up by
the great Plato\anote{Plato}
in the \textit{Sophist}.
\end{verbatim}
% \iffalse
%</example>
% \fi
% \begin{page}
% \newfootnotes{a}
% \anotecontent{PlatoFoot}{Aristotle's master.}
% This was first brought up by
% the great Plato\anote{PlatoFoot}
% in the \textit{Sophist}.
% \end{page}
%
% \medskip\noindent That sentence will take three lines of code however long the footnote to
% Plato is. No pun intended.
% \end{Example}
%
%
% \subsection{Endnotes}
%
% \begin{Description}
% \DescribeMacro{\newendnotes}
% \DescribeMacro{\<prefix>notes}
% Endnote and footnote commands are essentially the same but for two
% differences. To use endnotes first substitute |\newendnotes|
% for |\newfootnotes|, and then insert |\|\meta{prefix}|notes|,
% plural, at the end of the document.
% \begin{synopsis}
% \item |\newendnotes| \marg{prefix}
% \item |\|\meta{prefix}|notes|
% \end{synopsis}
% \end{Description}
% \begin{Example}
% {How to effortlessly convert all footnotes into endnotes.}
% \iffalse
%<*example>
% \fi
% \begin{verbatim}\newendnotes{a}
\anotecontent{Plato}{Aristotle's master.}
This was first brought up by
the great Plato\anote{Plato}
in the \textit{Sophist}.
\section*{Notes}
\anotes
\end{verbatim}
% \iffalse
%</example>
% \fi
% \end{Example}
%
% \subsection{Symbol footnotes}
%
% \begin{Description}
% \DescribeMacro{\newsymbolfootnotes}
% To get footnotes with symbols, such as *, $\dag$, and $\ddag$, instead of
% numbers, just declare |\newsymbolfootnotes| instead of |\newfootnotes|.
% (See section~\ref{Roman} for notes with Roman numerals or letters.)
% \begin{synopsis}
% \item |\newsymbolfootnotes| \oarg{master counter} \marg{prefix}
% \end{synopsis}
% \end{Description}
% The optional argument \meta{master counter} can be anything like |page|,
% |section|, |chapter|, etc. The default master counter is |page|. The series
% of symbols is reset each new page, so that * marks the first symbol footnote
% on any page, whereas $\dag$ marks the second, $\ddag$ the third, and so on.
% \begin{Example}{}
% \iffalse
%<*example>
% \fi
%\begin{verbatim}\newsymbolfootnotes[page]{a}
\anotecontent{Plato}{Aristotle's master.}
This was first brought up by
the great Plato\anote{Plato}
in the \textit{Sophist}.
\end{verbatim}
% \iffalse
%</example>
% \fi
% No need to modify the main body. Symbol footnotes are just footnotes using
% the same commands as before.
% \end{Example}
% \newpage
%
% \subsection{Footnotes in separate file}
%
% It is now easy to see how footnotes can be stored in a separate file. It is
% just a matter of moving all |\|\meta{prefix}|notecontent| declarations to a
% new file, say, |notes.tex|, and then loading it in the preamble with |\input|.
%
% \begin{Example}{How to move all footnotes to a separate file.}
%
% \bigskip This is |notes.tex|
% \iffalse
%<*example>
% \fi
% \begin{verbatim}
\anotecontent{Homer}{Everybody's master.}
\anotecontent{Plato}{Aristotle's master.}
\end{verbatim}
%
% And here is |document.tex|
%\begin{verbatim}\documentclass{article}
\usepackage{sepfootnotes}
\newfootnotes{a}
\input{notes.tex}
\begin{document}
This was first brought up by
the great Plato\anote{Plato}
in the \textit{Sophist}. But
nobody could suppose that an
antecedent is to be found in
Homer.\anote{Homer}
\end{document}
\end{verbatim}
% \iffalse
%</example>
% \fi
% Notice that |Homer| is the first entry in |notes.tex| though it will be
% typeset as note~\ref{homer}, whereas |Plato| is the first footnote here but
% the second entry there.
%\begin{page}\makeatletter\let\c@a\undefined\makeatother
%\newfootnotes{a}
%\anotecontent{HomerSep}{Everybody's master.}
%\anotecontent{PlatoSep}{Aristotle's master.}
%This was first brought up by
%the great Plato\anote{PlatoSep}
%in the \textit{Sophist}. But
%nobody could suppose that an
%antecedent is to be found in
%Homer.\anote{HomerSep}\label{homer}
% \end{page}
% \end{Example}
%
% \medskip\noindent Fortunately, the order in which content declarations
% appear in |notes.tex| is \textbf{not} particularly important when it comes to
% numbering footnotes. Numbering depends solely upon the order in which
% |\|\meta{prefix}|note| commands appear in the document.
%
% Content declarations can be either randomly inserted into
% |notes.tex|, or more interestingly perhaps, grouped together by similarity of
% subject or size.
%
% \newpage
% \section{Advanced Usage}
%
% \subsection{Footnotes and endnotes together}
%
% If a writer wants to insert footnotes and endnotes in the same document, all
% he has to do is declare |\newfootnotes| \marg{prefix$_1$} and
% |\newendnotes| \marg{prefix$_2$} in the preamble. Each |\new...notes| creates
% an independent note apparatus with its own counter, |\|\meta{prefix}|note|,
% |\|\meta{prefix}|notecontent|, etc.
%
% The trick though is to give each apparatus a different prefix, say, `a' and
% `b':
% \begin{Example}{}
% \iffalse
%<*example>
% \fi
\begin{verbatim}\newfootnotes{a}
\newendnotes{b}
\end{verbatim}
% \iffalse
%</example>
% \fi
% and then substitute prefix~`b' for `a' whenever a note is to be identified by
% the |b| apparatus. In our example if |Plato| is a footnote, but |Homer| is to be made into an endnote,
% just replace |\anotecontent{Homer}| with |\bnotecontent{Homer}| in
% |notes.tex|
% \iffalse
%<*example>
% \fi
% \begin{verbatim}
\bnotecontent{Homer}{Everybody's master.}
\anotecontent{Plato}{Aristotle's master.}
\end{verbatim}
% \iffalse
%</example>
% \fi
% And do the same to |\anote{Homer}| and |\bnote{Homer}| in |document.tex|.
% But don't forget the |\bnotes|, plural, at the end.
% \iffalse
%<*example>
% \fi
%\begin{verbatim}\newfootnotes{a}
\newendnotes{b}
\input{notes.tex}
\begin{document}
This was first brought up by
the great Plato\anote{Plato}
in the \textit{Sophist}. But
nobody could suppose that an
antecedent is to be found in
Homer.\bnote{Homer}
\section*{Notes}
\bnotes
\end{document}
\end{verbatim}
% \iffalse
%</example>
% \fi
% Here |Plato| will be typeset as a footnote, whereas |Homer| as an endnote.
% \end{Example}
%
% Now imagine that, for whatever reason, a writer or editor needs
% footnotes, endnotes, and symbol footnotes all together in the
% same document. He just has to declare three independent note apparatus taking
% three distinct prefixes:
% \begin{Example}{}
% \iffalse
%<*example>
% \fi
\begin{verbatim}\newfootnotes{a}
\newendnotes{b}
\newsymbolfootnotes{c}
\end{verbatim}
% \iffalse
%</example>
% \fi
% and then use |\anote| and |\anotecontent| for footnotes, but reserve |\bnote|
% and |\bnotecontent| for endnotes, as well as |\cnote| and |\cnotecontent| for
% symbol footnotes.
% \end{Example}
%
%
% \subsection{Cross-references}
%
% \begin{Description}
% \DescribeMacro{\<prefix>noteref}
% Footnotes and endnotes can be referenced to with |\|\meta{prefix}|noteref|.
% \begin{synopsis}
% \item |\|\meta{prefix}|noteref| \marg{id}.
% \end{synopsis}
% \end{Description}
% \begin{Example}
% {How to produce the number of that footnote to Plato.}
% \iffalse
%<*example>
% \fi
% \begin{verbatim}
This was first brought up by
the great Plato\anote{Plato}
in the \textit{Sophist}.
See note~\anoteref{Plato}.
\end{verbatim}
% \iffalse
%</example>
% \fi
% \end{Example}
% It is okay to use {\LaTeX} |\label| and |\ref| to refer the reader to notes
% created by |sepfootnotes|. However, because both |\label|, and |\|\meta{prefix}|note|,
% assign a unique identifier---or label, tag, marker, or name---to a particular
% note number, it may in most cases be just superfluous to label it twice. Compare:
% \begin{Example}{}
% \iffalse
%<*example>
% \fi
% \begin{verbatim}
This was first brought up by
the great Plato\anote{Plato}\label{Plato}
in the \textit{Sophist}.
See note~\ref{Plato}.
\end{verbatim}
% \iffalse
%</example>
% \fi
% \end{Example}
% But imagine our writer would rather stick to |\ref|. Since the labels |sepfootnotes|
% internally assigns to note numbers all have names like
% |Notes@refs@|\meta{prefix}|@|\meta{id}, the footnote number to |Plato| in our example
% may also be typeset, though somewhat clumsily, by
% |\ref{Notes@refs@a@Plato}|.
%
%
% \subsection{Roman numerals and letters}
% \label{Roman}
%
% \begin{Description}
% \DescribeMacro{\the<prefix>}
% To change the style of footnote or endnote marks, simply redefine
% |\the|\meta{prefix} to use another style: |roman|, |Roman|, |alph|, |Alph|, or
% |fnsymbol|.
% \begin{synopsis}
% \item |\renewcommand\the|\meta{prefix} |{\|\meta{style}| {|\meta{prefix}|}}|
% \end{synopsis}
% \end{Description}
% \begin{Example}
% {How to typeset lowercase Roman numerals in footnotes.}
% \iffalse
%<*example>
% \fi
\begin{verbatim}
\renewcommand\thea{\roman{a}}
This was first brought up by
the great Plato\anote{Plato}
in the \textit{Sophist}.
\end{verbatim}
% \iffalse
%</example>
% \fi
%\begin{page}\makeatletter\let\c@a\undefined\makeatother
%\newfootnotes{a}
%\renewcommand\thea{\roman{a}}
%\anotecontent{PlatoRoman}{Aristotle's master.}
%This was first brought up by
%the great Plato\anote{PlatoRoman}
%in the \textit{Sophist}.
%\end{page}
% \end{Example}
%
%
% \subsection{Endnotes customization}
%
% To customize how the text of endnotes is typeset at the end of the document,
% you may redefine |\|\meta{prefix}|endnotemark| and the
% \meta{prefix}|endnotes| environment.
% \begin{Description}
% \DescribeMacro{\<prefix>endnotemark} Numbers right before the text of
% endnotes are typeset by |\|\meta{prefix}|endnotemark|, which is not to be
% confused with |\the|\meta{prefix}. See section~\ref{Roman}.
% \begin{synopsis}
% \item |\|\meta{prefix}|endnotemark| \marg{number}
% \end{synopsis}
% \end{Description}
% \begin{Description}
% \DescribeEnv{<prefix>endnotes}
% The text of all endnotes is typeset within the \meta{prefix}|endnotes|
% environment.
% \end{Description}
% \iffalse
%<*example>
% \fi
% \begin{Example}{How to typeset endnotes as a list of numbers, instead of numbered paragraphs, and in boldface.}
%\begin{verbatim}
\newendnotes{a}
\anotecontent{Homer}{Everybody's master.}
\anotecontent{Plato}{Aristotle's master.}
\renewcommand \aendnotemark [1] {\item[\textbf{#1.}]}
\renewenvironment {aendnotes} {\begin{list}{}{}}
{\end{list}}
This was first brought up by
the great Plato\anote{Plato}
in the \textit{Sophist}. But
nobody could suppose that an
antecedent is to be found in
Homer.\anote{Homer}
\section*{Notes}
\anotes
\end{verbatim}
% \begin{page}\makeatletter\let\c@a\undefined\makeatother
% \newendnotes{a}
% \anotecontent{HomerCustom}{Everybody's master.}
% \anotecontent{PlatoCustom}{Aristotle's master.}
% \renewcommand \aendnotemark [1] {\item[\textbf{#1.}]}
% \renewenvironment {aendnotes}
% {\begin{list}{}
% {\setlength\topsep {0pt}
% \setlength\parsep {0pt}
% \setlength\itemsep{0pt}}}
% {\end{list}}
% This was first brought up by
% the great Plato\anote{PlatoCustom}
% in the \textit{Sophist}. But
% nobody could suppose that an
% antecedent is to be found in
% Homer.\anote{HomerCustom}
% \par\smallskip\noindent\textbf{Notes}
% \anotes
% \end{page}
% \end{Example}
% \iffalse
%</example>
% \fi
%
%\begin{thebibliography}{1}
%
% \bibitem{Nicholas Cole}
% At \texttt{http://tug.org/mailman/htdig/texhax/2010-April/014558.html}
%
% \bibitem{Luecking}
% At \texttt{http://www.44342.com/tex-f809-t9440-p1.htm}.
%
% \bibitem{Companion}
% Frank Mittelbach, and Michel Goossens, with Johannes Braams, David Carlisle,
% and Chris Rowley.
% \newblock \emph{The {\LaTeX} Companion}. 2nd
% \newblock Addison~Wesley, 2004.
% \newblock ISBN~\mbox{0-201-36299-6}.
%
%\end{thebibliography}
%
%
% \StopEventually
%
% \section{Implementation}
%
% \subsection*{Namespace}
%
% First we define a namespace for labels and identifiers.
% \begin{macrocode}
\newcommand\@SFnNamespace{Notes@}
% \end{macrocode}
%
% \subsection{Public macros}
%
% This section comments on public macros dynamically named, and defined, using a user provided prefix.
% They fall into four categories: footnote macros, endnote macros, symbol footnote macros, and
% macros that are common to all of them.
%
% \subsubsection{Common macros}
%
% \begin{macro}{\@SFnNew}
% The public |\newfootnotes|, |\newsymbolfootnotes|, and |\newendnotes|
% commented upon in the next sections first call
% the private |\@SFnNew| \marg{prefix}, which dynamically defines a counter and
% three public macros common to both footnotes and endnotes. They are all named with \meta{prefix}: if
% `bar' is provided as the prefix then |\barnotecontent|, |\barnoteref|, |\barnmark|,
% and the counter |bar| are defined.
% \begin{macrocode}
\newcommand\@SFnNew [1]{%
% \end{macrocode}
% The counter \meta{prefix} will only track notes typeset by macros named with \meta{prefix}.
% \begin{macrocode}
\newcounter{#1}%
% \end{macrocode}
% \begin{macro}{\<prefix>notecontent}
% The macro |\|\meta{prefix}|notecontent| \marg{id} \marg{text} stores
% \meta{text} as \meta{id}, which is in the \meta{prefix} namespace itself.
% \begin{macrocode}
\expandafter
\newcommand\csname #1notecontent\endcsname [2]
{\@SFnStoreText {#1} {##1} {##2}}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\<prefix>noteref}
% The macro |\|\meta{prefix}|noteref| \marg{id} typesets the reference to the label
% associated with \meta{id}. See |\|\meta{prefix}|notemark| in \ref{footnotes} below.
% \begin{macrocode}
\expandafter
\newcommand\csname #1noteref\endcsname [1]
{\@SFnGetReference {#1} {##1}}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\<prefix>nmark}
% Finally |\|\meta{prefix}|nmark| typesets the default note mark.
% \begin{macrocode}
\expandafter
\newcommand\csname #1nmark\endcsname
{\csname the#1\endcsname}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{Footnotes}
% \label{footnotes}
%
% \begin{macro}{\newfootnotes}
% The macro |\newfootnotes| \marg{prefix} dynamically defines three public
% macros. They also are all named with \meta{prefix}.
% \begin{macrocode}
\newcommand\newfootnotes [1]
{\@SFnNew{#1}%
% \end{macrocode}
% \begin{macro}{\<prefix>notemark}
% The macro |\|\meta{prefix}|notemark| \marg{id} steps the counter, assigns it a
% label, links that label up with \meta{id}, and typesets a footnote mark. See
% |\@SFnInsertMark|.
% \begin{macrocode}
\expandafter
\newcommand\csname #1notemark\endcsname [1]
{\@SFnInsertMark {#1} {##1}}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\<prefix>notetext}
% The macro |\|\meta{prefix}|notetext| \meta{id} typesets the text that was
% previously associated with \meta{id} by |\|\meta{prefix}|notecontent|.
% \begin{macrocode}
\expandafter
\newcommand\csname #1notetext\endcsname [1]
{\@SFnSetMark {#1}%
\@SFnTypesetText {#1} {##1}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\<prefix>note}
% The macro |\|\meta{prefix}|note| \meta{id} typesets the mark and text of a
% footnote.
% \begin{macrocode}
\expandafter
\newcommand\csname #1note\endcsname [1]
{\csname #1notemark\endcsname{##1}%
\csname #1notetext\endcsname{##1}}}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Symbol footnotes}
%
% \begin{macro}{\newsymbolfootnotes}
% The macro |\newsymbolfootnotes| \oarg{master counter} \marg{prefix} dynamically
% define all of the footnote macros commented upon in \ref{footnotes}, but it also
% redefines |\|\meta{prefix}|nmark| so as to render symbols instead of numbers. Further,
% it creates a counter to be reset when \meta{master counter} is stepped.
% The default master counter is |page|.
% \begin{macrocode}
\newcommand\newsymbolfootnotes [2][page]
{\newfootnotes {#2}%
\@addtoreset {#2} {#1}%
\expandafter
\renewcommand\csname #2nmark\endcsname
{\fnsymbol {#2}}}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Endnotes}
% \label{endnotes}
%
% Endnote identifiers, but not endnote number and text, need to be stored in a file
% for later processing. The list of endnote identifiers may then be converted into
% endnotes at the end of the document within a suitable environment.
%
% The following is similar to \ref{footnotes} on footnotes but for
% the fact that now we have to deal with files, and delayed typesetting of
% endnote text. Another difference to the footnote set is that
% |\|\meta{prefix}|notemark| and |\|\meta{prefix}|note| are the same here.
%
% \begin{macro}{\newendnotes}
% The macro |\newendnotes| \marg{prefix} dynamically defines a corresponding
% environment \meta{prefix}|endnotes|, as well as five public macros
% available to endnotes only. They also are
% all named with \meta{prefix}.
% \begin{macrocode}
\newcommand\newendnotes [1]
{\@SFnNew {#1}%
\@SFnOpenFileOut {#1}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\<prefix>note}
% \begin{macro}{\<prefix>notemark}
% Both |\|\meta{prefix}|note| \marg{id} and |\|\meta{prefix}|notemark| \marg{id}
% typeset an endnote mark, and write down its \meta{id} for later
% processing.
% \begin{macrocode}
\expandafter
\newcommand\csname #1notemark\endcsname [1]
{\@SFnInsertMark {#1} {##1}%
\@SFnWriteToFile {#1} {##1}}%
\expandafter
\newcommand\csname #1note\endcsname [1]
{\csname #1notemark\endcsname {##1}}%
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\<prefix>notetext}
% Though public, |\|\meta{prefix}|notetext| \marg{id} is not meant to be directly used
% when applied to endnotes. It typesets a single
% endnote mark and text, preferably within the \meta{prefix}|endnotes|
% environment.
% \begin{macrocode}
\expandafter
\newcommand\csname #1notetext\endcsname [1]
{\csname #1endnotemark\endcsname
{\@SFnGetReference {#1} {##1}}%
\@SFnRetrieveText {#1} {##1}\par}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\<prefix>notes}
% The |\|\meta{prefix}|notes| immediately closes the auxiliary file, and typesets all endnotes
% within a \meta{prefix}|endnotes| environment.
% \begin{macrocode}
\expandafter
\newcommand\csname #1notes\endcsname
{\@SFnCloseFile {#1}%
\begin{#1endnotes}
\input\@SFnFileName{#1}%
\end{#1endnotes}}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\<prefix>endnotemark}
% Now, the macro |\|\meta{prefix}|endnotemark| \marg{number}
% typesets marks preferably within the \meta{prefix}|endnotes|
% environment.\footnote{From \cite[p.114]{Companion}.}
% \begin{macrocode}
\expandafter
\newcommand\csname #1endnotemark\endcsname [1]
{\noindent\makebox[0pt][r]{\mbox{{\normalfont ##1.\,}}}}
% \end{macrocode}
% \end{macro}
% \begin{environment}{<prefix>endnotes}
% And here is the environment where to typeset all endnotes.
% \begin{macrocode}
\newenvironment{#1endnotes}
{\footnotesize\setlength\parskip\footnotesep}
{}}%
% \end{macrocode}
% \end{environment}
%
% \newpage
% \subsection{Private macros}
%
% This section comments on private macros.
%
% \subsubsection{Files}
%
% The following apply to endnotes only. See~\ref{endnotes}.
%
% \begin{macro}{\@SFnFileName}
% The macro |\@SFnFileName| \marg{prefix} returns a filename based on,
% surprise, \meta{prefix}. \TODO{} 3 letter extension: |sep|.
% \begin{macrocode}
\newcommand\@SFnFileName [1]
{\jobname.notes-#1}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@SFnOpenFileOut}
% \begin{macro}{\@SFnWriteToFile}
% \begin{macro}{\@SFnCloseFile}
% Here are three macros that operate on file descriptors:
%
% The first,
% |\@SFnOpenFileOut| \marg{prefix}, opens for writing a dynamically named
% file |\@SFnFileOut|\meta{prefix}.
% \begin{macrocode}
\newcommand\@SFnOpenFileOut [1]
{\expandafter\newwrite\csname @SFnFileOut#1\endcsname
\immediate\expandafter\openout
\csname @SFnFileOut#1\endcsname=\@SFnFileName#1\relax}
% \end{macrocode}
% The macro |\@SFnWriteToFile| \marg{prefix} \marg{id} writes down a
% note identifier, \meta{id}, for later processing. See
% |\|\meta{prefix}|notes| in section~\ref{endnotes}.
% \begin{macrocode}
\newcommand\@SFnWriteToFile [2]
{\immediate\write\csname @SFnFileOut#1\endcsname
{\expandafter\string\csname #1notetext\endcsname
{#2}}}%
% \end{macrocode}
% And |\@SFnCloseFile| \marg{prefix} closes the file containing note
% identifiers related to \meta{prefix}.
% \begin{macrocode}
\newcommand\@SFnCloseFile [1]
{\immediate\expandafter
\closeout\csname @SFnFileOut#1\endcsname\relax}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsubsection{Text}
%
% These are private macros to store, retrieve, and typeset the text of notes.
% They apply to both footnotes and endnotes.
%
% \begin{macro}{\@SFnStoreText}
% First |\@SFnStoreText| \marg{prefix} \marg{id} \marg{text} stores the
% text of a note as \meta{id} in the \meta{prefix} |text| namespace. The
% package aborts if \meta{id} is already in use in that namespace.
% \begin{macrocode}
\newcommand\@SFnStoreText [3]
{\@ifundefined{\@SFnNamespace text@#1@#2}
{\@SFnNameDef {#1} {#2} {#3}}
{\PackageError
{\@SFnPackageName}
{`#1' is already in use.}
{The note identifier `#1' already identifies a piece of
text.\MessageBreak Solution: Use another identifier.}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@SFnRetrieveText}
% And |\@SFnRetrieveText| \marg{prefix} \marg{id} retrieves a previously
% stored piece of text identified by \meta{id} in the \meta{prefix} |text|
% namespace. It silently ignores undefined content.
% \begin{macrocode}
\newcommand\@SFnRetrieveText [2]
{\@ifundefined{\@SFnNamespace text@#1@#2}
{}
{\@SFnNameUse {#1} {#2}}}
% \end{macrocode}
% ^^A {\PackageWarningNoLine
% ^^A {\@SFnPackageName}
% ^^A {Empty note `#2' on page \thepage}}
% ^^A% {Note `#2' has no content assigned to it.\MessageBreak
% ^^A% Solution: Insert \expandafter\protect\csname #1notetext\endcsname{#2}{...}
% ^^A% before it.}
% \end{macro}
% \begin{macro}{\@SFnTypesetText}
% Finally, |\@SFnTypesetText| \marg{prefix} \marg{id} not only retrieves
% but also typesets a note text identified by \meta{id} in the \meta{prefix}
% |text| namespace.
% \begin{macrocode}
\newcommand\@SFnTypesetText [2]
{\@footnotetext{\@SFnRetrieveText {#1} {#2}}}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Marks}
%
% These are private macros to typeset note marks.
% They apply to both footnotes and endnotes.
%
% \begin{macro}{\@SFnInsertMark}
% The macro |\@SFnInsertMark| \marg{prefix} \marg{id} steps the counter,
% assigns it a label, links that label up with \meta{id}, and then typesets a note
% mark. It does the real work behind |\|\meta{prefix}|notemark| in sections \ref{footnotes} and~\ref{endnotes}.
% \begin{macrocode}
\newcommand\@SFnInsertMark [2]
{\@SFnStepCounter {#1}%
\@SFnSetReference {#1} {#2}%
\@SFnSetMark {#1}%
\@SFnTypesetMark}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@SFnSetMark}
% Now, |\@SFnSetMark| \marg{prefix} sets\footnote{From {\LaTeX} Kernel (Floats),
% 2002/10/01 v1.1v.: |base/ltfloat.dtx|.} \LaTeX{} internal note engine to typeset a mark as
% publicly defined by |\|\meta{prefix}|nmark|.
% \begin{macrocode}
\newcommand\@SFnSetMark [1]
{\protected@xdef\@thefnmark{\csname #1nmark\endcsname}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@SFnTypesetMark}
% And |\@SFnTypesetMark| is just a more descriptive wrapper to the
% internal macro that typesets the note mark.
% \begin{macrocode}
\newcommand\@SFnTypesetMark
{\@footnotemark}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Labels and cross-references}
%
% This package relies heavily on labels and cross-references to keep track of endnote
% numbers. But every note number, be it footnote or endnote, is assigned a
% label in the \meta{prefix} |label| namespace. Thus note numbers can be
% directly referenced to with |\ref{Notes@refs@|\meta{prefix}|@|\meta{id}|}|, or
% indirectly, but more simply, with |\|\meta{prefix}|noteref| \meta{id}.
%
% On the one hand, labels require running |latex| at least twice to get
% cross-references right. But on the other they allow us not to bother
% with note numbers. As long as note text and labels are implicitly connected by a unique
% identifier \meta{id} in \meta{prefix} namespace, the explicit connection between note
% content and number does not need to be hard coded into the endnote auxiliary
% file, as it is in the |endnotes| package.
%
% But the motivation for the identifier approach---notes defined before notes
% inserted---is quite independent of such a feature, if it is a feature.
%
% \TODO{} However it be, the identifier approach might prove itself useful in solving
% \LaTeX{} misnumbering footnotes when two or more |\footnotemark| precedes two
% or more |\footnotetext|. Since the |sepfootnotes| package requires note text to
% be defined before note marks are inserted, even in a separate file, it no
% longer matters how many times |\|\meta{prefix}|notemark| \meta{id} is invoked before
% |\|\meta{prefix}|notetext| \meta{id}. That is precisely what goes on with endnotes.
% \begin{macro}{\@SFnSetReference}
% The macro |\@SFnSetReference| \marg{prefix} \marg{id} assigns a note
% number a label in the \meta{prefix} |refs| namespace.
% \begin{macrocode}
\newcommand\@SFnSetReference [2]
{\label{\@SFnNamespace refs@#1@#2}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@SFnGetReference}
% And |\@SFnGetReference| \marg{prefix} \marg{id} simply returns that
% number.
% \begin{macrocode}
\newcommand\@SFnGetReference [2]
{\ref{\@SFnNamespace refs@#1@#2}}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Counters}
%
% \begin{macro}{\@SFnStepCounter}
% The macro |\@SFnStepCounter| \marg{prefix} steps the counter |prefix|,
% and makes sure it can be properly labeled afterwards.
% \begin{macrocode}
\newcommand\@SFnStepCounter [1]
{\refstepcounter{#1}}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Names}
% \label{names}
%
% \begin{macro}{\@SFnNameDef}
% The macro |\@SFnNameDef| \marg{prefix} \marg{id} \marg{text} stores
% \meta{text} as \meta{id} in the \meta{prefix} |text|
% namespace.\footnote{I owe Dan Luecking the idea of using \LaTeX{} internal
% table to store note text.~\cite{Luecking}}
% \begin{macrocode}
\newcommand\@SFnNameDef [3]
{\@namedef{\@SFnNamespace text@#1@#2}{#3}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@SFnNameUse}
% And |\@SFnNameUse| \marg{prefix} \marg{id} retrieves a previously stored
% piece of text identified by \meta{id} in the \meta{prefix} |text| namespace.
% Undefined content is silently ignored.
% \begin{macrocode}
\newcommand\@SFnNameUse [2]
{\@nameuse{\@SFnNamespace text@#1@#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%\Finale
|