summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/crw/crwdoc.tex
blob: fc6d48474f7fecce0911dae278c5dc72ed9ee376 (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
%History of changes
%dec 1993: The Prague proceedings version as been adapted.
%          This version submitted to CTAN.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Revised/Alternative Crosswords via (plain) TeX
%Version: Oct 92
\input tugboat.sty
\def\rtitle{\hbox to \pagewd{\tenrm MAPS92.2\hfil
                             {\it Typesetting Crosswords via \TeX, revisited}
}}
\def\rfoot{\hbox to\pagewd{\sevenrm \rlap{Draft: \today}\hfil-\the\pageno-
\hfil\llap{\copyright cgl}}
}
\pageno=1
\overfullrule=0pt

\title*Typesetting Crosswords via \TeX, revisited*
\author*Kees van der Laan*
\address*Hunzeweg 57, 9893PB\\
         Garnwerd (Gr), The Netherlands*
\netaddress*cgl@risc1.rug.nl*
\article
%Footnote counter and footnote indexer
\newcount\fcnt
\def\ftn{\global\advance\fcnt1 \footnote{${}^{\the\fcnt}$}}
\def\DeK{D\kern-.11em\lower.5ex\hbox{E}\kern-.1em K}

\head*Abstract*
An alternative macro, to van der Laan (1992b),
is provided for typesetting crosswords via (plain) \TeX.

\subhead*Keywords* Crosswords, games, plain \TeX. %, typography.
%
\head*Introduction*
The previous version  has been published
in the proceedings of Euro\-\TeX\ '92, and in MAPS92.1.
A TUGboat referee suggested not to use |\halign|, et voil\`a.
The differences of this version with the previous version are:
|\halign| is not used, and therefore there is no mark-up phase,
and |\data| is hidden.
The nested FIFO paradigm is directly applied to |\data|,
van der Laan (1992a). The control sequence |\data| is created in
|\store| with as replacement text the data provided between |\bdata...\edata|.
Alternative sizes of the crossword
can be obtained via appropriate (re)definition of
|\usersize|.

\head*Example of use* %\input crwrev.tex
%
\let\ea=\expandafter \newif\ifpuzzle
\newcount\cnt \puzzletrue
\newdimen\csize\csize=3ex
%
\def\bdata{\bgroup\obeylines\obeyspaces%
\store}
\def\store#1\edata{\egroup\def\data{#1}}
{\obeyspaces\global\let =\relax}
\def\usersize{}
%
{\catcode`\^^M=13 %local scope
\gdef\crw{\cnt=0\relax\boxit{\usersize%
\hrule\ea\fifol\data\lofif^^M}}
\gdef\sol{\boxit{\def\num{}\puzzlefalse%
\usersize\hrule\ea\fifol\data\lofif^^M}}
\gdef\fifol#1^^M{\ifx\lofif#1\lofif\fi%
\processl{#1}\fifol}}%end local scope
%
\def\lofif#1\fifol{\fi}
\def\processl#1{\hbox{\fifo#1\ofif}\hrule}
\def\fifo#1{\ifx\ofif#1\ofif\fi%
\process#1\fifo}  \def\ofif#1\fifo{\fi}
%
\def\process#1{\if*#1\cc\else%
\ifx\relax#1\cc\else%
\ifnum`#1=\uccode`#1\cap#1\else%
\low#1\fi\fi\fi}
\def\low#1{\hbox to\csize{\vrule
height.8\csize depth.2\csize\relax%
\ifpuzzle\null\else\hss\uppercase{#1}%
\fi\hss\vrule}}
\def\cap#1{\hbox to\csize{\vrule
height.8\csize depth.2\csize\relax%
\num\ifpuzzle\null\else\hss#1\fi%
\hss\vrule}}
\def\cc{\vrule height.8\csize depth%
.2\csize width\csize}
%
\def\num{\global\advance\cnt1\relax%
\vbox to.8\csize{\rlap{\kern1pt%
\fiverm\the\cnt\hss}\vfil}}
%
\def\boxit#1{\vbox{\hrule\hbox{\vrule%
\vbox{#1}\vrule}\hrule}}%   cgl, oct92
%
\bdata%
P*On
DEk*
*n*S
Edit
\edata$$\crw\qquad
\def\usersize{\fiverm\csize=3ex}\sol$$
\medskip\noindent
is obtained via\ftn{The sides seem to wiggle. Is this optical illusion,
a driver bug, or caused by the properties of ink-blocks on paper?
Electronic previewing did not suffer from this.
The framing was added via {\tt\char92 boxit} to enhance a straight frame.}
\verbatim
\input crwrev.tex
\bdata%
P*On
DEk*
*n*S
Edit
\edata$$\crw\qquad
\def\usersize{\fiverm\csize=3ex}\sol$$
\endverbatim
\noindent Conventions for |\bdata| $\langle\,data\,\rangle$ |\edata|\ftn{A
`white lie,' spaces are also allowed for crossed out cells, see the Appendix.}
\item{--} cell descriptions have to be given line by line
\item{--} * denotes crossed out cell
\item{--} capitals denote marked open cells (with reference numbers
          to the clues), and letters of the solution
\item{--} lower case letters, denote empty cells,
          and letters of the solution.
\par\noindent The explicit number of cells is not needed to specify,
nor used.

\head*Programming*
Crossword diagrams consist of
(marked) empty cells, crossed out cells, and
for the solution cells with (capital) letters.
I parameterized each cell into the
size |\csize| by |\csize|, with height |.8\csize|.
Cells are typeset per row in a |\hbox| and these boxes are
stacked in a |\vbox|. All is framed via |\boxit|.
The carriage return, |^^M|, and space are active characters
between |\bdata| and |\edata|, allowing WYSIWYG input.
The numbering of the marked cells is done automatically, row-wise and hidden.
I adopted the convention to use reversed words for end-parameter separators,
except for the |\edata| separator.

Furthermore,
I assumed that no diacritical marks  are used in crosswords, and restricted
myself to the roman alphabet.

\subhead*The file {\tt crwrev.tex}*
%\verbfile{crwrev.tex}
\verbatim
\let\ea=\expandafter \newif\ifpuzzle
\newcount\cnt \puzzletrue
\newdimen\csize\csize=3ex
%
\def\bdata{\bgroup\obeylines\obeyspaces%
\store}
\def\store#1\edata{\egroup\def\data{#1}}
{\obeyspaces\global\let =\relax}
\def\usersize{}
%
{\catcode`\^^M=13 %local scope
\gdef\crw{\cnt=0\relax\boxit{\usersize%
\hrule\ea\fifol\data\lofif^^M}}
\gdef\sol{\boxit{\def\num{}\puzzlefalse%
\usersize\hrule\ea\fifol\data\lofif^^M}}
\gdef\fifol#1^^M{\ifx\lofif#1\lofif\fi%
\processl{#1}\fifol}}%end local scope
%
\def\lofif#1\fifol{\fi}
\def\processl#1{\hbox{\fifo#1\ofif}\hrule}
\def\fifo#1{\ifx\ofif#1\ofif\fi%
\process#1\fifo}  \def\ofif#1\fifo{\fi}
%
\def\process#1{\if*#1\cc\else%
\ifx\relax#1\cc\else%
\ifnum`#1=\uccode`#1\cap#1\else%
\low#1\fi\fi\fi}
\def\low#1{\hbox to\csize{\vrule
height.8\csize depth.2\csize\relax%
\ifpuzzle\null\else\hss\uppercase{#1}%
\fi\hss\vrule}}
\def\cap#1{\hbox to\csize{\vrule
height.8\csize depth.2\csize\relax%
\num\ifpuzzle\null\else\hss#1\fi%
\hss\vrule}}
\def\cc{\vrule height.8\csize depth%
.2\csize width\csize}
%
\def\num{\global\advance\cnt1\relax%
\vbox to.8\csize{\rlap{\kern1pt%
\fiverm\the\cnt\hss}\vfil}}
%
\def\boxit#1{\vbox{\hrule\hbox{\vrule%
\vbox{#1}\vrule}\hrule}}%   cgl, oct92
\endverbatim
%
\subhead*{\tt\char92crw}, {\tt\char92sol}*
The crossword, respectively the solution are typeset
(as |\vbox|-es) by these macros. |\data| is used.
%
\subhead*{\tt\char92process}*
This macro typesets each cell contents according to the |\data|. %
|\if*#1| etc.\ tests whether a crossed-out cell has to be typeset, and if so
a copy is inserted. For the other situation according to
the case of the letter |\low|(er case letter) or
|\cap|(ital letter), is invoked.
How the cell contents will be typeset depends upon |\ifpuzzle|.
The letters are typeset in upper case and centered.
%
\subhead*{\tt\char92num}*
Generates and typesets the reference numbers.
The numbers are set in the left upper corners of the cells marked
by capitals in the puzzle representation.
%
\subhead*{\tt\char92bdata, \char92store}*
These store the user provided information between |\bdata| and |\edata|
in |\data|, with the carriage return and space as active characters.
(The |\bgroup| after |\gdef| must be an
{\it explicit\/} brace, because |\bgroup| can be equally well a
parameter separator.)
%
\head*References*
%
\frenchspacing
\newcount\bcnt
\def\bib{\global\advance\bcnt1 [\the\bcnt]}
\item{\bib} Hamilton Kelley, B (1990): Some macros to draw crosswords.
            \tubissue{11}(1), 103\dash119.
\item{\bib} Knuth, D.E (1986): The \TeX Book. Addison-Wesley.
\item{\bib} Laan, C.G van der (1992a):
            FIFO and LIFO sing the BLUes. MAPS92.2.
\item{\bib} Laan, C.G van der Laan (1992b): Typesetting Crosswords via \TeX.
            Euro\TeX\ '92. 217\dash224. Also in MAPS92.1.
\par\noindent
%%%The above blank line (or \par) is needed to terminate \item%%%
\head*Appendix: {\rm Hamilton Kelley's puzzle}*
\tolerance=5000
\bdata%BHK's example, TB11#1
 S I C T D S P*
Swam Oho Icecap
 o p m r t n l*
Bopeep Schedule
 s l a i y u  *
Thalassographer
   e s n a   r*
HAirpin UmbRage
 r   o S b i  *
ScaLenetriangLe
   o a u c g e*
AMounted Allege
 a v e e l e a*
Floral Nil Tace
 l e y t y s y*
\edata$$\crw$$
is obtained---after |\input|\ |crwrev.tex|---via
\verbatim
\bdata%BHK's example
 S I C T D S P*
Swam Oho Icecap
 o p m r t n l*
Bopeep Schedule
 s l a i y u  *
Thalassographer
   e s n a   r*
HAirpin UmbRage
 r   o S b i  *
ScaLenetriangLe
   o a u c g e*
AMounted Allege
 a v e e l e a*
Floral Nil Tace
 l e y t y s y*
\edata$$\crw$$
\endverbatim
\endarticle
\bye