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
|
%%
%% This is file `crosswrd.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% crosswrd.dtx (with options: `package')
%% Copyright C 1989 Brian Hamilton Kelly
%%
%% crossword macros for LaTeX
%% updated for LaTeX2e by Frank Mittelbach 96/12/06
%%
%% for documentation run latex crosswrd.dtx
%%
%% distribution consist of
%%
%% crosswrd.dtx source
%% crosswrd.ins installation script
%% 00readme
%%
%% don't distribute this file without distributing the above
%% files as well
%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{crosswrd}
[1996/12/06 v2.8b Generating crosswords (BHK)]
\def\ninept{\@setsize\ninept{11pt}\ixpt\@ixpt
\abovedisplayskip 8.5pt plus 3pt minus 4pt
\belowdisplayskip \abovedisplayskip
\abovedisplayshortskip \z@ plus2pt
\belowdisplayshortskip 4pt plus2pt minus 2pt
\def\@listi{\itemsep 0pt
\parsep \z@ plus 1pt
\topsep 4pt plus 2pt minus 2pt
}}
\newif\ifnumberit
\newcount{\gr@dsize}
\newcount{\p@csize}
\newcount{\Down}
\newcount{\Across}
\newwrite\tf@acr
\newwrite\tf@dwn
\def\OpenClueFiles{%
\immediate\openout \tf@acr \jobname.acr\relax
\immediate\openout \tf@dwn \jobname.dwn\relax
\@writefile{acr}{\begin{minipage}[t]{70mm}}%
\@writefile{acr}{ \centerline{\textbf{\ACROSStext}}}%
\@writefile{acr}{ \sloppy}%
\@writefile{acr}{ \ninept}%
\@writefile{acr}{ \begin{ClueList}}%
\@writefile{dwn}{\begin{minipage}[t]{70mm}}%
\@writefile{dwn}{ \centerline{\textbf{\DOWNtext}}}%
\@writefile{dwn}{ \sloppy}%
\@writefile{dwn}{ \ninept}%
\@writefile{dwn}{ \begin{ClueList}}}
\newcommand\ACROSStext{ACROSS}
\newcommand\DOWNtext{DOWN}
\def\CloseClueFiles{%
\@writefile{acr}{ \end{ClueList}}%
\@writefile{acr}{\end{minipage}}%
\@writefile{dwn}{ \end{ClueList}}%
\@writefile{dwn}{\end{minipage}}%
\immediate\closeout\tf@acr \let\tf@acr\relax
\immediate\closeout\tf@dwn \let\tf@dwn\relax
\endgraf
}
\def\ClueListlabel#1{\hspace\labelsep {\bf #1}\hss}
\def\ClueList{\list{}{\labelwidth\leftmargin
\advance \labelwidth by -\labelsep
\let\makelabel\ClueListlabel}}
\let\endClueList\endlist
\def\PrintClues{%
\centerline{%
\begin{tabular}{ c | c }
\@input{\jobname.acr}
&
\@input{\jobname.dwn}
\end{tabular}
}\endgraf
}
\def\crossword#1#2{%
\endgraf\leavevmode
\vtop\bgroup
\unitlength 6mm\numberittrue
\def\Header{}%
\OpenClueFiles
\TestAnswers{#2}%
\SetUpGrid{#1}}
\def\endcrossword{\endgraf
\centerline{\Header}%
\hbox{\FinishGrid}%
\CloseClueFiles
\hbox{\PrintClues}%
\egroup
}
\expandafter\def\csname crossword*\endcsname#1#2{%
\unitlength 4mm\numberitfalse
\endgraf\leavevmode
\vtop\bgroup
\def\Header{{\bf\strut #2}}%
\def\answer{Y}%
\let\tf@dwn=\relax \let\tf@acr=\relax
\SetUpGrid{#1}}
\expandafter\def\csname endcrossword*\endcsname{\endgraf
\centerline{\Header}%
\hbox{\FinishGrid}%
\egroup
}
\def\laterletter#1{\setsquare{\lettersquare{#1}}}
\def\nextletter#1#2{%
\ifx#2\@nil \let\nextlet=\@gobble
\else\letterput{#2}\advance#1 by \@ne
\let\nextlet=\nextletter
\let\letterput=\laterletter
\fi
\nextlet{#1}}
\def\blacktest{\blacksquare}
\newif\ifneed@d
\newif\ifNoerr
\Noerrtrue
\newtoks\Number \newtoks\Plain
\def\blank#1{\Plain}
\def\numbered#1#2{\Number}
\def\letterinsquare#1{#1}
\def\letterinnumbersquare#1#2{#2}
\def\setsquare#1{%
\need@dfalse
\ifx#1\blacksquare
\need@dtrue
\else
\expandafter\ifx\csname\ther@w\thec@l\endcsname\blacktest
\need@dtrue
\else
\let\lettersquare=\letterinsquare
\let\numbersquare=\letterinnumbersquare
\expandafter\if\csname\ther@w\thec@l\endcsname#1
\else
\ifNoerr
\errhelp{Two intersecting lights tried to
put different letters^^Jin the same square!
You've probably confused their coordinates.^^J
Carry on, and examine the printout.}
\errmessage{Illegal redefinition of square \ther@w\thec@l.
Was: \expandafter\meaning\csname\ther@w
\thec@l\endcsname.
Now: \noexpand #1}
\Noerrfalse
\fi
\fi
\let\lettersquare=\blank
\let\numbersquare=\numbered
\expandafter\ifx#1\Number
\need@dtrue
\fi
\fi
\fi
\ifneed@d
\expandafter\edef\csname\ther@w\thec@l\endcsname{\noexpand #1}
\fi
}
\def\clue#1#2#3#4#5#6#7{%
\findnumber{#1}
\ifx#2A
\if\@empty#7\relax\else
\ifx\tf@acr\relax\else
\@writefile{acr}{ \item[#1] #6 (#7)}%
\fi
\fi
\let\Direction=\Across
\else
\ifx#2D
\if\@empty#7\relax\else
\ifx\tf@dwn\relax\else
\@writefile{dwn}{ \item[#1] #6 (#7)}%
\fi
\fi
\let\Direction=\Down
\else
\errhelp{The second parameter of the \string\clue\space
command must be `A' or `D'}
\errmessage{Illegal direction (#1) specification
for \string\clue.}
\fi
\fi
\Across=#3 \Down=#4
\edef\letterput##1{\noexpand\setsquare
{\noexpand\numbersquare
{\noexpand\cluenumber}{##1}}}%
\nextletter{\Direction}#5\@nil
\ignorespaces
}
\newcount\clueNumber
\def\special@gobble #1\@nil{}
\def\findnumber#1{%
\afterassignment \special@gobble \clueNumber=0#1 \@nil
\ifnum\clueNumber=0
\errhelp{The first parameter of the \string\clue\space command
must commence with a digit}
\errmessage{Illegal clue number (#1) specified
for \string\clue.}
\fi
}
\def\cluenumber{\the\clueNumber}
\def\blackenrow{\let\savediterate\iterate
\loop\relax\ifnum\Across>\z@
\setsquare{\blacksquare}%
\advance\Across by \m@ne
\repeat
\let\iterate\savediterate
}
\def\SetUpGrid#1{%
\gr@dsize=#1
\p@csize=#1 \advance\p@csize by \@ne
\Down=\gr@dsize
\loop
\Across=\gr@dsize
\ifnum\Down>\z@
\blackenrow
\advance\Down by \m@ne
\repeat
}
\def\thec@l{C\romannumeral\Across}
\def\ther@w{R\romannumeral\Down}
\def\f@rst#1#2.{#1}
\def\TestAnswers#1{\edef\next{\def\noexpand\answer{#1}}%
\lowercase\expandafter{\next}%
\edef\answer{\expandafter \f@rst \answer .}%
\if\answer y \else \if\answer n \else
\typein[\answer]{Make answers visible? [Y/N]: }\fi
\fi
\edef\next{\def\noexpand\answer{\answer}}%
\uppercase\expandafter{\next}%
\edef\answer{\expandafter \f@rst \answer .}%
}
\def\letter#1{{\put(\Across,-\Down){\makebox(1,1){\sffamily #1}}}}
\def\numberedsquare#1#2{%
\put(\Across,-\Down){%
\begin{picture}(1,1)(0,0)
\put(0.05,0.05){\makebox(0.9,0.9)[tl]{\tiny #1}}
\end{picture}%
}
\letter{#2}}
\def\unnumberedsquare#1{\letter}
\def\FinishGrid{%
\if\answer Y \else \let \letter=\@gobble \fi
\ifnumberit
\let\numbersquare=\numberedsquare
\else
\let\numbersquare=\unnumberedsquare
\fi
\let\lettersquare=\letter
\def\blacksquare{%
\put(\Across,-\Down){\rule{\unitlength}{\unitlength}}}
\Down=\gr@dsize
\centerline{%
\begin{picture}(\p@csize,\p@csize)(1,-\p@csize)
\loop\ifnum\Down>\z@
\put(1,-\Down){\line(1,0){\the\gr@dsize}}
\Across=\gr@dsize
{\loop \ifnum\Across>\z@
\csname\ther@w\thec@l\endcsname
\advance\Across by \m@ne
\repeat
}%
\advance\Down by \m@ne
\repeat
\put(1,0){\line(1,0){\the\gr@dsize}}
\Across=\p@csize
\loop\ifnum\Across>\z@
\put(\Across,0){\line(0,-1){\the\gr@dsize}}
\advance\Across by \m@ne
\repeat
\end{picture}%
}%
}
\endinput
%%
%% End of file `crosswrd.sty'.
|