summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/expex/source/04_Ex.tex
blob: f2270cc1653cb6a51d567833cf8ff550fece6ae6 (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

\section Examples without parts

\lingset{dima=1.3em}
\noindent
\begininventory
\macros \idx{|\ex|}|~[]|, \idx{|\xe|}\endmc
\counter \idx{|\excnt|}\endmc
\parameters
\idx{|numoffset|\user} & \inc dimension& \textdim{0 pt}\cr
\idx{|textoffset|\user}& \inc dimension& \textdim{1 em}\cr
\idx{|aboveexskip|\user}& \inc skip&
   2.7\dimskip ex plus .4\dimskip ex minus .4\dimskip ex\cr
\idx{|belowexskip|\user}& \inc skip&
   2.7\dimskip ex plus .4\dimskip ex minus .4\dimskip ex\cr
\idx{|exskip|}& skip& (pseudo-parameter)\cr
\endinventory
%
Sections will usually begin with an inventory of the parameters and
user friendly macros and registers that are introduced in the section,
The initial settings of parameters will be given if they are relevant.
Pseudo parameters are set for their immediate effect, not to store a
setting associated with the parameter, so the initial setting of
pseudo parameters is not relevant.
|\ex~[]| above should be taken to mean that the macro
|\ex| will be described, that it is optionally modified by a
following diacritical tilde |~| (as described below), and that it
optionally takes an argument.  The text will describe what
arguments are permitted.  A $\dag$ supersript on a parameter in these
inventories indicates a parameter whose value is
accessible by the macro |\ling«key»|. A \inc\ prefix on ``dimension''
or ``skip'' indicates that the parameter is incrementable, by a
dimension or a skip as the case may be.

|\ex| constructions are terminated by |\xe|.  The following
sample paragraph illustrates the use of |\ex| \dots|\xe|. The
convention in this manual is that text, {\it as it would appear in
a document}, is displayed in a framed box, usually with the code
immediately following or preceding. The code assumes that the
initial parameter settings are in effect at the point that the
code is executed.

\framedisplay
\exdisplay
The following example is well-known from the literature on
parasitic gaps.  Here we are concerned with example formatting,
not with the interesting syntax.
\ex
I wonder which article John filed {\sl t\/} without reading {\sl e}.
\xe
Various aspects of the format are controlled by parameters, which
can be set either globally or via an optional argument.
\xe
\endframedisplay
\codedisplay~
The following example is well-known from the literature on
parasitic gaps.  Here we are concerned with example formatting,
not with the interesting syntax.

\ex
I wonder which article John filed {\sl t\/} without reading {\sl e}.
\xe

\noindent Various aspects of the format are controlled by
parameters, which can be set either globally or via an optional
argument.|endcodedisplay

Those users who try to save virtual paper can equally
use:

\codedisplay
The following example is well-known from the literature on
parasitic gaps.  Here we are concerned with example formatting,
not with the interesting syntax.\ex I wonder which article John
filed {\sl t\/} without reading {\sl e}.\xe Various aspects of
the format are controlled by parameters, which can be set either
globally or via an optional argument.|endcodedisplay

With different parameter settings, we get:

\framedisplay
\exdisplay
The following example is well-known from the literature on
parasitic gaps.  Here we are concerned with example formatting,
not with the interesting syntax.

\ex[numoffset=2em,textoffset=.5em,aboveexskip=1ex,belowexskip=1ex]
I wonder which article John filed {\sl t\/} without reading {\sl e}.
\xe

\noindent Various aspects of the format are controlled by
parameters, which can be set either globally or via an optional
argument.
\xe
\endframedisplay

\codedisplay~
The following example is well-known from the literature on
parasitic gaps.  Here we are concerned with example formatting,
not with the interesting syntax.

\ex[numoffset=2em,textoffset=.5em,aboveexskip=1ex,belowexskip=1ex]
I wonder which article John filed {\sl t\/} without reading {\sl e}.
\xe

\noindent Various aspects of the format are controlled by
parameters, which can be set either globally or via an optional
argument.|endcodedisplay

The horizontal dimensions are illustrated below. |numoffset| is
measured from the left margin.

\bigskip
\noindent
\pspicture(0,-.9em)(4.9in,3em)
\psscalebox{1.5}{%
\psset{linewidth=.5pt,yunit=.2in}
\def\vline#1{\psline[linestyle=dashed](#1,1)(#1,-.4)\ignorespaces}%
\vline0
\dimpuba=.35in
\vline\dimpuba
\pcline{<->}(0,1)(\dimpuba,1)
\Aput{\eightrm numoffset}
\setbox0=\hbox{(23)}%
\rput[l](\dimpuba,0){\copy0}
\dimpubb=\dimpuba \advance\dimpubb by\wd0
\vline\dimpubb
\dimpuba=\dimpubb \advance\dimpubb by .5in
\vline\dimpubb
\pcline{<->}(\dimpuba,1)(\dimpubb,1)
\Aput{\eightrm textoffset}
\rput[l](\dimpubb,0){This is the example text.}
}\endpspicture
\bigskip

\noindent Example numbering is automatic.  The count is kept in
|\excnt|.  It is incremented when |\ex| is expanded, before the
number is typeset.  Outside examples, |\excnt| gives the count
of the next example.   Inside examples, it also gives the count of the
next example, not the current one.  Vertical skip is inserted
before and after examples, of amounts determined by the values of
|aboveexskip| and |belowexskip|.

Inside |\ex| constructions, the example text is wrapped as
ordinary text, with |\leftskip| set by |\ex|.  Since |\ex|
sets |\leftskip| and relies on this setting, changes in |\leftskip|
inside \hbox{|\ex| \dots|\xe|} must be made with care, but can be made
after the first paragraph (i.e. after the first  explicit or
implicit |\par|).

\makeatletter
\framedisplay
\ex
Und hier k\"onnen wir sehen was f\"ur Unfug wird gemacht
wenn er einen ganz langen Satz binnen kriegt.\par\nobreak
\xe

\ex~
$\alpha$ {\it governs\/} $\beta$ if $\alpha=X^0$ (in the
sense of X-bar theory), $\alpha$ c-commands $\beta$, and $\beta$
is not protected by a maximal projection.
\xe
\endframedisplay
\resetatcatcode

The code which was used to typeset the pair of examples above has
two useful features which are worth highlighting.

\codedisplay
\ex
Und hier k\"onnen wir sehen was f\"ur Unfug wird gemacht
wenn er einen ganz langen Satz binnen kriegt.\par\nobreak
\xe
|exbreak
\ex[aboveexskip=0pt]
$\alpha$ {\it governs\/} $\beta$ if $\alpha=X^0$ (in the
sense of X-bar theory), $\alpha$ c-commands $\beta$, and $\beta$
is not protected by a maximal projection.
\xe|endcodedisplay

\noindent |\par\nobreak| is used to illustrate how a page break
between two consecutive examples can be suppressed. This is
sometimes desirable.  |\par| puts \Tex\ in the mode of adding
lines to the page, and |\nobreak| tells \Tex\ to avoid a break
(which is a page break when \Tex\ is in the mode of adding
lines), essentially until after more text is added to the page.
|aboveexskip=0pt| is used in the second example to avoid double
spacing between the examples.  Otherwise vertical skip would be
added both below the first example and above the second example.

Since the need to suppress vertical skip above examples arises
with some frequency, a shortcut is made available to accomplish
this.  Simply say |\ex~|.  \sidx{|~|, tilde modification}Tilde
modification of |\ex| can be used with parameters; |\ex~[|\dots|]| will be interpreted correctly.

|exskip| is a pseudo parameter which can be used to
simultaneously set both |aboveexskip| and |belowexskip|. The
effect of |\lingset{exskip=«value»}| is

\exfrag
|\lingset{aboveexskip=«value»,belowexskip=«value»}|
\xe

\subsection Explicit example numbers

\begininventory
\parameters
\idx{|exno|}& token list& (pseudo parameter)\cr
\idx{|exnoformat|}& token list of the form $\;\ldots\,|X|\,\ldots$& |(X)|\cr
\endinventory
%
Suppose that you want to repeat an example that was given earlier
in your document.  Something like.

\framedisplay
\excnt=94
\ex This is a crucial example.\xe
It is clear that this example is related to the earlier
example (14), which is repeated below.
\ex[exno=14]
This is an example that was given many pages earlier.\xe
If we are on the right track, as the saying goes,
we expect the next example to be grammatical.  But it is not.
\ex * \dots\xe
\endframedisplay

\codedisplay~
\ex This is a crucial example.\xe
It is clear that this example is related to the earlier
example (14), which is repeated below.
\ex[exno=14]
This is an example that was given many pages earlier.\xe
If we are on the right track, as the saying goes,
we expect the next example to be grammatical.  But it is not.
\ex * \dots\xe
|endcodedisplay

|\excnt| is not incremented if the example number is
supplied by |exno|.

|exno| does not have to be set to an integer, as shown below.

\framedisplay
\ex[exno=$\Delta$] Earlier example.\xe
\endframedisplay

\codedisplay~
\ex[exno=$\Delta$] Earlier example.\xe |endcodedisplay


\framedisplay
\ex[exno={[14, repeated]},exnoformat=X] Earlier example.\xe
\endframedisplay
\codedisplay~
\ex[exno={[14, repeated]},exnoformat=X] Earlier example.\xe|endcodedisplay

\noindent Note the use of braces to hide the comma in the setting
of |exno|.  Otherwise, the key-value parser would get
confused, interpreting |[14| as the setting of |exno| and
reporting that |repeated| is an undefined key.  The initial setting of
|exnoformat| is |(X)|, so this parameter must be reset to prevent
putting parentheses around the special exno.  The label formatting mechanism is primitive.
|labelformat| must
be of the form\medskip
\centerline{$\rm \langle balanced\
text\rangle\thinspace|X|\thinspace \langle balanced\ text\rangle$}
\medskip
\noindent The pre-X text is inserted before the label (including
the material specified by |everypar|) and the post-X text is
inserted after the label. The balanced text cannot contain the
character |X|.  {\it Balanced text\/} is a string of tokens with
properly nested (explicit) braces. No error checking is done to
ensure that the format specification has the required form, so be
careful.  An error might lead to very obscure error messages.

Note that
\exfrag
|\ex[exno={14, repeated},exnoformat={[X]}] Earlier example.\xe|
\xe
and
\exfrag
|\ex[exno={[14, repeated]},exnoformat=X] Earlier example.\xe|
\xe
give the same result.

Section (\getref{named-reference}) will show how to name example
numbers, so that |exno| can be set by giving the name of
an example number.