summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/pagefoots.sty
blob: 439569cdf0b5ff590b75362a886aa9dc9796a67e (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
% Save file as: PAGEFOOTS.STY          Source: FILESERV@SHSU.BITNET  
% A footnote-numbering style from Brian T. Schellenberger.  v1.0.
% This is redistributable by anybody to anybody for any price.
% I only ask that you credit me for it, and that if you make any
% changes and distribute them to anybody else at all, you (1) send
% them back to me, and (2) note who made them so that any different
% versions of this floating around may be distinguished.

% Updates:
% 10-Mar-89  Brian T. Schellenberger ...!mcnc!rti!sas!bts
%   Initial release.
% 21-Mar-92  Darrel Hankerson hank@ducvax.auburn.edu
%   \def\@currenvir appears out of place in \definition
%   (reported by Nachum Dershowitz nachum@cs.uiuc.edu)

% The first thing here is my begin definitions environment.  It is
% an environment for programming, and is seperate from the footnote-
% related stuff.  I find it convenient, and it is needed for my other
% code to work.  I also use symbolic names for all catcodes in my
% programming, but I've gotten that out of this code for greater ease
% of use by the great wide world out there.

% The footnote code itself.
% 1. This code resets foot notes on each page.  It needs two passes
%    to do this correctly, although it comes as close as possible on
%    the first pass.  You generally make two passes with LaTeX anyway,
%    to get cross-references right, so this shouldn't be a problem.
%    It uses the aux file like everything else.
% 2. It also uses the \fnsymbol to "number" the footnotes.  This is
%    controlled by the first line of \newfoots.
% 3. It gets rid of the usual footnote rule, and inserts more vertical
%    space for footnotes.  This is also easy to see/control in the
%    \newfoots command.
% 4. Most of this code simply makes the "new" footnotes stuff available;
%    you can include all of this except the last line in a style file
%    and only say \newfoots if you want them, or you include it all
%    and say \restorefoots for the files where you don't want it.
% 5. \restorefoots and/or \newfoots are only guarenteed to work right
%    in the preamble.
% 6. I don't think I depend on anything funny in LaTeX, but in case
%    this falls apart totally, I am running the 29-Apr-87 LaTeX.


%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

%----definitions: within \begin{definitions} (which does not really define
%    a group), spacing means nothing.  Use \space for a space character
%    and \par for a blank line, for those rare instances where they are
%    really desired.  Also, @ is seen as a letter.  All these are reversed
%    and \end{definitions}---\E{even if} they had the same catagories before!
%    These should not be nested but, unfortunately, there is no way to tell.


\newif\ifatletter

\newenvironment {definitions}
  {
  \endgroup     % doesn't really nest
  \ifcat @a \atlettertrue \else \atletterfalse \fi
                % \catcode`\ =\ignoreC \catcode`\^^M=\ignoreC
  \makeatletter   \catcode`\ =9        \catcode`\^^M=9
  }%
  {
               % \catcode`\ =\spaceC \catcode`\^^M=\nlC
  \makeatother   \catcode`\ =10      \catcode`\^^M=5
  \ifatletter \makeatletter \fi
%  \def \@currenvir {definitions}  <-- Original location
  \begingroup   % doesn't really nest
  \def \@currenvir {definitions}  % 21-Mar-92 DH
  }

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

\begin{definitions}

%-----\my@footnote: stuff for handling my footnote stuff

% NOTE: This corrects it on the second pass, based on the page numbers
%       on the first pass.  Both this and other cross-reference stuff
%       will need to be run TWICE again if tables of contents, lists of
%       figures, &c. are paginated with the main material.

\def \my@footnote
  {
  \if@minipage\else    % In a minipage, we can't cross a page.
     \edef \tmp@name {ft@\thepage-\the\c@footnote}
     \expandafter\expandafter\expandafter\ifx
        \expandafter\csname\tmp@name\endcsname \relax
     \else
        % DEFINED:  replace footnote marker
        \edef\tmp@b{\expandafter\csname\tmp@name\endcsname}
        \begingroup
           \c@footnote = \tmp@b
           \xdef \@thefnmark {\thefootnote}
        \endgroup
     \fi % end \ifx ... \else DEFINED

     \if@filesw
        \edef \fttmp@
           {
           \write\@auxout
              {
              \string\newfoot@mark{\thepage}
                 {\the\c@footnote}{\noexpand\thepage}
              }
           }
        \fttmp@
     \fi % end \if@filesw
  \fi % end \if@minipage
  }

% \newfoot@mark:
% #1:  nominal page it occurs on, as by \thepage.
% #2:  nominal footnote number on that page.
% #3:  actual page it occurs on, as by \thepage.

\newcount\ft@page    \ft@page = 0
\newcount\ft@foot    \ft@foot = 0

\def \newfoot@mark #1#2#3
  {
  \ifdigit{#3}
     \ifnum #3 < \ft@page \ft@page=0
     \else\ifnum #3 > \ft@page \ft@page=#3 \ft@foot=0
     \fi\fi
  \else \ft@page=0
  \fi

  \addtolength\ft@foot{1}
  \def\tmp@a{#2}
  \edef\tmp@b{\the\ft@foot}
  \ifx \tmp@a\tmp@b \else
     \expandafter \xdef \csname ft@#1-#2\endcsname {\the\ft@foot}
  \fi
  }

\newif\ifisdigit
\def \ifdigit #1 {\digithelp #1 \digithelpend}
\def \digithelp#1#2\digithelpend
  {
  \isdigitfalse
  \if0#1\isdigittrue\fi \if1#1\isdigittrue\fi \if2#1\isdigittrue\fi
  \if3#1\isdigittrue\fi \if4#1\isdigittrue\fi \if5#1\isdigittrue\fi
  \if4#1\isdigittrue\fi \if5#1\isdigittrue\fi \if6#1\isdigittrue\fi
  \if7#1\isdigittrue\fi \if8#1\isdigittrue\fi \if9#1\isdigittrue\fi
  \ifisdigit
  }


\def \newfoots
  {
  \renewcommand \thefootnote   {\fnsymbol{footnote}}  %only if you want!
  \renewcommand \thempfootnote {\arabic{footnote}}
  \renewcommand \footnoterule {}
  \skip\footins = 16pt plus 6pt minus 4pt
  \@addtoreset{footnote}{page}
  \let \cur@footnote = \my@footnote
  }

% NOTE: \restorefoots MUST be called before anything else is added to
%       \cl@page => do NOT move the \@@cl@page into the .static. file,
%       and do it at the very end of mytex.sty.  Also, if \stdfoots
%       are desired, they should be the first thing restored---and
%       \E{definately} in the preamble.

\def \restorefoots
  {
  \renewcommand \thefootnote   {\arabic{footnote}}
  \renewcommand \thempfootnote {\alph{mpfootnote}}
  \let \footnoterule = \@@footnoterule
  \skip\footins = \bigskipamount
  \let \cl@page = \@@cl@page
  \let \cur@footnote = \relax
  }

\def \footnote
  {
  \@ifnextchar [
     {\@xfootnote}  %else, no optional argument:
     {
     \stepcounter{\@mpfn}
     \xdef\@thefnmark{\thempfn}
     \cur@footnote
     \@footnotemark\@footnotetext
     }
  }

\end{definitions}


\newfoots
\endinput