<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%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








</pre></body></html>