Debian Codegraph @

texmf-dist/doc/latex/endnotes/endnotes.tex

raw
1 \documentclass[pagesize=auto]{scrartcl}
2
3 \usepackage{lmodern}
4 \usepackage[T1]{fontenc}
5 \usepackage{textcomp}
6 \usepackage[utf8]{inputenc}
7 \usepackage{microtype}
8 \usepackage{hyperref}
9
10 \newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
11 \newcommand*{\pkg}[1]{\textsf{#1}}
12 \newcommand*{\cs}[1]{\texttt{\textbackslash#1}}
13 \makeatletter
14 \newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}}
15 \makeatother
16 \newcommand*{\env}[1]{\texttt{#1}}
17 \newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle}
18 \newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}}
19 \newcommand*{\oarg}[1]{\texttt{[}\meta{#1}\texttt{]}}
20
21 \addtokomafont{title}{\rmfamily}
22
23 \title{The \pkg{endnotes} package}
24 \author{John Lavagnino\thanks{Centre for Computing in the Humanities, King's College London}\thanks{Now Maintained by the \LaTeX3 project, \url{https://github.com/rf-latex/endnotes}}}
25
26 \date{2020-01-02}
27
28
29 \begin{document}
30
31 \maketitle
32
33 \noindent
34 Based on the \textsc{footnotes} section of
35 \texttt{LATEX.TEX} (version~2.09 -- release of 19 April 1986), with
36 ``\texttt{footnote}'' changed to ``\texttt{endnote}'' and ``\texttt{fn}'' changed to ``\texttt{en}'' (where
37 appropriate), with all the \env{minipage} stuff pulled out, and with
38 some small changes for the different operation of endnotes.
39 Subsequently updated to follow the code for
40 \LaTeXe\ \textlangle 2000/06/01\textrangle.
41
42 Uses an extra external file, with \texttt{.ent} extension, to hold the
43 text of the endnotes. This may be deleted after the run; a new
44 version is generated each time---it doesn't require information
45 collected from the previous run.
46
47 This code does not obey \cmd{\nofiles}. Perhaps it should.
48
49 \bigskip
50
51 To turn all the footnotes in your documents into endnotes, say
52 %
53 \begin{verbatim}
54 \let\footnote=\endnote
55 \end{verbatim}
56 %
57 in your preamble, and then add something like
58 %
59 \begin{verbatim}
60 \newpage
61 \begingroup
62 \parindent 0pt
63 \parskip 2ex
64 \def\enotesize{\normalsize}
65 \theendnotes
66 \endgroup
67 \end{verbatim}
68 %
69 as the last thing in your document. (But \cmd{\theendnotes} all
70 by itself will work.)
71
72
73 \section{Change log}
74
75 \renewcommand*{\labelenumi}{\theenumi)}
76
77 \begin{labeling}[~--]{DW}
78 \item[JL] Modified to include \cmd{\addtoendnotes}. JL, 10/22/89.
79
80 \item[JK] Modification by Jörg Knappen 25.\,2.\,1991:
81
82 Introduced \cmd{\notesname} in the spirit of international \LaTeX.
83 \cmd{\notesname} is set per default to be \verb+{Notes}+, but can easily
84 be redifined, e.\,g.\ for german language\\
85 \verb+\renewcommand{\notesname}{Anmerkungen}+
86
87 \item[DW] Modification by Dominik Wujastyk, London, 19 September 1991:
88
89 Moved the line\\
90 \verb+\edef\@currentlabel{\csname p@endnote\endcsname\@theenmark}+\\
91 out of the definition of \cmd{\@endnotetext} and into the definition
92 of \cmd{\@doanenote} so that \cmd{\label} and \cmd{\ref} commands work correctly in
93 endnotes. Otherwise, the \cmd{\label} just pointed to the last section
94 heading (or whatever) preceding the \cmd{\theendnotes} command.
95
96 \item[JL] Revised documentation and macros. 24 Sept 1991.
97
98 \item[\null]
99 \begingroup
100 \setlength{\leftmarginii}{25mm}%
101 \begin{enumerate}
102 \item[\rlap{\hspace{-\labelwidth}modified by \texttt{-\null-bg} (B.\,Gaulle) 09/14/94 for:}]
103 \item replace \verb+»+ (why a 8bit char here?) by \verb+^+ as a default.
104 \item force \cmd{\catcode} of \verb+>+ to be 12 (implied by \cmd{\@doanenote}).
105 \item[\rlap{\hspace{-\labelwidth}\phantom{modified} by \texttt{-\null-bg} again 03/22/95 for:}]
106 \item reseting appropriate \texttt{catcode} of \verb+>+ in case it were
107 used as an active char before \cmd{\@endanenote} (was
108 pointed by Ch.\ Pallier).
109 \end{enumerate}
110 \endgroup
111
112 \item[JL] John Lavagnino, 12 January 2003: a number of small updates:
113
114 Incorporate change suggested by Frank Mittelbach to
115 \cmd{\enoteheading}, so that first note has paragraph indentation.
116 Frank's note:
117 %
118 \begin{quote}
119 the idea of this code is to fix the problem that without it
120 the first endnote after the heading will not be indented thus looking
121 somewhat strange. Problem however is that since there is no
122 indentation \verb+\leavemode\par+ will make an absolutely empty pargraph so
123 that no baseline calculation is done. therefore \verb+\vskip-\baselineskip+
124 will put the first endnote directly below the heading without the
125 usual spaccing. using \cmd{\mbox} insead will cure this defect.
126 \end{quote}
127
128 Also incorporated Frank's suggestion to define
129 \cmd{\makeenmark} and \cmd{\theenmark}, so that users can change more of the
130 layout without using \cmd{\makeatletter}. \cmd{\makeenmark} defaults to
131 \cmd{\@makeenmark}, so old code is still supported; and \cmd{\theenmark} is
132 just syntactic sugar for \cmd{\@theenmark}, which is still the real
133 value (and shouldn't be directly modified by user code).
134
135 Definition of \cmd{\ETC}.\ also dropped: surely nobody is still
136 using \TeX~2.992. (If you are, you need to upgrade it or
137 endnotes longer than 1000~characters will be truncated.)
138
139 Update much of the code to track the current \LaTeXe\ code more
140 closely. Clean up \cmd{\theendnotes}.
141
142 \item[JL] John Lavagnino, 15 January 2003: fix my garbled version of
143 Frank's updates.
144
145 \item[JS] Modification by Jürgen Spitzmüller, 17.\,8.\,2019:
146
147 Do not break but just warn if \verb|\theendnotes| is used, but no
148 endnotes have been inserted yet.
149
150 If the last remaining \verb|\endnote| is removed, clear the \verb|*.ent|
151 auxiliary file.
152
153 \end{labeling}
154
155
156 \section{Endnote commands}
157
158 \addtokomafont{labelinglabel}{\small}
159
160 \begin{labeling}[~:]{\cmd{\endnotetext}\oarg{num}\marg{text}}
161 \item[\cmd{\endnote}\marg{note}] User command to insert a endnote.
162
163 \item[\cmd{\endnote}\oarg{num}\marg{note}] User command to insert a endnote numbered
164 \meta{num}, where \meta{num} is a number -- 1, 2,
165 etc. For example, if endnotes are numbered
166 *, **, etc. within pages, then \verb+\endnote[2]{...}+
167 produces endnote `**'. This command does not
168 step the endnote counter.
169
170 \item[\cmd{\endnotemark}\oarg{num}] Command to produce just the endnote mark in
171 the text, but no endnote. With no argument,
172 it steps the endnote counter before generating
173 the mark.
174
175 \item[\cmd{\endnotetext}\oarg{num}\marg{text}] Command to produce the endnote but no
176 mark. \cmd{\endnote} is equivalent to
177 \cmd{\endnotemark}\cmd{\endnotetext}.
178
179 \item[\cmd{\addtoendnotes}\marg{text}] Command to add text or commands to current
180 endnotes file: for inserting headings,
181 pagebreaks, and the like into endnotes
182 sections. \meta{text} a moving argument:
183 \cmd{\protect} required for fragile commands.
184
185 \end{labeling}
186
187
188 \section{Endnote user commands}
189
190 Endnotes use the following parameters, similar to those relating
191 to footnotes:
192 %
193 \begin{labeling}[~:]{\cmd{\@makeentext}\marg{note}}
194 \item[\cmd{\enotesize}] Size-changing command for endnotes.
195
196 \item[\cmd{\theendnote}] In usual \LaTeX\ style, produces the endnote number.
197
198 \item[\cmd{\theenmark}] Holds the current endnote's mark---e.\,g., \dag\ or `1' or `a'.
199 (You don't want to set this yourself, as it comes
200 either from the autonumbering of notes or from
201 the optional argument to \cmd{\endnote}. But you'll need
202 to use it if you define your own \cmd{\makeenmark}.)
203
204 \item[\cmd{\makeenmark}] A macro to generate the endnote marker from \cmd{\theenmark}.
205 The default definition is \verb+\hbox{$^\theenmark$}+.
206
207 \item[\cmd{\@makeentext}\marg{note}]
208 Must produce the actual endnote, using \cmd{\theenmark} as the mark
209 of the endnote and \meta{note} as the text. It is called when effectively
210 inside a \cmd{\parbox}, with $\cmd{\hsize} = \cmd{\columnwidth}$. For example, it might
211 be as simple as
212 \verb*+$^{\theenmark}$ +\meta{note}
213
214 \end{labeling}
215
216
217 \pagebreak[2]
218
219 \section{Endnote pseudocode}
220
221 \begin{verbatim}
222 \endnote{NOTE} ==
223 BEGIN
224 \stepcounter{endnote}
225 \@theenmark :=G eval (\theendnote)
226 \@endnotemark
227 \@endnotetext{NOTE}
228 END
229
230 \endnote[NUM]{NOTE} ==
231 BEGIN
232 begingroup
233 counter endnote :=L NUM
234 \@theenmark :=G eval (\theendnote)
235 endgroup
236 \@endnotemark
237 \@endnotetext{NOTE}
238 END
239
240 \@endnotetext{NOTE} ==
241 BEGIN
242 write to \@enotes file: "\@doanenote{ENDNOTE MARK}"
243 begingroup
244 \next := NOTE
245 set \newlinechar for \write to \space
246 write to \@enotes file: \meaning\next
247 (that is, "macro:->NOTE)
248 endgroup
249 END
250
251 \addtoendnotes{TEXT} ==
252 BEGIN
253 open endnotes file if not already open
254 begingroup
255 let \protect to \string
256 set \newlinechar for \write to \space
257 write TEXT to \@enotes file
258 endgroup
259 END
260
261 \endnotemark ==
262 BEGIN \stepcounter{endnote}
263 \@theenmark :=G eval(\theendnote)
264 \@endnotemark
265 END
266
267 \endnotemark[NUM] ==
268 BEGIN
269 begingroup
270 endnote counter :=L NUM
271 \@theenmark :=G eval(\theendnote)
272 endgroup
273 \@endnotemark
274 END
275
276 \@endnotemark ==
277 BEGIN
278 \leavevmode
279 IF hmode THEN \@x@sf := \the\spacefactor FI
280 \makeenmark % put number in main text
281 IF hmode THEN \spacefactor := \@x@sf FI
282 END
283
284 \endnotetext ==
285 BEGIN \@theenmark :=G eval (\theendnote)
286 \@endnotetext
287 END
288
289 \endnotetext[NUM] ==
290 BEGIN begingroup counter endnote :=L NUM
291 \@theenmark :=G eval (\theendnote)
292 endgroup
293 \@endnotetext
294 END
295 \end{verbatim}
296
297 \end{document}