summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/sqmac.tex
blob: 80e88cf89015864a2578f1f08c6ae81d9329ea4f (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
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
%  This should appear in a file named SQMAC.TEX
\long\def\ig#1{\relax}
\ig{Thanks to Roberto Minio for this def'n.  Compare the def'n of
\comment in AMSTeX.}
\ig{      Copyright 1988 Michael Barr
          Department of Mathematics and Statistics
          McGill University
          Montreal, Quebec, Canada
          H3P 1S4
 
          inhb@mcgillc.bitnet
 
          All commercial rights reserved.  May be freely distributed
          for non-commercial use, so long as this notice is included.}
 
\setlength{\unitlength}{.1em}
 
\newlength{\ulabeloffset}
\newlength{\ulabelwidth}
\newlength{\arrowwidth}
\newlength{\lnodewidth}
\newlength{\rnodewidth}
\newlength{\loffset}
\newlength{\roffset}
 
\newcount\tarrowflag
\newcount\larrowflag
\newcount\rarrowflag
\newcount\barrowflag
\newcount\height
\newcount\width
\newcount\arrowlen
\newcount\labelheight
 
 
% The following is like \vector, except it makes a monic (tailed) arrow.
 
\def\mvector(#1,#2)#3
{
\begin{picture}(#3,#3)(-2,0)
\put(0,4){\vector(#1,#2){#3}}
\put(0,4){\vector(#1,#2){3}}
\end{picture}
}
 
% The following is like \vector, except it makes an epic (2-headed) arrow.
 
\def\evector(#1,#2)#3
{
\arrowlen #3
\begin{picture}(\arrowlen,\arrowlen)(-2,0)
\put(0,4){\vector(#1,#2){\arrowlen}}
\advance \arrowlen by -4
\put(0,4){\vector(#1,#2){\arrowlen}}
\end{picture}
}
 
 
\catcode`@=11 % unhide @sign definitions
 
\def\absvector(#1,#2)#3{\@xarg #1\relax \@yarg #2\relax
\@linelen=#3
\ifnum\@xarg =0 \@vvector
  \else \ifnum\@yarg =0 \@hvector \else \@svector\fi
\fi}
 
\catcode`@=12 % @signs are no longer letters
 
\ig{This definition of \function below is a modification of one due to
Charles Wells whose idea it was to try to make the length of the arrow
depend on the sizes of the nodes.  Much elaborated, it forms the basis
of the square macro.}
 
\newcommand{\setwidths}[4]
{
\settowidth{\lnodewidth}{#1}
\settowidth{\rnodewidth}{#2}
\setlength{\loffset}{0.5\lnodewidth}
\setlength{\roffset}{0.5\rnodewidth}
\addtolength{\loffset}{3\unitlength} %allows a little space
\addtolength{\roffset}{3\unitlength} %before & after the arrow
\setlength{\arrowwidth}{#4\unitlength}
\addtolength{\arrowwidth}{-\loffset}
\addtolength{\arrowwidth}{-\roffset}
\setlength{\ulabeloffset}{\loffset}
\settowidth{\ulabelwidth}{#3}
\advance\ulabeloffset by .5\arrowwidth
\advance\ulabeloffset by -.5\ulabelwidth
}
 
\newcommand{\dofunc}[4]
{
\setwidths{#1}{#2}{#3}{#4}
\begin{picture}(0,0)
\put(0,0){\makebox(0,0){#1}}
\put(-3,0){\hspace{\loffset}\absvector(1,0){\arrowwidth}}
\put(#4,0){\makebox(0,0){#2}}
\put(0,4){\hspace{\ulabeloffset}{#3}\hspace{\ulabeloffset}}
\end{picture}
}
 
 
% The four parameters are (lnode,rnode;label,width)
\def\func(#1,#2;#3;#4)
{   %begin func
\makebox(0,0){\dofunc{#1}{#2}{#3}{#4}
}%end box
}%end func
 
 
\ig{The next procedure is to set parameters for a square.  The six
parameters are all numbers.  The first 4 flag the four arrows of the
square as follows:
 
               top or bottom           left or right
                  arrow                    arrow
 
   < -3       leftwards, normal         upwards, normal   ( <----- )
     -3       leftwards, epic           upwards, epic     ( <<---- )
     -2       leftwards, monic          upwards, monic    ( <----< )
     -1       leftwards, normal         upwards, normal   ( <----- )
      0       omitted                   omitted
      1       rightwards, normal        downwards, normal ( -----> )
      2       rightwards, epic          downwards, epic   ( ---->> )
      3       rightwards, monic         downwards, monic  ( >----> )
    > 3       rightwards, normal        downwards, normal ( -----> )
 
In other words, when the parameter is positive, the arrow goes in the
ordinary (linguistic) direction and when negative, in the opposite
direction.  When the parameter is 0, the arrow is omitted.  When the
absolute valute of the parameter is 2, you get a monic (tailed) arrow
and when it is 3, you get an epic (double headed) arrow.  Any other
non-zero value gives an normal arrow.
 
The last 2 parameters, for which 60 and 70 are a reasonable values, are
the distance between the vertical, resp.  horizontal arrows in
increments of .1 em.
 
The procedure \resetparms sets the first 4 of these parameters to 1 and
the last two to 60 and 70.
 
NOTE: ONE OF THE PROCEDURES \setparms OR \resetparms SHOULD BE EXECUTED
BEFORE A SQUARE IS MADE.
 
The procedure \square takes 8 parameters, in the format
[#1`#2`#3`#4;#5`#6`#7`#8] which are in order,
[NW`NE`SW`SE;t`l`r`b], the first four being the nodes and the last four
the labels on the arrows.
 
The top and bottom arrows have their lengths automatically adjusted to
compensate for the widths of the nodes.  Thus 50 will be a reasonable
value for the width parameter, but only if the labels are not too long.
The examples below show how these squares may be fitted together to make
more complicated diagrams.  Although it may be possible in principle to
superimpose the joint arrow, it seems safer to omit one of them.  Minor
arithmetic errors might otherwise result in thick lines.  Note, in the
examples, the use of the procedure \phantom to make the arrow lengths
proper, while avoiding overlapping nodes.
 
Note the \hspace and \space used to properly space them.  I don't
understand the spacing rules used in picture mode to figure out how to
do these automatically and so they are determined by trial and error.  I
suspect they depend on the widths of the nodes and the heights of the
labels.  Also note the blank lines between the two squares in the second
example.  This is necessary for proper spacing.}
 
\ig{In case you are interested why I used the peculiar syntax for the
parameters, it is because I didn't like to type braces and I also didn't
want to use things like parens and commas that I am likely to use as
parts of nodes and arrows.  But feel free to change this syntax.}
 
\def\setparms[#1`#2`#3`#4;#5`#6]
{
\tarrowflag #1
\larrowflag #2
\rarrowflag #3
\barrowflag #4
\width #5
\height #6
}
 
\newcommand{\resetparms}
{
\tarrowflag1
\larrowflag1
\rarrowflag1
\barrowflag1
\width50
\height50
}
 
\resetparms %initializes defaults
 
\ig{The parameters are the nodes and arrows in linguistic order.
Note: if one of the nodes has an asscript, then the other one on
the same line must too. Use an empty box (e.g. blah_{}) if necessary.}
\def\square[#1`#2`#3`#4;#5`#6`#7`#8]%
{
\advance \height by 30
\begin{picture}(\width,\height)(0,4)
\arrowlen\height
\labelheight\height
\divide\labelheight by 2
\advance \height by -15
\advance \arrowlen by -44
 
\setwidths{#1}{#2}{#5}{\width}
\put(0,\height){\makebox(0,0){#1}}
\ifnum\tarrowflag>0
   \put(-3,\height){\hspace{\loffset}\absvector(1,0){\arrowwidth}}
   \ifnum\tarrowflag=3
      \advance\arrowwidth by -4\unitlength
      \put(-3,\height){\hspace{\loffset}\absvector(1,0){\arrowwidth}}
   \fi
   \ifnum\tarrowflag=2
       \put(-1,\height){\hspace{\loffset}\absvector(1,0){\unitlength}}
   \fi
\else\ifnum\tarrowflag<0
   \advance\loffset by \arrowwidth
   \put(-3,\height){\hspace{\loffset}\absvector(-1,0){\arrowwidth}}
   \ifnum\tarrowflag=-3
      \advance\arrowwidth by -4\unitlength
      \put(-3,\height){\hspace{\loffset}\absvector(-1,0){\arrowwidth}}
   \fi
   \ifnum\tarrowflag=-2
       \put(-5,\height){\hspace{\loffset}\absvector(-1,0){\unitlength}}
   \fi
\fi\fi
 
\put(\width,\height){\makebox(0,0){#2}}
\advance \height by 4
\put(0,\height){\hspace{\ulabeloffset}{#5}\hspace{\ulabeloffset}}
 
\advance \height by -11
\ifnum\larrowflag>0
   \put(0,\height){\vector(0,-1){\arrowlen}}
   \ifnum\larrowflag=3
      \advance\arrowlen by -4
      \put(0,\height){\vector(0,-1){\arrowlen}}
      \advance\arrowlen by 4
   \fi
   \ifnum\larrowflag=2
      \advance \height by -2
      \put(0,\height){\vector(0,-1){1}}
      \advance \height by 2
   \fi
\else\ifnum\larrowflag<0
   \advance\height by-\arrowlen
   \put(0,\height){\vector(0,1){\arrowlen}}
   \ifnum\larrowflag=-3
      \advance\arrowlen by -4
      \put(0,\height){\vector(0,1){\arrowlen}}
      \advance\arrowlen by 4
   \fi
   \ifnum\larrowflag=-2
      \advance \height by 2
      \put(0,\height){\vector(0,1){1}}
      \advance \height by -2
   \fi
   \advance\height by\arrowlen
\fi\fi
 
\ifnum\rarrowflag>0
   \put(\width,\height){\vector(0,-1){\arrowlen}}
   \ifnum\rarrowflag=3
      \advance\arrowlen by -4
      \put(\width,\height){\vector(0,-1){\arrowlen}}
   \fi
   \ifnum\rarrowflag=2
      \advance \height by -2
      \put(\width,\height){\vector(0,-1){1}}
   \fi
\else\ifnum\rarrowflag<0
   \advance\height by-\arrowlen
   \put(\width,\height){\vector(0,1){\arrowlen}}
   \ifnum\rarrowflag=-3
      \advance\arrowlen by -4
      \put(\width,\height){\vector(0,1){\arrowlen}}
      \advance\arrowlen by 4
   \fi
   \ifnum\rarrowflag=-2
      \advance \height by 2
      \put(\width,\height){\vector(0,1){1}}
      \advance \height by -2
   \fi
\fi\fi
 
\put(-3,\labelheight){\makebox(0,0)[r]{#6}}
\advance \width by 3
\put(\width,\labelheight){\makebox(0,0)[l]{#7}}
\advance \width by -3
 
\setwidths{#3}{#4}{#8}{\width}
\put(0,15){\makebox(0,0){#3}}
\ifnum\barrowflag>0
   \put(-3,15){\hspace{\loffset}\absvector(1,0){\arrowwidth}}
   \ifnum\barrowflag=3
      \advance\arrowwidth by -4\unitlength
      \put(-3,15){\hspace{\loffset}\absvector(1,0){\arrowwidth}}
   \fi
   \ifnum\barrowflag=2
      \put(-1,15){\hspace{\loffset}\absvector(1,0){\unitlength}}
   \fi
\else\ifnum\barrowflag<0
   \advance\loffset by \arrowwidth
   \put(-3,15){\hspace{\loffset}\absvector(-1,0){\arrowwidth}}
   \ifnum\barrowflag=-3
      \advance\arrowwidth by -4\unitlength
      \put(-3,15){\hspace{\loffset}\absvector(-1,0){\arrowwidth}}
   \fi
   \ifnum\barrowflag=-2
       \put(-5,15){\hspace{\loffset}\absvector(-1,0){\unitlength}}
   \fi
\fi\fi
\put(\width,15){\makebox(0,0){#4}}
\put(0,7){\hspace{\ulabeloffset}{#8}\hspace{\ulabeloffset}}
\end{picture}
}
ý SMTPUSER HMCVAX  5/14/88
þ INHB@MCGILLC.BITNET DHOSEK@HMCVAX.BITNE  5/14/88 No subject