summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/savefnmark/savefnmark.dtx
blob: 765c4a373186dfc61fff740452df7a671bebef68 (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
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
% \iffalse meta-comment
% %%----------------------------------------------------------------------------
%
%% File: savefnmark.dtx Copyright (C) 2000 Volker Kuhlmann
%% All rights are reserved.
%%
%
%<*dtx>
        \NeedsTeXFormat{LaTeX2e}[1999/06/01]
        \ProvidesFile{savefnmark.dtx}
%</dtx>
%<package|maindoc>\NeedsTeXFormat{LaTeX2e}[1998/06/01]
%<package>\ProvidesPackage{savefnmark}
%<driver> \ProvidesFile{savefnmark.drv}
%<maindoc>\ProvidesFile{savefnmark.tex}
%
% \fi
%         \ProvidesFile{savefnmark.dtx}
       [2000/05/11 v1.0 save footnote marks for multiple use (VK)]
%
%%
%% \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         \~}
%%
%
% \iffalse
%<*driver>

\NeedsTeXFormat{LaTeX2e}[1999/06/01]
\documentclass{ltxdoc}
%%\IfFileExists{ltxdoc.cfg}{}{\OnlyDescription\RecordChanges\CodelineIndex}

 %\OnlyDescription                  % uncomment to suppress code line listing
 \RecordChanges                    % uncomment for a change history
 %\CodelineIndex\EnableCrossrefs    % uncomment for command index
\GetFileInfo{savefnmark.dtx}

\usepackage{savefnmark}

\begin{document}
\DocInput{savefnmark.dtx}
%%\IfFileExists{ltxdoc.cfg}{}{\PrintChanges\PrintIndex}
 \PrintChanges                     % uncomment for a change history
 %\PrintIndex                       % uncomment for command index
\end{document}

%</driver>
% \fi
%
%
% \GetFileInfo{savefnmark.dtx}
% \CheckSum{30}
%
% \title{The \textsf{savefnmark} Package\thanks
%        {This file has version number \fileversion,
%         last modified \filedate.}}
% \author{Volker Kuhlmann\thanks{%^^A
%         Email:\ \url{v.kuhlmann@elec.canterbury.ac.nz}.
%   	  For a postal address refer to the license section.}}
% \date{\filedate}
%
%
% %^^A  MACROS used for this document
% \let\package\textsf
% \let\env\textsf
% \let\url\texttt
% \newcommand\optmeta[1]{[\meta{#1}]}
% \providecommand\MF{\textsc{meta-font}}
% \providecommand\fixendverbatim{\vspace{-\bigskipamount}}
% \newenvironment{pckcmd}{%^^A
%   \ifvmode \else \par\vspace{-\parskip}\fi
%   \vspace{1mm}\noindent \hangindent 4em\hangafter 0\ignorespaces
%   }{%^^A
%   \par\vspace{1mm}\vspace{-\parskip}}
% \renewenvironment{quote}{%
%   \list{}{\leftmargin=0.5\leftmargin\rightmargin\leftmargin}\item\relax
%   }{%
%   \endlist
%   }
% \makeatletter
% \providecommand\DescribeWord[1]{%
%   \leavevmode\@bsphack
%   \marginpar{\raggedleft\PrintDescribeEnv{#1}}%^^A
%   \@bsphack\index{#1\actualchar{\protect\ttfamily#1}\encapchar usage}\@esphack
%   \@esphack\ignorespaces
%   }
% \makeatother
%
% \changes{v1.0}{2000/05/10}
%   {Initial version.}
%
%
%
% \maketitle
%
% \begin{abstract}
% Sometimes the same footnote applies to more than one location in a table. With
% this package the mark of a footnote can be saved into a name, and re-used
% subsequently without creating another footnote at the bottom.
% \end{abstract}
%
% \tableofcontents
%
%
% \section{License}
%
% This package is copyright \textcopyright\ 2000 by:
%
% \begin{quote}
%   Volker Kuhlmann,
%   c/o University of Canterbury,
%   ELEC Dept, Creyke Road,
%   Christchurch, New Zealand\\
%   E-Mail: \url{v.kuhlmann@elec.canterbury.ac.nz}
% \end{quote}
%
%     This program is free software; you can redistribute it and/or modify
%     it under the terms of the GNU General Public License as published by
%     the Free Software Foundation; either version 2 of the License, or
%     (at your option) any later version.
%
% To obtain a copy of the license, write to the
% Free Software Foundation, Inc.,
% 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA,
% or browse \url{http://www.fsf.org/}.
%
%
% \section{Introduction}
%
% Sometimes the same footnote applies to more than one location in a table. With
% this package the mark of a footnote can be saved into a name, and re-used
% subsequently without creating another footnote at the bottom.
% 
% This even works between tables (in minipages) and footnotes in surrounding
% text. The appearance of the footnote mark is kept, that is when a footnote of
% a previous table is mentioned in the text following the table, the mark looks
% the same as it does in the table.
% 
% The footnote marks are saved globally into a given control sequence. This
% control sequence must not have already been used and is defined for the whole
% of the document.
% 
% \pagebreak
%
% Currently forward references are not possible. In other words footnotes which
% appear later in the text can't be referenced.
%
% \DescribeMacro{\saveFN}
% The following two commands are defined by this package:
% 
% \begin{pckcmd}
%     |\saveFN{|\meta{name}|}|
% \end{pckcmd}
% 
% saves the number of the footnote which was last introduced into \meta{name}.
% \meta{name} can be any valid control sequence not already used.
%
% \DescribeMacro{\useFN}
% To place the same footnote mark again later in the text, use
% 
% \begin{pckcmd}
%     |\useFN{|\meta{name}|}|
% \end{pckcmd}
%
%
% \section{Example}
%
% The following example is produced with this input:
% 
% %^^A************************************************************************
% \begingroup
% \small
% \begin{verbatim}
% Surrounding text before the minipage with table.
% text text text\footnote{footnote 1 in text} text
% text\footnote{footnote 2 in text; also in table}\saveFN\sft\ text text text 
% 
% \begin{minipage}{\textwidth}
% \begin{tabular}{lll}
% abc
%         &abc abc abc\footnote{footnote 1}\saveFN\sfn    
%                 &abc\\
% abc abc abc
%         &abc abcdef efgh\footnote{footnote 2} abc
%                 &same mark as first\useFN\sfn\ footnote\\
% www\footnote{footnote 3}
%         &mark as text\useFN\sft\ footnote 
%                 &abc\\
% \end{tabular}
% \end{minipage}
% 
% Surrounding text after the minipage with table.
% text text text\footnote{footnote 3 in text} text text text 
% \end{verbatim}
% \fixendverbatim
% \endgroup
% %^^A************************************************************************
% 
% \parskip	2.5ex
% \parindent	0em
% 
% Surrounding text before the minipage with table.
% text text text\footnote{footnote 1 in text} text
% text\footnote{footnote 2 in text; also in table}\saveFN\sft\ text text text 
% 
% \begin{minipage}{\textwidth}
% \begin{tabular}{lll}
% abc
% 	&abc abc abc\footnote{footnote 1}\saveFN\sfn	
% 		&abc\\
% abc abc abc
% 	&abc abcdef efgh\footnote{footnote 2} abc
% 		&same mark as first\useFN\sfn\ footnote\\
% www\footnote{footnote 3}
% 	&mark as text\useFN\sft\ footnote 
% 		&abc\\
% \end{tabular}
% \end{minipage}
% 
% Surrounding text after the minipage with table.
% text text text\footnote{footnote 3 in text} text text text 
% 
%
% \section{To Do and Bugs}
% 
% Any bugs?
% 
% Is it worth implementing a forward reference capability?
%
%
% %^^A This command extracts all index entries:
% %^^A sed < savefnmark.idx -e 's,indexentry{,,' -e 's,=.*$,,'
%
% \DoNotIndex{\ ,\.,\_}%^^A  DOES NOT WORK!!
% \DoNotIndex{\@footnotetext,\@mpfn,\@xfootnote,\begingroup,\csname,\def}
% \DoNotIndex{\endcsname,\endgroup,\expandafter,\let,\newcommand,\noexpand}
% \DoNotIndex{\relax,\show,\the,\thempfn,\xdef}
%
% \StopEventually{}
%
%
%
% \section{Implementation}
%
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
% \begin{macro}{\saveFN}
% First part: save the footnote number and whether it was a normal footnote or
% one from inside a minipage. We test first whether the control sequence to save
% it in is already defined.
%
%    \begin{macrocode}
\newcommand\saveFN[1]{%
    \newcommand{#1}{}%
    \xdef#1{\noexpand\@useFN{\@mpfn}{\the\csname c@\@mpfn\endcsname}}%
    %\show#1%
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\useFN}
% Start a new group and temporarily disable the creation of the footnote text by
% \cs{@xfootnote}, then run the command defined when saving the mark. This
% restores the footnote type and its number, then prints the corresponding mark.
%
%    \begin{macrocode}
\newcommand\useFN[1]{\begingroup\let\@footnotetext\relax#1\endgroup}
\newcommand\@useFN[2]{%
    \def\@mpfn{#1}%
    \expandafter\let\expandafter\thempfn\csname the#1\endcsname
    \@xfootnote[#2]%
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
%
% \Finale
%
% \iffalse
% %% EOF savefnmark.dtx
% %%----------------------------------------------------------------------------
% \fi