Debian Codegraph @

texmf-dist/source/latex/mdwtools/footnote.dtx

raw
1 % \begin{meta-comment}
2 %
3 % $Id: footnote.dtx,v 1.13 1997/01/28 19:45:16 mdw Exp $
4 %
5 % Save footnotes around boxing environments and things
6 %
7 % (c) 1996 Mark Wooding
8 %
9 %----- Revision history -----------------------------------------------------
10 %
11 % $Log: footnote.dtx,v $
12 % Revision 1.13 1997/01/28 19:45:16 mdw
13 % Fixed stupid bug in AMS environment handling which stops the thing from
14 % working properly if you haven't included amsmath. Doh.
15 %
16 % Revision 1.12 1997/01/18 00:45:37 mdw
17 % Fix problems with duplicated footnotes in broken AMS environments which
18 % typeset things multiple times. This is a nasty kludge.
19 %
20 % Revision 1.11 1996/11/19 20:50:05 mdw
21 % Entered into RCS
22 %
23 %
24 % \end{meta-comment}
25 %
26 % \begin{meta-comment} <general public licence>
27 %%
28 %% footnote package -- Save footnotes around boxing environments
29 %% Copyright (c) 1996 Mark Wooding
30 %<*package>
31 %%
32 %% This program is free software; you can redistribute it and/or modify
33 %% it under the terms of the GNU General Public License as published by
34 %% the Free Software Foundation; either version 2 of the License, or
35 %% (at your option) any later version.
36 %%
37 %% This program is distributed in the hope that it will be useful,
38 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
39 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40 %% GNU General Public License for more details.
41 %%
42 %% You should have received a copy of the GNU General Public License
43 %% along with this program; if not, write to the Free Software
44 %% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
45 %</package>
46 %%
47 % \end{meta-comment}
48 %
49 % \begin{meta-comment} <Package preamble>
50 %<+package>\NeedsTeXFormat{LaTeX2e}
51 %<+package>\ProvidesPackage{footnote}
52 %<+package> [1997/01/28 1.13 Save footnotes around boxes]
53 % \end{meta-comment}
54 %
55 % \CheckSum{327}
56 %\iffalse
57 %<*package>
58 %\fi
59 %% \CharacterTable
60 %% {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
61 %% 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
62 %% Digits \0\1\2\3\4\5\6\7\8\9
63 %% Exclamation \! Double quote \" Hash (number) \#
64 %% Dollar \$ Percent \% Ampersand \&
65 %% Acute accent \' Left paren \( Right paren \)
66 %% Asterisk \* Plus \+ Comma \,
67 %% Minus \- Point \. Solidus \/
68 %% Colon \: Semicolon \; Less than \<
69 %% Equals \= Greater than \> Question mark \?
70 %% Commercial at \@ Left bracket \[ Backslash \\
71 %% Right bracket \] Circumflex \^ Underscore \_
72 %% Grave accent \` Left brace \{ Vertical bar \|
73 %% Right brace \} Tilde \~}
74 %%
75 %\iffalse
76 %</package>
77 %\fi
78 %
79 % \begin{meta-comment} <driver>
80 %
81 %<*driver>
82 \input{mdwtools}
83 \describespackage{footnote}
84 \mdwdoc
85 %</driver>
86 %
87 % \end{meta-comment}
88 %
89 % \section{User guide}
90 %
91 % This package provides some commands for handling footnotes slightly
92 % better than \LaTeX\ usually does; there are several commands and
93 % environments (notably |\parbox|, \env{minipage} and \env{tabular}
94 % \begin{footnote}
95 % The \package{mdwtab} package, provided in this distribution, handles
96 % footnotes correctly anyway; it uses an internal version of this package
97 % to do so.
98 % \end{footnote})
99 % which `trap' footnotes so that they can't escape and appear at the bottom
100 % of the page.
101 %
102 % \DescribeEnv{savenotes}
103 % The \env{savenotes} environment saves up any footnotes encountered within
104 % it, and performs them all at the end.
105 %
106 % \DescribeMacro{\savenotes}
107 % \DescribeMacro{\spewnotes}
108 % If you're defining a command or environment, you can use the |\savenotes|
109 % command to start saving up footnotes, and the |\spewnotes| command to
110 % execute them all at the end. Note that |\savenotes| and |\spewnotes|
111 % enclose a group, so watch out. You can safely nest the commands and
112 % environments -- they work out if they're already working and behave
113 % appropriately.
114 %
115 % \DescribeEnv{minipage*}
116 % To help things along a bit, the package provides a $*$-version of the
117 % \env{minipage} environment, which doesn't trap footnotes for itself (and
118 % in fact sends any footnotes it contains to the bottom of the page, where
119 % they belong).
120 %
121 % \DescribeMacro{\makesavenoteenv}
122 % The new \env{minipage$*$} environment was created with a magic command
123 % called |\makesavenoteenv|. It has a fairly simple syntax:
124 %
125 % \begin{grammar}
126 % <make-save-note-env-cmd> ::= \[[
127 % "\\makesavenoteenv"
128 % \begin{stack} \\ "[" <new-env-name> "]" \end{stack}
129 % "{" <env-name> "}"
130 % \]]
131 % \end{grammar}
132 %
133 % Without the optional argument, it redefines the named environment so that
134 % it handles footnotes correctly. With the optional argument, it makes
135 % the new environment named by \<new-env-name> into a footnote-friendly
136 % version of the \<env-name> environment.
137 %
138 % \DescribeMacro{\parbox}
139 % The package also redefines the |\parbox| command so that it works properly
140 % with footnotes.
141 %
142 % \DescribeEnv{footnote}
143 % The other problem which people tend to experience with footnotes is that
144 % you can't put verbatim text (with the |\verb| comamnd or the \env{verbatim}
145 % environment) into the |\footnote| command's argument. This package
146 % provides a \env{footnote} \emph{environment}, which \emph{does} allow
147 % verbatim things. You use the environment just like you do the command.
148 % It's really easy. It even has an optional argument, which works the same
149 % way.
150 %
151 % \DescribeEnv{footnotetext}
152 % To go with the \env{footnote} environment, there's a \env{footnotetext}
153 % environment, which just puts the text in the bottom of the page, like
154 % |\footnotetext| does.
155 %
156 % There's a snag with these environments, though. Some other nonstandard
157 % environments, like \env{tabularx}, try to handle footnotes their own
158 % way, because they won't work otherwise. The way they do this is not
159 % compatible with the way that the \env{footnote} and \env{footnotetext}
160 % environments work, and you will get strange results if you try (there'll
161 % be odd vertical spacing, and the footnote text may well be incorrect).
162 % \begin{footnote}
163 % The solution to this problem is to send mail to David Carlisle persuading
164 % him to use this package to handle footnotes, rather than doing it his
165 % way.
166 % \end{footnote}
167 %
168 % \implementation
169 %
170 % \section{Implementation}
171 %
172 % Most implementations of footnote-saving (in particular, that used in
173 % the \package{tabularx} and \package{longtable} packages) use a token
174 % list register to store the footnote text, and then expand it when whatever
175 % was preventing footnotes (usually a vbox) stops. This is no good at all
176 % if the footnotes contain things which might not be there by the time the
177 % expansion occurs. For example, references to things in temporary boxes
178 % won't work.
179 %
180 % This implementation therefore stores the footnotes up in a box register.
181 % This must be just as valid as using tokens, because all I'm going to do
182 % at the end is unbox the box).
183 %
184 % \begin{macrocode}
185 %<*macro|package>
186 \ifx\fn@notes\@@undefined%
187 \newbox\fn@notes%
188 \fi
189 % \end{macrocode}
190 %
191 % I'll need a length to tell me how wide the footnotes should be at the
192 % moment.
193 %
194 % \begin{macrocode}
195 \newdimen\fn@width
196 % \end{macrocode}
197 %
198 % Of course, I can't set this up until I actually start saving footnotes.
199 % Until then I'll use |\columnwidth| (which works in \package{multicol}
200 % even though it doesn't have any right to).
201 %
202 % \begin{macrocode}
203 \let\fn@colwidth\columnwidth
204 % \end{macrocode}
205 %
206 % And now a switch to remember if we're already handling footnotes,
207 %
208 % \begin{macrocode}
209 \newif\if@savingnotes
210 % \end{macrocode}
211 %
212 %
213 % \subsection{Building footnote text}
214 %
215 % I need to emulate \LaTeX's footnote handling when I'm putting the notes
216 % into my box; this is also useful in the verbatim-in-footnotes stuff.
217 %
218 % \begin{macro}{\fn@startnote}
219 %
220 % Here's how a footnote gets started. Most of the code here is stolen
221 % from |\@footnotetext|.
222 %
223 % \begin{macrocode}
224 \def\fn@startnote{%
225 \hsize\fn@colwidth%
226 \interlinepenalty\interfootnotelinepenalty%
227 \reset@font\footnotesize%
228 \floatingpenalty\@MM% Is this right???
229 \@parboxrestore%
230 \protected@edef\@currentlabel{\csname p@\@mpfn\endcsname\@thefnmark}%
231 \color@begingroup%
232 }
233 % \end{macrocode}
234 %
235 % \end{macro}
236 %
237 % \begin{macro}{\fn@endnote}
238 %
239 % Footnotes are finished off by this macro. This is the easy bit.
240 %
241 % \begin{macrocode}
242 \let\fn@endnote\color@endgroup
243 % \end{macrocode}
244 %
245 % \end{macro}
246 %
247 %
248 % \subsection{Footnote saving}
249 %
250 % \begin{macro}{\fn@fntext}
251 %
252 % Now to define how to actually do footnotes. I'll just add the notes to
253 % the bottom of the footnote box I'm building.
254 %
255 % There's some hacking added here to handle the case that a footnote is
256 % in an |\intertext| command within a broken \package{amsmath} alignment
257 % environment -- otherwise the footnotes get duplicated due to the way that
258 % that package measures equations.
259 % \begin{footnote}
260 % The correct solution of course is to
261 % implement aligning environments in a sensible way, by building the table
262 % and leaving penalties describing the intended format, and then pick that
263 % apart in a postprocessing phase. If I get the time, I'll start working
264 % on this again. I have a design worked out and the beginnings of an
265 % implementation, but it's going to be a long time coming.
266 % \end{footnote}
267 %
268 % \begin{macrocode}
269 \def\fn@fntext#1{%
270 \ifx\ifmeasuring@\@@undefined%
271 \expandafter\@secondoftwo\else\expandafter\@iden%
272 \fi%
273 {\ifmeasuring@\expandafter\@gobble\else\expandafter\@iden\fi}%
274 {%
275 \global\setbox\fn@notes\vbox{%
276 \unvbox\fn@notes%
277 \fn@startnote%
278 \@makefntext{%
279 \rule\z@\footnotesep%
280 \ignorespaces%
281 #1%
282 \@finalstrut\strutbox%
283 }%
284 \fn@endnote%
285 }%
286 }%
287 }
288 % \end{macrocode}
289 %
290 % \end{macro}
291 %
292 % \begin{macro}{\savenotes}
293 %
294 % The |\savenotes| declaration starts saving footnotes, to be spewed at a
295 % later date. We'll also remember which counter we're meant to use, and
296 % redefine the footnotes used by minipages.
297 %
298 % The idea here is that we'll gather up footnotes within the environment,
299 % and output them in whatever format they were being typeset outside the
300 % environment.
301 %
302 % I'll take this a bit at a time. The start is easy: we need a group in
303 % which to keep our local definitions.
304 %
305 % \begin{macrocode}
306 \def\savenotes{%
307 \begingroup%
308 % \end{macrocode}
309 %
310 % Now, if I'm already saving footnotes away, I won't bother doing anything
311 % here. Otherwise I need to start hacking, and set the switch.
312 %
313 % \begin{macrocode}
314 \if@savingnotes\else%
315 \@savingnotestrue%
316 % \end{macrocode}
317 %
318 % I redefine the |\@footnotetext| command, which is responsible for adding
319 % a footnote to the appropriate insert. I'll redefine both the current
320 % version, and \env{minipage}'s specific version, in case there's a nested
321 % minipage.
322 %
323 % \begin{macrocode}
324 \let\@footnotetext\fn@fntext%
325 \let\@mpfootnotetext\fn@fntext%
326 % \end{macrocode}
327 %
328 % I'd better make sure my box is empty before I start, and I must set up
329 % the column width so that later changes (e.g., in \env{minipage}) don't
330 % upset things too much.
331 %
332 % \begin{macrocode}
333 \fn@width\columnwidth%
334 \let\fn@colwidth\fn@width%
335 \global\setbox\fn@notes\box\voidb@x%
336 % \end{macrocode}
337 %
338 % Now for some yuckiness. I want to ensure that \env{minipage} doesn't
339 % change how footnotes are handled once I've taken charge. I'll store the
340 % current values of |\thempfn| (which typesets a footnote marker) and
341 % |\@mpfn| (which contains the name of the current footnote counter).
342 %
343 % \begin{macrocode}
344 \let\fn@thempfn\thempfn%
345 \let\fn@mpfn\@mpfn%
346 % \end{macrocode}
347 %
348 % The \env{minipage} environment provides a hook, called |\@minipagerestore|.
349 % Initially it's set to |\relax|, which is unfortunately unexpandable, so if
350 % I want to add code to it, I must check this possibility. I'll make it
351 % |\@empty| (which expands to nothing) if it's still |\relax|. Then I'll
352 % add my code to the hook, to override |\thempfn| and |\@mpfn| set up by
353 % \env{minipage}.
354 %
355 % Note that I can't just force the |mpfootnote| counter to be equal to
356 % the |footnote| one, because \env{minipage} clears |\c@mpfootnote| to zero
357 % when it starts. This method will ensure that even so, the current counter
358 % works OK.
359 %
360 % \begin{macrocode}
361 \ifx\@minipagerestore\relax\let\@minipagerestore\@empty\fi%
362 \expandafter\def\expandafter\@minipagerestore\expandafter{%
363 \@minipagerestore%
364 \let\thempfn\fn@thempfn%
365 \let\@mpfn\fn@mpfn%
366 }%
367 \fi%
368 }
369 % \end{macrocode}
370 %
371 % \end{macro}
372 %
373 % \begin{macro}{\spewnotes}
374 %
375 % Now I can spew out the notes we saved. This is a bit messy, actually.
376 % Since the standard |\@footnotetext| implementation tries to insert funny
377 % struts and things, I must be a bit careful. I'll disable all this bits
378 % which start paragraphs prematurely.
379 %
380 % \begin{macrocode}
381 \def\spewnotes{%
382 \endgroup%
383 \if@savingnotes\else\ifvoid\fn@notes\else\begingroup%
384 \let\@makefntext\@empty%
385 \let\@finalstrut\@gobble%
386 \let\rule\@gobbletwo%
387 \@footnotetext{\unvbox\fn@notes}%
388 \endgroup\fi\fi%
389 }
390 % \end{macrocode}
391 %
392 % \end{macro}
393 %
394 % Now make an environment, for users.
395 %
396 % \begin{macrocode}
397 \let\endsavenotes\spewnotes
398 % \end{macrocode}
399 %
400 % That's all that needs to be in the shared code section.
401 %
402 % \begin{macrocode}
403 %</macro|package>
404 %<*package>
405 % \end{macrocode}
406 %
407 %
408 % \subsection{The \env{footnote} environment}
409 %
410 % Since |\footnote| is a command with an argument, things like \env{verbatim}
411 % are unwelcome in it. Every so often someone on |comp.text.tex| moans
412 % about it and I post a nasty hack to make it work. However, as a more
413 % permanent and `official' solution, here's an environment which does the
414 % job rather better. Lots of this is based on code from my latest attempt
415 % on the newsgroup.
416 %
417 % I'll work on this in a funny order, although I think it's easier to
418 % understand. First, I'll do some macros for reading the optional argument
419 % of footnote-related commands.
420 %
421 % \begin{macro}{\fn@getmark}
422 %
423 % Saying \syntax{"\\fn@getmark{"<default-code>"}{"<cont-code>"}"} will read
424 % an optional argument giving a value for the footnote counter; if the
425 % argument isn't there, the \<default-code> is executed, and it's expected
426 % to set up the appropriate counter to the current value. The footnote
427 % marker text is stored in the macro |\@thefnmark|, as is conventional for
428 % \LaTeX's footnote handling macros. Once this is done properly, the
429 % \<cont-code> is called to continue handling things.
430 %
431 % Since the handling of the optional argument plays with the footnote
432 % counter locally, I'll start a group right now to save some code. Then I'll
433 % decide what to do based on the presence of the argument.
434 %
435 % \begin{macrocode}
436 \def\fn@getmark#1#2{%
437 \begingroup%
438 \@ifnextchar[%
439 {\fn@getmark@i{#1}}%
440 {#1\fn@getmark@ii{#2}}%
441 }
442 % \end{macrocode}
443 %
444 % There's an optional argument, so I need to read it and assign it to the
445 % footnote counter.
446 %
447 % \begin{macrocode}
448 \def\fn@getmark@i#1[#2]{%
449 \csname c@\@mpfn\endcsname#2%
450 \fn@getmark@ii%
451 }
452 % \end{macrocode}
453 %
454 % Finally, set up the macro properly, and end the group.
455 %
456 % \begin{macrocode}
457 \def\fn@getmark@ii#1{%
458 \unrestored@protected@xdef\@thefnmark{\thempfn}%
459 \endgroup%
460 #1%
461 }
462 % \end{macrocode}
463 %
464 % \end{macro}
465 %
466 % From argument reading, I'll move on to footnote typesetting.
467 %
468 % \begin{macro}{\fn@startfntext}
469 %
470 % The |\fn@startfntext| macro sets everything up for building the footnote
471 % in a box register, ready for unboxing into the footnotes insert. The
472 % |\fn@prefntext| macro is a style hook I'll set up later.
473 %
474 % \begin{macrocode}
475 \def\fn@startfntext{%
476 \setbox\z@\vbox\bgroup%
477 \fn@startnote%
478 \fn@prefntext%
479 \rule\z@\footnotesep%
480 \ignorespaces%
481 }
482 % \end{macrocode}
483 %
484 % \end{macro}
485 %
486 % \begin{macro}{\fn@endfntext}
487 %
488 % Now I'll end the vbox, and add it to the footnote insertion. Again, I
489 % must be careful to prevent |\@footnotetext| from adding horizontal mode
490 % things in bad places.
491 %
492 % \begin{macrocode}
493 \def\fn@endfntext{%
494 \@finalstrut\strutbox%
495 \fn@postfntext%
496 \egroup%
497 \begingroup%
498 \let\@makefntext\@empty%
499 \let\@finalstrut\@gobble%
500 \let\rule\@gobbletwo%
501 \@footnotetext{\unvbox\z@}%
502 \endgroup%
503 }
504 % \end{macrocode}
505 %
506 % \end{macro}
507 %
508 % \begin{environment}{footnote}
509 %
510 % I can now start on the environment proper. First I'll look for an
511 % optional argument.
512 %
513 % \begin{listing}
514 %\def\footnote{%
515 % \end{listing}
516 %
517 % Oh. I've already come up against the first problem: that name's already
518 % used. I'd better save the original version.
519 %
520 % \begin{macrocode}
521 \let\fn@latex@@footnote\footnote
522 % \end{macrocode}
523 %
524 % The best way I can think of for seeing if I'm in an environment is to
525 % look at |\@currenvir|. I'll need something to compare with, then.
526 %
527 % \begin{macrocode}
528 \def\fn@footnote{footnote}
529 % \end{macrocode}
530 %
531 % Now to start properly. |;-)|
532 %
533 % \begin{macrocode}
534 \def\footnote{%
535 \ifx\@currenvir\fn@footnote%
536 \expandafter\@firstoftwo%
537 \else%
538 \expandafter\@secondoftwo%
539 \fi%
540 {\fn@getmark{\stepcounter\@mpfn}%
541 {\leavevmode\unskip\@footnotemark\fn@startfntext}}%
542 {\fn@latex@@footnote}%
543 }
544 % \end{macrocode}
545 %
546 % Ending the environment is simple.
547 %
548 % \begin{macrocode}
549 \let\endfootnote\fn@endfntext
550 % \end{macrocode}
551 %
552 % \end{environment}
553 %
554 % \begin{environment}{footnotetext}
555 %
556 % I'll do the same magic as before for |\footnotetext|.
557 %
558 % \begin{macrocode}
559 \def\fn@footnotetext{footnotetext}
560 \let\fn@latex@@footnotetext\footnotetext
561 \def\footnotetext{%
562 \ifx\@currenvir\fn@footnotetext%
563 \expandafter\@firstoftwo%
564 \else%
565 \expandafter\@secondoftwo%
566 \fi%
567 {\fn@getmark{}\fn@startfntext}%
568 {\fn@latex@@footnotetext}%
569 }
570 \let\endfootnotetext\endfootnote
571 % \end{macrocode}
572 %
573 % \end{environment}
574 %
575 % \begin{macro}{\fn@prefntext}
576 % \begin{macro}{\fn@postfntext}
577 %
578 % Now for one final problem. The style hook for footnotes is the command
579 % |\@makefntext|, which takes the footnote text as its argument. Clearly
580 % this is utterly unsuitable, so I need to split it into two bits, where
581 % the argument is. This is very tricky, and doesn't deserve to work,
582 % although it appears to be a good deal more effective than it has any right
583 % to be.
584 %
585 % \begin{macrocode}
586 \long\def\@tempa#1\@@#2\@@@{\def\fn@prefntext{#1}\def\fn@postfntext{#2}}
587 \expandafter\@tempa\@makefntext\@@\@@@
588 % \end{macrocode}
589 %
590 % \end{macro}
591 % \end{macro}
592 %
593 %
594 % \subsection{Hacking existing environments}
595 %
596 % Some existing \LaTeX\ environments ought to have footnote handling but
597 % don't. Now's our chance.
598 %
599 % \begin{macro}{\makesavenoteenv}
600 %
601 % The |\makesavenoteenv| command makes an environment save footnotes around
602 % itself.
603 %
604 % It would also be nice to make |\parbox| work with footnotes. I'll do this
605 % later.
606 %
607 % \begin{macrocode}
608 \def\makesavenoteenv{\@ifnextchar[\fn@msne@ii\fn@msne@i}
609 % \end{macrocode}
610 %
611 % We're meant to redefine the environment. We'll copy it (using |\let|) to
612 % a magic name, and then pass it on to stage~2.
613 %
614 % \begin{macrocode}
615 \def\fn@msne@i#1{%
616 \expandafter\let\csname msne$#1\expandafter\endcsname%
617 \csname #1\endcsname%
618 \expandafter\let\csname endmsne$#1\expandafter\endcsname%
619 \csname end#1\endcsname%
620 \fn@msne@ii[#1]{msne$#1}%
621 }
622 % \end{macrocode}
623 %
624 % Now we'll define the new environment. The start is really easy, since we
625 % just need to insert a |\savenotes|. The end is more complex, since we
626 % need to preserve the |\if@endpe| flag so that |\end| can pick it up. I
627 % reckon that proper hooks should be added to |\begin| and |\end| so that
628 % environments can define things to be done outside the main group as
629 % well as within it; still, we can't all have what we want, can we?
630 %
631 % \begin{macrocode}
632 \def\fn@msne@ii[#1]#2{%
633 \expandafter\edef\csname#1\endcsname{%
634 \noexpand\savenotes%
635 \expandafter\noexpand\csname#2\endcsname%
636 }%
637 \expandafter\edef\csname end#1\endcsname{%
638 \expandafter\noexpand\csname end#2\endcsname%
639 \noexpand\expandafter%
640 \noexpand\spewnotes%
641 \noexpand\if@endpe\noexpand\@endpetrue\noexpand\fi%
642 }%
643 }
644 % \end{macrocode}
645 %
646 % \end{macro}
647 %
648 % \begin{environment}{minipage*}
649 %
650 % Let's define a \env{minipage$*$} environment which handles footnotes
651 % nicely. Really easy:
652 %
653 % \begin{macrocode}
654 \makesavenoteenv[minipage*]{minipage}
655 % \end{macrocode}
656 %
657 % \end{environment}
658 %
659 % \begin{macro}{\parbox}
660 %
661 % Now to alter |\parbox| slightly, so that it handles footnotes properly.
662 % I'm going to do this fairly inefficiently, because I'm going to try and
663 % change it as little as possible.
664 %
665 % First, I'll save the old |\parbox| command. If I don't find a \lit{*},
666 % I'll just call this command.
667 %
668 % \begin{macrocode}
669 \let\fn@parbox\parbox
670 % \end{macrocode}
671 %
672 % This is the clever bit: I don't know how many optional arguments
673 % Mr~Mittelbach and his chums will add to |\parbox|, so I'll handle any
674 % number. I'll store them all up in my first argument and call myself
675 % every time I find a new one. If I run out of optional arguments,
676 % I'll call the original |\parbox| command, surrounding it with |\savenotes|
677 % and |\spewnotes|.
678 %
679 % \begin{macrocode}
680 \def\parbox{\@ifnextchar[{\fn@parbox@i{}}{\fn@parbox@ii{}}}
681 \def\fn@parbox@i#1[#2]{%
682 \@ifnextchar[{\fn@parbox@i{#1[#2]}}{\fn@parbox@ii{#1[#2]}}%
683 }
684 \long\def\fn@parbox@ii#1#2#3{\savenotes\fn@parbox#1{#2}{#3}\spewnotes}
685 % \end{macrocode}
686 %
687 % \end{macro}
688 %
689 % Done!
690 %
691 % \begin{macrocode}
692 %</package>
693 % \end{macrocode}
694 %
695 % \hfill Mark Wooding, \today
696 %
697 % \Finale
698 %
699 \endinput