summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/expex/source/03_XKV.tex
blob: 0a5831f312115c430231df673a564fe68e3e8f35 (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

%\def\typedim#1{\typed@m#1\@nil}
%\def\typed@m#1 #2\@nil{$#1\,\rm #2$}
\def\!{\kern-1.6pt}

\section XKV parameterization

\begininventory
\macros* \idx{|\lingset|}\endmc
\endinventory
%
(Here and in following sections and subsections, an inventory of
the macros, parameters, and count registers which are described
in what follows appears at the beginning of the section. ``What
follows'' refers to the text up to the next section or subsection
heading.)

The key-value approach to parameter setting in \Tex, which
originated with David Carlisle's |keyval| package, is illustrated
by the key |glspace|. \ExPex\ uses to it set one of the
parameters used in typesetting glosses.  Executing the command


\sidx{|\lingset|}
\exfrag
|\lingset{glspace=1.3em}|
\xe

\noindent results in the definition (or redefinition) of the
macro |\lingglspace| so that it expands to the value \textdim{1.3
em}.
The macro |\begingl|, which is used to typeset glosses, uses
|\lingglspace|, typesetting the gloss so that the minimal
interword separation is the dimension which |\lingglspace|
expands~to.  But \ExPex\ users never have to concern themselves
with the macro |\lingglspace|.  If they are not satisfied with
the default spacing, they simply have to know that |glspace| is
the key to setting the word spacing in glosses.

The argument of |\lingset| can be a comma separated sequence of
key/value pairs. The syntax is:

\exfrag \everymath={}%
|\lingset{«key$_1$»=«value$_1$»,«\dots»,«key$_n$»=«value$_n$»}|
\xe
%
The comma separated key/value pairs are processed sequentially,
from left to right. If a value contains a comma, it must be
hidden from the mechanism which parses the list by putting the
value in braces. The braces are removed by the parser.

Several \ExPex\ macros take an optional argument, delimited by
brackets, which is passed to |\lingset|.  |\begingl|, used to
typeset glosses, takes an optional argument.  You might say, for
example,

\exfrag
|\begingl[glspace=.9em,everyglft=\it]|
\xe

\noindent The optional argument of |\begingl| will be passed to
|\lingset| and the result evaluated, so that the gloss will be
typeset with these parameter settings.  This is carried out
inside a group, so the global settings of the parameters are not
affected. As we will see later, |everyglft=\it| will result in an
italicized translation.

\ExPex\ has various kinds of keys.  The distinctions depend on
the effect of executing (\nextx) and the restrictions on the
possible values which can appear.

\ex
|\lingset{«key»=«value»}|
\xe

\noindent {\it Command key\/}:\enspace
After (\lastx) is executed, the macro |\ling«key»| or
|\ling@«key»| expands to {\sl value}.  It will be made clear when
the key is introduced whether it is |\ling«key»| or |\ling@«key»|
that is
defined.


\smallskip
\noindent {\it Incremental dimension parameter\/}:\enspace {\sl
value\/} must be a dimension or a dimension prefixed by |!|. If
{\sl value\/} is a dimension, it is stored in |\ling«key»|. If it
is a !-prefixed dimension, the prefixed dimension is added to its
former dimension and the result stored in |\ling«key»|. If
|\ling@«key»| is undefined or does not expand to a dimension, a
fatal error results.  Incremental parameters are very useful if
minor adjustments to the format are desired.  There are {\it
incremental skip parameters\/} as well, which operate on an
entirely parallel manner.

\smallskip
\noindent {\it Choice parameter\/}:\enspace
{\sl value\/} must be drawn from a prescribed list.  Although the
\ExPex\ choice parameters do store {\sl value\/} when (\lastx)
is executed, the main purpose of executing (\lastx) is the side
effects which are coded into the definition of the key.

The parameter |labelalign| illustrates this.
|\lingset{labelalign=«value»}| is valid only if {\sl value\/} is
one of |left|, |center|, or |right|.  A fatal error results
otherwise.  The effect is to appropriately define the macro
|\@labelprint| which is used to typeset the labels of subparts in
multipart examples.
\smallskip

\smallskip
\noindent {\it Pseudo parameter\/}: (\lastx) is executed for its
side effects.  {\sl value\/} is not stored. The key |samplelabel|
illustrates this.  When |\lingset{samplelabel=A.}| is executed,
for example, the macro |\ling@samplelabel| is not defined.
Instead, the parameter |labelwidth| is set to the width of
``A.'' in the current font.

\medskip
In the interest of clarity, the exposition above was somewhat
oversimplified (i.e. told some lies, but small lies).  The macro
in which a value associated with {\sl key\/} is stored was
assumed to be |\ling@«key»|.  In fact, some keys use
|\ling«key»|, with no |@| in the macro name so that they are
easier for the user to access. In those cases in which it
appeared that there is a significant chance that some users will
want easy access to the value of a parameter at some point, the
macro name |\ling«key»| was used rather than |\ling@«key»|.

When keys are defined, they can be given default values, as part
of their definitions.  If a key |foo|, for example, is given the
default value |2pt|, then executing |\lingset{foo}| is equivalent
to executing |\lingset{foo=2pt}|.  Only a few \ExPex\ keys have
default values, but most are set to an initial value in {\sl
expex.tex}.