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
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ****************************************
% * TABNOTES *
% ****************************************
%
% Date of this version: 28 August 2009.
% Matthias Borck-Elsner
%
%% Based on endnotes.sty Copyright 2002 John Lavagnino
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
%% 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.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%
% Uses an extra external file, with .tne extension, to hold the
% text of the tabnotes. This may be deleted after the run; a new
% version is generated each time--it doesn't require information
% collected from the previous run.
%
% This code does not obey \nofiles. Perhaps it should.
%
%
% To turn all the footnotes in your documents into tabnotes, say
%
% \let\footnote=\tabnote
%
% in your preamble, and then add something like
%
% \newpage
% \begingroup
% \parindent 0pt
% \parskip 2ex
% \def\tnotesize{\normalsize}
% \thetabnotes
% \endgroup
%
% as the last thing in your document. (But \thetabnotes all
% by itself will work.)
%
%
%
% ****************************************
% * TABNOTE COMMANDS *
% ****************************************
%
%
% \tabnote{NOTE} : User command to insert a tabnote.
%
% \tabnote[NUM]{NOTE} : User command to insert a tabnote numbered
% NUM, where NUM is a number -- 1, 2,
% etc. For example, if tabnotes are numbered
% *, **, etc. within pages, then \tabnote[2]{...}
% produces tabnote '**'. This command does not
% step the tabnote counter.
%
% \tabnotemark[NUM] : Command to produce just the tabnote mark in
% the text, but no tabnote. With no argument,
% it steps the tabnote counter before generating
% the mark.
%
% \tabnotetext[NUM]{TEXT} : Command to produce the tabnote but no
% mark. \tabnote is equivalent to
% \tabnotemark \tabnotetext .
%
% \addtotabnotes{TEXT} : Command to add text or commands to current
% tabnotes file: for inserting headings,
% pagebreaks, and the like into tabnotes
% sections. TEXT a moving argument:
% \protect required for fragile commands.
%
% ****************************************
% * TABNOTE USER COMMANDS *
% ****************************************
%
% Tabnotes use the following parameters, similar to those relating
% to footnotes:
%
% \tnotesize : Size-changing command for tabnotes.
%
% \thetabnote : In usual LaTeX style, produces the tabnote number.
%
% \thetnmark : Holds the current tabnote's mark--e.g., \dag or '1' or 'a'.
% (You don't want to set this yourself, as it comes
% either from the autonumbering of notes or from
% the optional argument to \tabnote. But you'll need
% to use it if you define your own \maketnmark.)
%
% \maketnmark : A macro to generate the tabnote marker from \thetnmark
% The default definition is \hbox{$^\thetnmark$}.
%
% \@makeentext{NOTE} :
% Must produce the actual tabnote, using \thetnmark as the mark
% of the tabnote and NOTE as the text. It is called when effectively
% inside a \parbox, with \hsize = \columnwidth. For example, it might
% be as simple as
% $^{\thetnmark}$ NOTE
%
%
% ****************************************
% * TABNOTE PSEUDOCODE *
% ****************************************
%
% \tabnote{NOTE} ==
% BEGIN
% \stepcounter{tabnote}
% \@thetnmark :=G eval (\thetabnote)
% \@tabnotemark
% \@tabnotetext{NOTE}
% END
%
% \tabnote[NUM]{NOTE} ==
% BEGIN
% begingroup
% counter tabnote :=L NUM
% \@thetnmark :=G eval (\thetabnote)
% endgroup
% \@tabnotemark
% \@tabnotetext{NOTE}
% END
%
% \@tabnotetext{NOTE} ==
% BEGIN
% write to \@tnotes file: "\@doantnote{TABNOTE MARK}"
% begingroup
% \next := NOTE
% set \newlinechar for \write to \space
% write to \@tnotes file: \meaning\next
% (that is, "macro:->NOTE)
% endgroup
% END
%
% \addtotabnotes{TEXT} ==
% BEGIN
% open tabnotes file if not already open
% begingroup
% let \protect to \string
% set \newlinechar for \write to \space
% write TEXT to \@tnotes file
% endgroup
% END
%
% \tabnotemark ==
% BEGIN \stepcounter{tabnote}
% \@thetnmark :=G eval(\thetabnote)
% \@tabnotemark
% END
%
% \tabnotemark[NUM] ==
% BEGIN
% begingroup
% tabnote counter :=L NUM
% \@thetnmark :=G eval(\thetabnote)
% endgroup
% \@tabnotemark
% END
%
% \@tabnotemark ==
% BEGIN
% \leavevmode
% IF hmode THEN \@x@sf := \the\spacefactor FI
% \maketnmark % put number in main text
% IF hmode THEN \spacefactor := \@x@sf FI
% END
%
% \tabnotetext ==
% BEGIN \@thetnmark :=G eval (\thetabnote)
% \@tabnotetext
% END
%
% \tabnotetext[NUM] ==
% BEGIN begingroup counter tabnote :=L NUM
% \@thetnmark :=G eval (\thetabnote)
% endgroup
% \@tabnotetext
% END
%
% ****************************************
% * ENDNOTE MACROS *
% ****************************************
%
\@definecounter{tabnote}
\def\thetabnote{\@arabic\c@tabnote}
\def\@maketnmark{\hbox{\@textsuperscript{\normalfont\@thetnmark}}}
\def\maketnmark{\@maketnmark}
\def\thetnmark{\@thetnmark}
\newdimen\tabnotesep
\def\tabnote{\@ifnextchar[\@xtabnote{\stepcounter{tabnote}%
\protected@xdef\@thetnmark{\thetabnote}%
\@tabnotemark\@tabnotetext}}
\def\@xtabnote[#1]{%
\begingroup
\c@tabnote=#1\relax
\unrestored@protected@xdef\@thetnmark{\thetabnote}%
\endgroup
\@tabnotemark\@tabnotetext}
% Here begins a section of tabnote code that's really different from
% the footnote code of LaTeX.
\let\@doantnote=0
\let\@endantnote=0
\newwrite\@tnotes
\newif\if@tnotesopen \global\@tnotesopenfalse
\def\@opentnotes{\immediate\openout\@tnotes=\jobname.tne\relax
\global\@tnotesopentrue}
% The stuff with \next and \meaning is a trick from the TeXbook, 382,
% there intended for setting verbatim text, but here used to avoid
% macro expansion when the footnote text is written. \next will have
% the entire text of the footnote as one long line, which might well
% overflow limits on output line length; the business with \newlinechar
% makes every space become a newline in the \@tnotes file, so that all
% of the lines wind up being quite short.
\long\def\@tabnotetext#1{%
\if@tnotesopen \else \@opentnotes \fi
\immediate\write\@tnotes{\@doantnote{\@thetnmark}}%
\begingroup
\def\next{#1}%
\newlinechar='40
\immediate\write\@tnotes{\meaning\next}%
\endgroup
\immediate\write\@tnotes{\@endantnote}}
% \addtotabnotes works the way the other tabnote macros probably should
% have, requiring the use of \protect for fragile commands.
\long\def\addtotabnotes#1{%
\if@tnotesopen \else \@opentnotes \fi
\begingroup
\newlinechar='40
\let\protect\string
\immediate\write\@tnotes{#1}%
\endgroup}
% End of unique tabnote code
\def\tabnotemark{%
\@ifnextchar[\@xtabnotemark
{\stepcounter{tabnote}%
\protected@xdef\@thetnmark{\thetabnote}%
\@tabnotemark}}
\def\@xtabnotemark[#1]{%
\begingroup
\c@tabnote #1\relax
\unrestored@protected@xdef\@thetnmark{\thetabnote}%
\endgroup
\@tabnotemark}
\def\@tabnotemark{%
\leavevmode
\ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
\maketnmark
\ifhmode\spacefactor\@x@sf\fi
\relax}
\def\tabnotetext{%
\@ifnextchar [\@xtabnotenext
{\protected@xdef\@thetnmark{\thetabnote}%
\@tabnotetext}}
\def\@xtabnotenext[#1]{\begingroup \c@tabnote=#1\relax
\xdef\@thetnmark{\thetabnote}\endgroup \@tabnotetext}
\def\@xtabnotenext[#1]{%
\begingroup
\c@tabnote=#1\relax
\unrestored@protected@xdef\@thetnmark{\thetabnote}%
\endgroup
\@tabnotetext}
% \thetabnotes actually prints out the tabnotes.
% The user may want separate tabnotes for each chapter, or a big
% block of them at the end of the whole document. As it stands,
% either will work; you just say \thetabnotes wherever you want the
% tabnotes so far to be inserted. However, you must add
% \setcounter{tabnote}{0} after that if you want subsequent tabnotes
% to start numbering at 1 again.
% \tnoteformat is provided so user can specify some special formatting
% for the tabnotes. It needs to set up the paragraph parameters, start
% the paragraph, and print the label. The \mbox stuff in \tnoteheading
% is to make and undo a dummy paragraph, to get around the games \section*
% plays with paragraph indenting and instead give us uniform
% indenting for all notes.
\def\tnotesname{Tablenotes}%
\def\tnoteheading{\subsection*{\tnotesname
\@mkboth{\MakeUppercase{\tnotesname}}{\MakeUppercase{\tnotesname}}}%
\mbox{}\par\vskip-\baselineskip}
\def\tnoteformat{\rightskip\z@ \leftskip\z@ \parindent=1.8em
\leavevmode\llap{\maketnmark}}
\def\tnotesize{\footnotesize}
\def\thetabnotes{\immediate\closeout\@tnotes \global\@tnotesopenfalse
\begingroup
\makeatletter
%
% The machinery with \@ResetGT and > here ensures that
% \@doantnote works properly even if > is an active character
% at the point where \thetabnotes is invoked. > needs to have
% catcode 12 when the arguments of \@doantnote are scanned, so
% that the > in the string "macro:->" is matched. The actual
% footnote text is not an argument to \@doantnote, but just
% follows it in the .tne file; so \@ResetGT can reset the
% category code for > that should be used when processing
% that text. That resetting takes place within a
% \begingroup-\endgroup block set up by \@doantnote and
% \@endantnote, so the catcode for > is back to 12 for the
% next note.
%
\edef\@tempa{`\string >}%
\ifnum\catcode\@tempa=12%
\let\@ResetGT\relax
\else
\edef\@ResetGT{\noexpand\catcode\@tempa=\the\catcode\@tempa}%
\@makeother\>%
\fi
\def\@doantnote##1##2>{\def\@thetnmark{##1}\par\begingroup
\@ResetGT
\edef\@currentlabel{\csname p@tabnote\endcsname\@thetnmark}%
\tnoteformat}
\def\@endantnote{\par\endgroup}%
\tnoteheading
\tnotesize
\input{\jobname.tne}%
\endgroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|