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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
% Lingmacros
% include
% \enumsentence, \eenumsentence, \ex
% \smalltree
% \shortex, \shortexnt (\shortexdt no longer needed)
% \clap, \ollap, \orlap, \oclap on analogy with \rlap and \llap
% \outerfs
% this file created 1/23/89 by Emma Pease, CSLI
% modified 4/1/91 by Emma Pease
% modified by Chris Manning and Avery Andrews (has Emma's mods until 8/10/92)
%Note (for those who use jbmacros):
% (a) the enumsentence macro is very similar to the \example command
% in jbmacros; however, it does not have the annoying habit of leaving
% the example number on one page and the example on the next (some
% jbmacros don't have this problem). The eenumsentence macro is very
% similar to the \examples macro.
% (b) \ex may be different
% the enumsentence macro.
%
% \enumsentence{This is an example}
% produces
% (1) This is an example
% while
% \enumsentence[(a)]{This is another example}
% produces
% (a) This is another example
%
% A related macros is
% \eenumsentence{\item[a.] A third example
% \item[b.] A fourth example}
% which produces
% (2) a. A third example
% b. A fourth example
%
% other macro is \ex{1} which produces the number of the following
% enumsentence (\ex{0} produces number of preceeding enumsentence and
% so on.)
%
% The standard \label command also works within \enumsentence and
% \eenumsentence.
%
% the \enumsentence counter. Add [chapter] if using report style
\newcounter{enums}
% \widelabel is defined for use when the width of the enumsentence or
% eenumsentence number is wider than 20pt (default labelwidth). As a
% rule of thumb if your enumerated sentences are only 1 or 2 digit
% you don't need to worry. At 3 digits, set \widelabel to 2.78pt at 4
% digits set to 7.78pt.
\newdimen\widelabel
\widelabel=0pt
\def\enumsentence{\@ifnextchar[{\@enumsentence}% %]
{\refstepcounter{enums}\@enumsentence[(\theenums)]}}
\long\def\@enumsentence[#1]#2{\begin{list}{}{%
\advance\leftmargin by\widelabel \advance\labelwidth by \widelabel}
\item[#1] #2
\end{list}}
%chris+
% The \ex definition
% modified Feb 13 1991 to provide \exn for bare example number,
% \ex for normal xref format, in parentheses.
% further modified to have (following) optional argument for sublabel
% beware if you follow it by a square bracket for other reasons!
\newcounter{tempcnt}
% this one doesn't gobble spaces while looking for a [ and so will leave a
% space after an optional argument.
\def\@ifverynextchar#1#2#3{\let\@tempe #1\def\@tempa{#2}\def
\@tempb{#3}\futurelet\@tempc\@ifvnch}
\def\@ifvnch{\ifx \@tempc \@tempe\let\@tempd\@tempa\else\let\@tempd\@tempb\fi
\@tempd}
\newcommand{\exn}[1]{\setcounter{tempcnt}{\value{enums}}%
\addtocounter{tempcnt}{#1}%
\arabic{tempcnt}}
\def\@ex#1[#2]{(\exn{#1}#2)}
\def\ex#1{\@ifverynextchar[{\@ex#1}% %]
{\@ex#1[]}}
\def\exx#1#2{(\exn{#1}--\exn{#2})}
\def\exxref#1#2{(\ref{#1}--\ref{#2})}
% \exref for label-references: (ADA 13 Feb 1991)
% allows the order \exref{-2}[b] -- which I greatly prefer. cdm.
\def\exref#1{\@ifverynextchar[{\@exref#1}% %]
{\@exref#1[]}}
\def\@exref#1[#2]{(\ref{#1}#2)}
%chris-
% modified \@item command \unhbox\@tempboxa replaces \makelabel{#1}
% Used to get \eenumsentence to work correctly
\def\@item[#1]{\if@noparitem \@donoparitem
\else \if@inlabel \indent \par \fi
\ifhmode \unskip\unskip \par \fi
\if@newlist \if@nobreak \@nbitem \else
\addpenalty\@beginparpenalty
\addvspace\@topsep \addvspace{-\parskip}\fi
\else \addpenalty\@itempenalty \addvspace\itemsep
\fi
\global\@inlabeltrue
\fi
\everypar{\global\@minipagefalse\global\@newlistfalse
\if@inlabel\global\@inlabelfalse \hskip -\parindent \box\@labels
\penalty\z@ \fi
\everypar{}}\global\@nobreakfalse
\if@noitemarg \@noitemargfalse \if@nmbrlist \refstepcounter{\@listctr}\fi \fi
\setbox\@tempboxa\hbox{\makelabel{#1}}%
\global\setbox\@labels
\hbox{\unhbox\@labels \hskip \itemindent
\hskip -\labelwidth \hskip -\labelsep
\ifdim \wd\@tempboxa >\labelwidth
\box\@tempboxa
\else \hbox to\labelwidth {\unhbox\@tempboxa}\fi
\hskip \labelsep}\ignorespaces}
% for enumerated enumsentences. Internal enumeration is alpha if not
% otherwise defined.
% counter for items within \eenumsentence. (might use enumi instead?)
\newcounter{enumsi}
% \eenumsentence{\item[a.] A third \label{bar}example \toplabel{foo}
% \item[b.] A fourth \label{baz}example}
% Testing references \ref{foo}, \ref{bar}, and \ref{baz}.
% which produces
% (3) a. A third example
% b. A fourth example
% Testing references 3, 3a, and 3b.
% To ensure that labels in \eenumsentence come out right.
%
\def\theenumsi{\theenums\alph{enumsi}}
\newdimen\eeindent
\eeindent=15pt
% changes \leftmargin increased by \eeindent
% \labelwidth increased by \eeindent
% .. .. .leftmargin.. .. .. .. ..
% oldlabelwidth eeindent labelsep actual entry
% 20pt 15pt 5pt
% (enumlabel) eelabel
% eelabel
\def\@mklab#1{\hfil#1}
\def\enummklab#1{\hfil(\eelabel)\hbox to \eeindent{\hfil#1}}
\def\enummakelabel#1{\enummklab{#1}\global\let\makelabel=\@mklab}
\def\toplabel#1{{\edef\@currentlabel{\p@enums\theenums}\label{#1}}}
\def\eenumsentence{\@ifnextchar[{\@eenumsentence}% %]
{\refstepcounter{enums}\@eenumsentence[\theenums]}}
\long\def\@eenumsentence[#1]#2{\def\eelabel{#1}\let\holdlabel\makelabel%
\begin{list}{\alph{enumsi}.}{\usecounter{enumsi}%
\advance\leftmargin by \eeindent \advance\leftmargin by \widelabel%
\advance\labelwidth by \eeindent \advance\labelwidth by \widelabel%
\let\makelabel=\enummakelabel}
#2
\end{list}\let\makelabel\holdlabel}
%chris+
% Examples environment. This is a slightly non-standard environment that
% has two optional parameters:
% o the first is a number or other label to give the example. This
% optional argument must be surrounded in ( ); if none is supplied the
% enums counter is used; either will be surrounded by ( ) in the text.
% o the second is a string representing the longest piece of text you
% allege you will want to llap with \bad below and the indentation of
% examples is increased by the width of it to allow for this.
% (Note that LaTeX doesn't officially support optional arguments to
% environments, and having two kinds of optional arguments is a bit of an
% innovation, but they're not difficult to implement in practice.)
% Examples:
% A complete example:
% \begin{examples}(18)[\#\#] \item \bad{\#\#}A bone ate a dog.
% \item A dog ate a bone. \end{examples}
% Other prologues:
% \begin{examples} (92) \begin{examples}[??] \begin{examples}
\newbox\ll@pbox % for calculating width of llap'ed material
\newdimen\llapdimen
\llapdimen=0pt
\newdimen\exlabel
\exlabel=20pt
\def\bad#1{\leavevmode\llap{#1}} % put badness ratings in here!
% these clauses provide a definition of the `examples' pseudo-environment
\def\examples{\@ifnextchar({\ex@@mples}% %)
{\refstepcounter{enums}\ex@@mples(\theenums)}}
\long\def\ex@@mples(#1){\@ifnextchar[{\ex@mples(#1)}% %]
{\ex@mples(#1)[]}}
\long\def\ex@mples(#1)[#2]{\def\eelabel{#1}
\setbox\@tempboxa=\hbox{(#1)}%There used to be a space here which was crazy
\@tempdima=\wd\@tempboxa
\ifdim\exlabel>\@tempdima \@tempdima=\exlabel\fi
%\advance\@tempdima by -20pt
\setbox\ll@pbox=\hbox{#2}
\@tempdimb=\wd\ll@pbox
\ifdim\llapdimen>\@tempdimb \@tempdimb=\llapdimen\fi
\begin{list}{\alph{enumsi}.}{\usecounter{enumsi}%
% abandon auto width determination until I can get it right...
%\labelwidth=\@tempdima\leftmargin=\@tempdima
\advance\leftmargin by \eeindent\advance\labelwidth by \eeindent
\advance\leftmargin by \@tempdimb\advance\labelsep by \@tempdimb
\advance\leftmargin by\widelabel \advance\labelwidth by \widelabel
%\itemsep=0pt % Optional, but sometimes examples look better scrunched a bit
\let\makelabel=\enummakelabel}}
\def\endexamples{\end{list}}
% example environment
\def\example{\@ifnextchar({\ex@@mple}% %)
{\refstepcounter{enums}\ex@@mple(\theenums)}}
\long\def\ex@@mple(#1){\@ifnextchar[{\ex@mple(#1)}% %]
{\ex@mple(#1)[]}}
\long\def\ex@mple(#1)[#2]{\setbox\ll@pbox=\hbox{#2}%
\begin{list}{}{\advance\leftmargin by \wd\ll@pbox%
\advance\leftmargin by\widelabel \advance\labelwidth by\widelabel
\advance\labelsep by \wd\ll@pbox}
\item[(#1)]}
\def\endexample{\end{list}}
%chris-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% smalltree
% use
% \smalltree{& &a\\
% &b& &c\\
% d& &e& &f}
% produces
% a
% b c
% d e f
\long\def\smalltree#1{\leavevmode{\def\\{\cr\noalign{\vskip12pt}}%
\def\mc##1##2{\multispan{##1}{\hfil##2\hfil}}%
\tabskip=1em%
\hbox{\vtop{\halign{&\hfil##\hfil\cr
#1\crcr}}}}}
% modsmalltree
% use
% \modsmalltree{3}{&&a\\ &b&&c\\ d&&e&&f}
% and produces the same output
% \mc{n}{item} within either will produce item centered across n
% number of columns
% \modsmalltree[arraystretch]{num of cols}{argument}
%
\def\modsmalltree{\@ifnextchar[{\@modsmalltree}{\@modsmalltree[2]}}
\long\def\@modsmalltree[#1]#2#3{{\def\mc##1##2{%
\multicolumn{##1}{c}{\def\arraystretch{1}##2}}%
\def\arraystretch{#1}%
\def\ns{\def\arraystretch{1}}%
\setbox0=\hbox{\begin{tabular}[t]{@{}*{#2}{c}@{}}
#3
\end{tabular}}%
\dimen0=\ht0
\advance\dimen0 by -\arraystretch \ht\strutbox
\advance\dimen0 by \ht\strutbox
\ht0=\dimen0
\dimen0=\dp0
\advance\dimen0 by -\arraystretch \dp\strutbox
\advance\dimen0 by \dp\strutbox
\dp0=\dimen0
\leavevmode\box0}}
% center lap creates a box of 0 width centered on the point
\def\clap#1{\hbox to 0pt{\hss#1\hss}}
%The first argument in both of these commands is the distance above the
%baseline desired. The second is what is the actual text.
% over right lap
\def\orlap#1#2{\vbox to0pt{\vss\hbox to 0pt{#2\hss}\hbox{\vrule height#1
width0pt depth0pt}}}
% over left lap
\def\ollap#1#2{\vbox to0pt{\vss\hbox to 0pt{\hss#2}\hbox{\vrule height#1
width0pt depth0pt}}}
% over center lap
\def\oclap#1#2{\vbox to0pt{\vss\hbox to 0pt{\hss#2\hss}\hbox{\vrule height#1
width0pt depth0pt}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% need to be modified?
% Format
% \shortex{4}{a & b & c & d}
% {z & y & x & w}
% {mnop}
% produces
% a b c d
% z y x w
% mnop
%
% \shortexdt takes two gloss lines
% \shortexnt takes no gloss lines
\def\shortex#1#2#3#4{\begin{tabular}[t]{@{}*{#1}{l@{\ }}}
#2\\ #3\\ \multicolumn{#1}{@{}l@{}}{\parbox{\linewidth}{#4}}
\end{tabular}}
%\def\shortexdt#1#2#3#4#5{\begin{tabular}[t]{@{}*{#1}{l@{\ }}}
%#2\\ #3\\ \multicolumn{#1}{@{}l@{}}{#4}\\
%\multicolumn{#1}{@{}l@{}}{#5}
%\end{tabular}}
\def\shortexnt#1#2#3{\begin{tabular}[t]{@{}*{#1}{l@{\ }}}
#2\\ #3
\end{tabular}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% need to create equivalent of AVM structures.
% Structure is
% \outerfs{alpha & beta\\ gamma & delta}
% produces
% __ __
% | alpha beta |
% | gamma delta |
% -- --
%
% \outerfs can be nested.
% inside of enumsentence use with \evnup[2pt]{\outerfs{. . .}}
% to ensure that top of fs structure lines up with the number
%
% Note that you can use \\[1ex] to increase the space between
% individual lines
\def\outerfs#1{$\left[\begin{tabular}{ll}#1\end{tabular}\right]$}
% \evnup is used to line up the enumsentence number and an entry along
% the top. It can take an argument to improve lining up.
\def\evnup{\@ifnextchar[{\@evnup}{\@evnup[0pt]}}
\def\@evnup[#1]#2{\setbox1=\hbox{#2}%
\dimen1=\ht1 \advance\dimen1 by -.5\baselineskip%
\advance\dimen1 by -#1%
\leavevmode\lower\dimen1\box1}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% End of main lingmacros
%
%chris+
% for easier hand entry of csli bib items.
\def\bib{\bibitem[]{}}
%chris-
|