diff options
author | Karl Berry <karl@freefriends.org> | 2010-02-01 23:43:36 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-02-01 23:43:36 +0000 |
commit | b5175a492edaae1f38dd15addcbfeccf76033194 (patch) | |
tree | 77937c49ab2cbb89c57955c2073d224c98fb9a4b /Master/texmf-dist/source/latex/crosswrd | |
parent | 3556ffda02def0f822bd81adaa1a0f331e850ed6 (diff) |
crosswrd update (1feb10)
git-svn-id: svn://tug.org/texlive/trunk@16896 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/crosswrd')
-rw-r--r-- | Master/texmf-dist/source/latex/crosswrd/crosswrd.dtx | 944 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/crosswrd/crosswrd.ins | 42 |
2 files changed, 481 insertions, 505 deletions
diff --git a/Master/texmf-dist/source/latex/crosswrd/crosswrd.dtx b/Master/texmf-dist/source/latex/crosswrd/crosswrd.dtx index edf15c4ca90..741e54f8e87 100644 --- a/Master/texmf-dist/source/latex/crosswrd/crosswrd.dtx +++ b/Master/texmf-dist/source/latex/crosswrd/crosswrd.dtx @@ -3,6 +3,8 @@ %% Copyright 1989 Brian Hamilton Kelly %% updated for LaTeX2e by Frank Mittelbach 96/12/06 %% Updated for LPPL 1.3c or later by Clea F. Rees (for Frank Mittelbach), 2008/10/06. +%% +%% Upgraded with many new features by Dirk Laurie 2010/02/01 % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -22,11 +24,12 @@ \ProvidesFile{crosswrd.dtx} %</dtx> %<+package>\NeedsTeXFormat{LaTeX2e}[1995/12/01] +%<+package>\RequirePackage{ifthen} %<+package>\ProvidesPackage{crosswrd} %<*dtx,package> % \fi % \ProvidesFile{crosswrd.dtx} - [1996/12/06 v2.8b Generating crosswords (BHK)] + [2010/02/01 v3.0 Generating crosswords (BHK,DPL)] % % \iffalse %</dtx,package> @@ -40,7 +43,7 @@ %</driver> % \fi % -% \CheckSum{671} +% \CheckSum{813} % % \let\ifBigTeX=\iftrue ^^A Change this in the obvious fashion if an % ^^A enlarged (>75k maxmem) version of TeX is available @@ -67,12 +70,17 @@ % \changes{v2.5}{89/09/01}{Final revisions for publication} % \changes{v2.6}{89/10/13}{Consistent indentation of {\tt\protect\bslash % def}s} +% \changes{v2.9}{07/12/19}{Variable dimensions and type sizes, does barred +% grids, does rectangular grids, tests label compatibility, complete +% rewrite of grid population code} +% \changes{v3.0}{10/02/01}{LPPL copyright notice included} % % \title{Some Macros to Draw Crosswords\thanks{This file is \fileversion, % dated \filedate}} % \author{B Hamilton Kelly\thanks{Especial thanks to my colleague Niel % Kempson for many helpful suggestions, and to Frank Mittelbach of the -% Johannes Gutenberg University of Mainz, who saved me two pages of code!}} +% Johannes Gutenberg University of Mainz, who saved me two pages of code!} +% \\ Extensions by Dirk Laurie} % \maketitle % \begin{abstract} % The {\sf crossword} environment is intended to be used to typeset @@ -104,11 +112,20 @@ % % The macros presented in this document provide a \LaTeX{} method of % typesetting these, and also assist the composer to ensure that the -% ``grid'' all goes together correctly. The grid generated is the more +% ``grid'' all goes together correctly. That is to say, checks +% are made that crossing lights have the same letter where they cross, +% lights starting at the same square have the same clue number, +% and clue numbers are in sequence from 1 upwards when reading +% from top left to bottom right. + +% The grid generated can be the more % usual form, with black squares separating the ``lights'' which receive the -% answers to the clues. Work is in hand to be able to handle the {\sl -% Mephisto/Azed\/} type of grid, in which only thicker grid lines -% separate the lights. +% answers to the clues, or the {\sl Mephisto/Azed\/} type of grid, +% in which only thicker grid lines separate the lights, or even +% a mixture of these. The user need not specify which type of grid +% is to be used, since they are both described by the same simple rule: +% a bar is drawn between every pair of adjacent +% light squares that do not belong to the same light. % % A sample crossword appears as Figure~\ref{crossword:1}; I've left the % grid blank for those who want some intellectual exercise: those who don't @@ -118,10 +135,15 @@ % % \DescribeEnv{crossword} % The whole crossword, including the \verb+\clue+ commands ({\it q.v}.), -% is bracketed within the {\sf crossword} environment. This requires that -% the user specifies two parameters:\begin{description} -% \item[\meta{gridsize}] This is a number which specifies the columns -% (and rows) in the square grid. +% is bracketed within the {\sf crossword} environment. The user may +% specify one optional and must specify two required parameters: +% \begin{description} +% \item[\meta{gridrows}] The number of rows +% in the rectangular grid. If supplied, it must be enclosed in +% square brackets. It may be omitted if the number of rows +% equals the number of columns. +% \item[\meta{gridcols}] The number of columns +% in the rectangular grid. % \item[\meta{visible}] This controls whether the answers are to be % ``filled in''; obviously of no use for publication, but useful whilst % composing the crossword. If the parameter provided is the letter `{\tt @@ -136,10 +158,10 @@ % An analogous environment is provided especially for typesetting a smaller % version of a grid showing, for example, ``Last Month's Solution''. In % this of course, the answers {\em always\/} appear, and the clues are not -% printed. Again it takes two parameters: +% printed. Again it takes three parameters, the first optional: % \begin{description} -% \item[\meta{gridsize}] As before, this specifies the number of squares -% in each axis. +% \item[\meta{gridrows, gridcols}] As before, these specify the number +% of squares in the two axes. % \item[\meta{header\_text}] Some text which will be set (in {\bf bold}) % above the completed grid. % \end{description} @@ -149,10 +171,10 @@ % \protect\TeX's} % Here is an example of the {\sf crossword*} % environment: -% +% {\centering % \begin{crossword*}{15}{Last month's solution} % \MakePercentComment \input{grid0} \MakePercentIgnore -% \end{crossword*} +% \end{crossword*}} % \else % Figure~\ref{crossword:2} shows an example of the {\sf crossword*} % environment. @@ -172,9 +194,12 @@ % \item[\meta{row\_number}] The $y$-coordinate of the first square of the % light. The top-most row is numbered 1. % \item[\meta{answer}] The answer to the clue (or that part of it which -% appears in the light numbered \meta{clue\_number}). This must be a -% string of upper-case letters {\em only\/}; no spaces, punctuation, -% hyphens, etc. +% appears in the light numbered \meta{clue\_number}). Traditionally +% in a completed grid, this is a +% string of upper-case letters, but spaces in between are silently ignored, +% lower case letters are equally OK, and some other characters such as +% question mark and fullstop are useful as placeholders in an +% uncompleted grid. No hyphens or apostrophes, though. % \item[\meta{text}] The text of the clue itself. If you want to use any % \LaTeX{} macros in this text, such as \verb+\dots+, each such macro must % be preceded by \verb+\noexpand+. This includes such macros as \verb+\&+, @@ -183,28 +208,54 @@ % this will most usually be used for giving the length of the answer, such % as ``7'' or ``2,6,3-3''. Also used when the text of the clue is % associated with another light when this parameter may say something like -% ``see 14d''. +% ``see 14d''. If this parameter is left \emph{absolutely empty}, +% not merely blank, i.e.\ \verb+{}+, the clue (if any) +% will not be printed at all. % \end{description} +% +% \subsection{Customizing the layout} +% Some definitions made when entering the {\sf crossword} environment +% may be overridden by the user inside the environment. +% \begin{verbatim} +% \unitlength 6mm +% \def\Preamble{} +% \def\cluewidth{70mm} +% \let\numbersize\tiny +% \let\cluesize\ninept +% \def\barwidth{0.1} +% \end{verbatim} +% These refer respectively to size of grid cells, text to be set between +% the diagram and the clues, +% width of clue columns, typesize of numbers in grid, type size of +% clues, and width of bars in \verb+\unitlength+s. +% +% If you override +% \verb+\cluesize+ by a \LaTeX\ size command +% like \verb+\normalsize+, you will probably feel that there is too much +% vertical space between the clues. The only good solution is to +% write your own macro by adapting the definition of \verb+\ninept+ +% given below. % + % \subsection{How to Specify Clue Numbers}\label{clue-numbers} % % Sometimes the solution to one clue is split amongst a number of -% ``lights''. To cover this eventuality, provide a \verb+\clue+ for {\em +% lights. To cover this eventuality, provide a \verb+\clue+ for {\em % each\/} of the lights involved, with the solution to that light {\em % alone\/} given as \meta{answer}. All except the \verb+\clue+ % corresponding to the first light of the solution should have a null -% \meta{text}, and the \meta{help} parameter should be something like +% \meta{text}, and the \meta{help} parameter might be something like % ``see 7d''. % % \changes{v2.4}{89/08/15}{Support for empty help field} -% If this final parameter is totally empty, no corresponding clue number -% is printed: this facility would be used when the current clue is the -% next consecutive light, when it is usual to omit any further reference -% to the clue number. +% If you wish to omit any further reference +% to the clue number (the usual practice when the current clue +% applies to consecutive lights, or in hard cryptics), +% leave the \meta{help} field totally empty. % % The \verb+\clue+ for the first light of the solution % should provide the {\em entire\/} clue as its \meta{text}, and the -% \meta{help} should say something like ``7,3-3''. The \meta{clue\_number} +% \meta{help} might say something like ``7,3-3''. The \meta{clue\_number} % field should consist of the number of that light, followed immediately % by the text required to describe the other lights, separated from it by % some non-digit character, for example, a space. @@ -213,7 +264,7 @@ % \end{multicols} % % \begin{figure*}[tp] -% \begin{crossword}{15}{N} +% \begin{crossword}{15}{N} % \MakePercentComment \input{grid1} \MakePercentIgnore % \end{crossword} % \caption{A Sample Crossword}\label{crossword:1} @@ -225,7 +276,7 @@ % for the {\tt\string\&}} % \begin{verbatim} % \clue{13}{A}{5}{1}{PARLIAMENT}{}{see 9d} -% \clue{9 {\noexpand\rm\&} 13a}{D}{1}{10}{ACTOF}% +% \clue{9 {\noexpand\rm\&} 13a}{D}{1}{10}{ACT OF}% % {Bill's desired outcome?}{3,2,10} % \end{verbatim} % will produce\begin{description} @@ -245,6 +296,7 @@ % \end{figure} % \fi % + % \StopEventually{\PrintIndex % \PrintChanges % \ifBigTeX @@ -258,8 +310,8 @@ % % \begin{macro}{\ninept} % \begin{macro}{\@listi} -% We define a new font size to ensure clues are set at 9pt, no matter what -% style size option is in effect. This command also defines suitable +% We define a new 9pt font size for setting clues. +% This command also defines suitable % parameters for list environments set in this size of type. % % \begin{macrocode} @@ -283,7 +335,7 @@ % \begin{macro}{\numberitfalse} % % The {\sf crossword} environment draws a grid (with black and white -% squares); each ``light'' into which a clue's answer is to be written has +% squares); each light into which a clue's answer is to be written has % to be numbered, and this number will be typeset (using \verb+\tiny+) in % the top-left corner of the first square of the light. % @@ -300,21 +352,27 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\gr@dsize} +% \begin{macro}{\gridr@ws} +% \begin{macro}{\gridc@ls} % \changes{v2.3}{89/05/17}{Use a raw \protect\TeX\protect\space counter} +% \begin{macro}{\p@rsize} % \begin{macro}{\p@csize} % \changes{v2.3}{89/05/17}{Use a raw \protect\TeX\protect\space counter} -% The counter \verb+\gr@dsize+ is used to hold the width of the grid, as the -% number of squares in each direction. +% \changes{v2.9}{07/12/05}{Define more counters to allow rectangular grids.} +% The counters \verb+\gridr@ws+, \verb+\gridc@ls+, are used to hold the +% width of the grid, as the number of squares in each direction. % -% To prevent too much run-time arithmetic, the counter \verb+\p@csize+ is set -% to be one count higher than \verb+\gr@dsize+. +% To prevent too much run-time arithmetic, the counters \verb+\p@rsize+, +% \verb+\p@csize+ are set to be one count higher than \verb+\gridc@ls+, +% \verb+\gridr@ws+. % \begin{macrocode} -\newcount{\gr@dsize} -\newcount{\p@csize} +\newcount{\gridr@ws}\newcount{\gridc@ls} +\newcount{\p@rsize}\newcount{\p@csize} % \end{macrocode} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} % % \begin{macro}{\Down} % \changes{v2.3}{89/05/17}{Use a raw \protect\TeX\protect\space counter} @@ -370,26 +428,28 @@ % \changes{v2.8a}{96/07/22}{Removed string from \cs{@writefile} arg (FMi)} % \changes{v2.8a}{96/07/22}{Make clue column texts accessible (FMi)} % \begin{macrocode} - \@writefile{acr}{\begin{minipage}[t]{70mm}}% + \@writefile{acr}{\begin{minipage}[t]{\cluewidth}}% \@writefile{acr}{ \centerline{\textbf{\ACROSStext}}}% \@writefile{acr}{ \sloppy}% - \@writefile{acr}{ \ninept}% + \@writefile{acr}{ \cluesize}% \@writefile{acr}{ \begin{ClueList}}% % \end{macrocode} % Whilst something similar goes into the {\tt.dwn} file. % \begin{macrocode} - \@writefile{dwn}{\begin{minipage}[t]{70mm}}% + \@writefile{dwn}{\begin{minipage}[t]{\cluewidth}}% \@writefile{dwn}{ \centerline{\textbf{\DOWNtext}}}% \@writefile{dwn}{ \sloppy}% - \@writefile{dwn}{ \ninept}% + \@writefile{dwn}{ \cluesize}% \@writefile{dwn}{ \begin{ClueList}}} % \end{macrocode} -% \end{macro} +% \end{macro}\end{macro}\end{macro} % % \begin{macro}{\ACROSStext} % \changes{v2.8a}{96/07/22}{Make clue column texts accessible (FMi)} % \begin{macro}{\DOWNtext} % \changes{v2.8a}{96/07/22}{Make clue column texts accessible (FMi)} +% You may (e.g.\ if the crossword is not in English) prefer to change +% the column text headers. % \begin{macrocode} \newcommand\ACROSStext{ACROSS} \newcommand\DOWNtext{DOWN} @@ -425,8 +485,6 @@ } % \end{macrocode} % \end{macro} -% \end{macro} -% \end{macro} % % \subsection{Tabulating the Clues} % The auxiliary files contain the texts of the clues, each given as an @@ -470,17 +528,20 @@ % % \section{Creating the Grid} % The remaining commands are concerned with creating (and, optionally, -% populating) the crossword grid +% populating) the crossword grid. % -% \begin{macro}{\crossword} +% \begin{macro}{crossword} +% \begin{macro}{\c@ls} % -% The {\sf crossword} environment takes two parameters: {\em viz}.~the -% size of the matrix, and the indication of whether the grid is to include -% the answers. (If the latter is omitted, \LaTeX\ will request it -% interactively.) +% The {\sf crossword} environment takes three parameters: {\em viz}.~the +% number of rows (optional, may be omitted if the grid is square) and +% columns of the matrix, and the indication of whether the grid is to include +% the answers. (If the latter is not Y or N, \LaTeX\ will request it +% interactively.) The macro \verb+\c@ls+ is a communication mechanism. % % \begin{macrocode} -\def\crossword#1#2{% +\newenvironment{crossword}[3][\c@ls]{% + \def\c@ls{#2} % \end{macrocode} % % \changes{v2.4}{89/08/15}{Group within \string\crossword\space environment} @@ -488,20 +549,34 @@ % We start off with a \verb+\vtop+ box and a group to hold everything % within the environment, so as to ensure that user-entered text remains % with the crossword. +% \changes{v2.9}{07/12/04}{Changed to environment syntax, with +% optional argument for rectangular grids} % % \begin{macrocode} \endgraf\leavevmode \vtop\bgroup % \end{macrocode} % +% \begin{macro}{\Header} +% \begin{macro}{\cluewidth} +% \begin{macro}{\numbersize} +% \begin{macro}{\cluesize} +% \begin{macro}{\barwidth} % The {\sf crossword} environment uses the full-size grid, and has the % lights numbered. Furthermore it doesn't have any heading to output (see -% the {\sf crossword*} environment). +% the {\sf crossword*} environment). +% Some other macros are given so that the user can customize the layout. % % \begin{macrocode} \unitlength 6mm\numberittrue \def\Header{}% + \def\Preamble{}% + \def\cluewidth{70mm} + \let\numbersize\tiny + \let\cluesize\ninept + \def\barwidth{0.1} % \end{macrocode} +% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro} % % We now open the auxiliary files into which the clues are written, and % determine (interactively if necessary) whether the answers are to be @@ -509,21 +584,22 @@ % % \begin{macrocode} \OpenClueFiles - \TestAnswers{#2}% + \TestAnswers{#3}% % \end{macrocode} % -% Finally, we generate the necessary macros to describe the grid as being -% entirely filled with black squares; for each square, a macro whose name is -% of the form \verb+\RiCi+, \verb+\RxiiCviii+, {\em etc}.\ is created. As -% the \verb+\clue+ commands are read in, these will be redefined to produce -% the correct appearance when the macros are later expanded. -% +% Finally, we generate the necessary macros to describe the grid. +% For each square, there are three macros. For example, corresponding +% to the square in row 4 from the top, column 2 from the +% left, the macros are: \smallskip \\ \hspace{1cm} +% \begin{tabular}{ll} +% \verb+\LetterRivCii+ & Letter in the square; \texttt{!} is used for a black square.\\ +% \verb+\NumberRivCii+ & Number in the square; 0 is used for a numberless square.\\ +% \verb+\BarRivCii+ & Code defining bars around the square, defined below. +% \end{tabular} \smallskip \\ +% % \begin{macrocode} - \SetUpGrid{#1}} + \SetUpGrid{#1}{\c@ls}} % \end{macrocode} -% \end{macro} -% -% \begin{macro}{\endcrossword} % % When all the clues have been processed, we can invoke \verb+\FinishGrid+ % to draw the grid. The \verb+\FinishGrid+ and \verb+\PrintClues+ commands @@ -536,7 +612,7 @@ % we'll print it just above the grid itself. % % \begin{macrocode} -\def\endcrossword{\endgraf +{\endgraf \centerline{\Header}% \hbox{\FinishGrid}% % \end{macrocode} @@ -549,24 +625,27 @@ % Finally, we complete the group and the \verb+\vtop+ box. % % \begin{macrocode} + \ifthenelse {\equal{\Preamble}{}} {} + {\centerline{\parbox{\textwidth}{\Preamble}}\medskip} \CloseClueFiles \hbox{\PrintClues}% \egroup } % \end{macrocode} -% \end{macro} +% \end{macro}\end{macro} % -% \begin{macro}{\crossword*} -% \changes{v2.6}{89/10/13}{Removed {\tt\protect\bslash iffalse} hack} -% \begin{macro}{\endcrossword*} -% \changes{v2.1}{89/04/27}{No longer opens {\tt.acr} and {\tt.dwn} files} +% \begin{macro}{crossword*} +% \changes{v2.1}{89/04/27}{No longer opens {\tt.acr} and {\tt.dwn} files} % \changes{v2.6}{89/10/13}{Removed {\tt\protect\bslash iffalse} hack} +% \changes{v2.9}{07/12/04}{Changed to environment syntax, with +% optional argument for rectangular grids} % The {\sf crossword*} environment doesn't need a second parameter to % control printing of answers, because it {\bf always} populates the grid % with the answers. Instead, its second parameter provides the text to % appear above the printed grid. Its actions are as for the {\sf % crossword} environment except that\begin{itemize} -% \item It prints the descriptive text above the grid. +% \item It assumes that there is descriptive text above the grid +% and allows room for it. % \item It {\bf always} outputs the answers, without numbers. % \item It draws them in a smaller box. % \item It doesn't output the clues (it doesn't even open any @@ -574,38 +653,92 @@ % \end{itemize} % % \begin{macrocode} -\expandafter\def\csname crossword*\endcsname#1#2{% +\newenvironment{crossword*}[3][\c@ls]{% + \def\c@ls{#2} \unitlength 4mm\numberitfalse + \def\barwidth{0.1} \endgraf\leavevmode \vtop\bgroup - \def\Header{{\bf\strut #2}}% + \def\Header{{\bf\strut #3}}% \def\answer{Y}% \let\tf@dwn=\relax \let\tf@acr=\relax - \SetUpGrid{#1}} - -\expandafter\def\csname endcrossword*\endcsname{\endgraf + \SetUpGrid{#1}{#2}} +{\endgraf \centerline{\Header}% \hbox{\FinishGrid}% \egroup } % \end{macrocode} % \end{macro} -% \end{macro} -% -% \subsection{Macros used when Populating the Grid} % -% \begin{macro}{\laterletter} -% \changes{v2.1}{89/04/27}{Used to be {\tt\protect\bslash letterput}} -% The following macro calls this to ``place'' the letters of a solution by -% defining a macro unique to this square. -% +% \subsection{Macros for each square} +% \changes{v2.9}{07/12/19}{The part of the code dealing with grid details has +% been completely rewritten. (DPL)} +% \begin{macro}{\ind@x} +% \begin{macro}{\arr@yref} +% \begin{macro}{\value} +% \begin{macro}{\assign} +% \begin{macro}{\addto} +% Crosswords are inherently two-dimensional, and require matrices +% of related definitions. Since \TeX\ does not allow numbers in +% a name, each square has a unique text index using \texttt{R} and +% \texttt{C} followed by roman numerals. Each macro name consists +% of a prefix (the same for all squares) followed by the unique +% text index. The original version of this +% package had only one such macro for each square, with an empty prefix, +% but in this version we have three: \texttt{Letter}, \texttt{Number} +% and \texttt{Bar}. +% +% For readability of the code, the following macros provide bracket +% syntax, thereby avoiding the use of \verb+\csname+\ldots\verb+\endcsname+ +% elsewhere. +% For example, \verb+\value Bar[2,5]+ gives \verb+\BarRiiCv+. +% A new definition \texttt{NEW} is assigned by \verb+\assign Bar[2,5]=NEW;+. +% If the contents of \verb+\BarRiiCv+ is a number, you can add 31 +% to it using \verb"\addto Bar[2,5]+=31;". In both cases, the semicolon +% is essential. +% \begin{macrocode} +\def\ind@x#1#2{R\romannumeral #1C\romannumeral#2} +\def\arr@yref#1#2#3{\csname #1\ind@x{#2}{#3}\endcsname} +\def\value#1[#2,#3]{\arr@yref{#1}{#2}{#3}} +\def\assign#1[#2,#3]=#4;% +{\expandafter\edef\csname #1\ind@x{#2}{#3}\endcsname{#4}} +\newcount\accumulat@r +\def\addto#1[#2,#3]+=#4;% +{\accumulat@r=\value #1[#2,#3] \advance\accumulat@r by #4 + \assign #1[#2,#3]=\the\accumulat@r;} +% \end{macrocode} +% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro} + +% We do bars as follows: in addition to \verb+\RiCii+ etc which define the +% contents of a square, there is a bar code \verb+\BarRiCii+ etc with +% the following meaning: +% \begin{enumerate} +% \item[0:] no bar above or to the left of the square +% \item[1:] bar above the square +% \item[2:] bar to the left of the square +% \item[3:] bars above and to the left of the square +% \end{enumerate} +% At the start, all bar codes are set to 3; +% the bars between letters are erased as we go along. + +% \subsection{Macros used while processing the clues} + +% \begin{macro}{\lettercount} +% \begin{macro}{\Barcode} +% As we move along the letters of the answer, we count +% the number of letters processed in \verb+\lettercount+. +% The code for the bar to be erased (1 or 2) is put +% into \verb+Barcode+ before we start on each answer. % \begin{macrocode} -\def\laterletter#1{\setsquare{\lettersquare{#1}}} +\newcount\lettercount +\newcount\Barcode % \end{macrocode} -% +% \end{macro} +% \end{macro} + % \begin{macro}{\nextletter} % \begin{macro}{\nextlet} -% % To determine how much space is required for the light corresponding to % an answer, we need to cycle through each of the characters of the answer % individually; this macro is called with two parameters --- the first @@ -615,7 +748,7 @@ % When it is called, this ``second'' parameter is {\em not\/} enclosed in % braces, so only the first token in it is accessed. The macro calls % itself recursively to process the remaining characters until the -% \verb+\@nil+ has been met. +% \verb+\@nil+ has been met. % % \changes{v2.1}{89/04/27}{Can now process {\em first\/} letter of light} % \begin{macrocode} @@ -633,11 +766,22 @@ % \end{macrocode} % % Otherwise, we have another letter of the \meta{answer} in {\tt\#2}, so we -% call \verb+\letterput+ to define the macro corresponding to this square, -% and count one more position occupied in the current direction. +% save the letter and check that it does not conflict with an earlier letter +% in the same square. % % \begin{macrocode} - \else\letterput{#2}\advance#1 by \@ne + \else \immediate\edef\Before{\value Letter[\Down,\Across]} + \assign Letter[\Down,\Across]=#2; + \immediate\edef\After{\value Letter[\Down,\Across]} + \if \Before ! \else \if \Before \After + \else \errhelp{You mistyped an answer, or miscounted the coordinates.} + \errmessage{Letter "\After" conflicts with earlier "\Before" + in row \the\Down, column \the\Across} + \fi \fi +% If the letter is not the first letter of its answer, we erase a bar. + \ifnum \lettercount>0 \addto Bar[\Down,\Across]+=-\Barcode; \fi +% Advance another position in the current direction. + \@gobble{#2} \advance#1 by \@ne \global\advance \lettercount by \@ne % \end{macrocode} % % After we've processed this letter, we want to call this routine @@ -646,13 +790,6 @@ % \changes{v2.1}{89/04/27}{Change to handle subsequent letters of light} % \begin{macrocode} \let\nextlet=\nextletter -% \end{macrocode} -% -% These letters cannot possibly require a starting square number, so we -% use a simpler macro for these later letters. -% -% \begin{macrocode} - \let\letterput=\laterletter \fi % \end{macrocode} % @@ -666,214 +803,9 @@ % \end{macrocode} % \end{macro} % \end{macro} -% \end{macro} -% -% -% \begin{macro}{\blacktest} -% Later we shall want to check that the square into which we are ``putting'' -% a letter is either black (and hence should be changed to contain the -% character) or has already had the {\em same\/} letter put into it by an -% intersecting light. -% -% We don't want to expand each squares' macros, so these tests have to use -% the \verb+\ifx+ primitive; therefore, we need a macro which has the same -% substitution text {\em at the highest level}. -% -% \begin{macrocode} -\def\blacktest{\blacksquare} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\ifneed@d} -% \begin{macro}{\need@dtrue} -% \begin{macro}{\need@dfalse} -% As we create the macros corresponding to each occupied square, we have to -% decide whether it is necessary to actually perform a (re)definition of the -% macro; the following permits the code to determine whether such definition -% takes place (within the \verb+\putsquare+ macro). -% -% \begin{macrocode} -\newif\ifneed@d -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\ifNoerr} -% \begin{macro}{\Noerrtrue} -% \begin{macro}{\Noerrfalse} -% If an error is detected during the placement of the occupied squares, -% there will probably be other errors; to save pouring out yards of error -% messages, we arrange to suppress all but the first such; the following -% \verb+\newif+ provides this facility. % -% And of course we start without any errors! -% -% \begin{macrocode} -\newif\ifNoerr -\Noerrtrue -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\Number} -% \begin{macro}{\Plain} -% To determine whether a square has already been occupied, and if so, by -% what, we require a couple of new tokens which can be tested for as the -% result of a macro expansion -% \begin{macrocode} -\newtoks\Number \newtoks\Plain -% \end{macrocode} -% -% \begin{macro}{\blank} -% \begin{macro}{\numbered} -% The next two definitions can be temporarily \verb+\let+ to be the -% replacements for \verb+\lettersquare+ and \verb+\numbersquare+ -% respectively, for use in conjunction with the aforementioned test. -% -% \begin{macrocode} -\def\blank#1{\Plain} -\def\numbered#1#2{\Number} -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\letterinsquare} -% \begin{macro}{\letterinnumbersquare} -% When we first read the clues, we create macros which are unique to each -% square; later we shall redefine the macros to which the squares' macros -% expand to actually perform the setting, but during the first phase we -% require expansions which correspond to the parameters alone. The -% following definitions are therefore used during the ``filling'' phase. -% -% \begin{macrocode} -\def\letterinsquare#1{#1} -\def\letterinnumbersquare#1#2{#2} -% \end{macrocode} -% -% \begin{macro}{\setsquare} -% As we scan the answers for each clue, this macro is called with a -% parameter which specifies a call of either the \verb+\lettersquare+ or -% \verb+\numbersquare+ macros (with appropriate parameters). -% -% It starts by assuming that no redefinition of the square's macro will be -% required. -% -% \begin{macrocode} -\def\setsquare#1{% - \need@dfalse -% \end{macrocode} -% -% This macro is also called during the initialization of the grid, when we -% populate it with black squares; therefore, we definitely want to perform a -% definition of the square's macro at this stage. -% -% \begin{macrocode} - \ifx#1\blacksquare - \need@dtrue -% \end{macrocode} -% -% Otherwise, let's have a look and see what is already in the square's -% macro. This test will succeed only if the square contains its initial -% definition (as \verb+\blacksquare+). -% \begin{macrocode} - \else - \expandafter\ifx\csname\ther@w\thec@l\endcsname\blacktest -% \end{macrocode} -% -% in which case we {\em will\/} want to redefine the macro for this square -% -% \begin{macrocode} - \need@dtrue -% \end{macrocode} -% -% If the square has already been redefined, it means we've already ``put'' a -% letter (or number+letter) into its definition, so we will have to check -% that this definition doesn't conflict with the new one (which is in -% {\tt\#1}). We have to expand the macros to perform this test, but don't -% want that expansion to return anything except the letter which is being -% (and has been) placed in the square, so we make a temporary replacement -% for the two macros which might form our {\tt\#1}. -% \begin{macrocode} - \else - \let\lettersquare=\letterinsquare - \let\numbersquare=\letterinnumbersquare -% \end{macrocode} -% -% Now we {\em expand\/} the original definition and the new one; these -% should be the same! -% \changes{v2.6}{89/10/13}{Minor revision of layout} -% -% \begin{macrocode} - \expandafter\if\csname\ther@w\thec@l\endcsname#1 - \else -% \end{macrocode} -% -% If they aren't, it means the compiler of the crossword has made a mistake -% and has solutions which don't correctly intersect: tell him so (well, the -% first time anyway). We even provide the user with some help! -% -% \begin{macrocode} - \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 -% \end{macrocode} -% -% So far, we don't seem to need to change anything, but if the new {\tt\#1} -% which has been passed to \verb+\putsquare+ specifies that it be numbered, -% we must subsume any existing definition which {\em doesn't\/} have a -% number. -% -% Again, we make temporary reassignments for the two potential macros, which -% is where we make use of the two new tokens that we invented. -% -% \begin{macrocode} - \let\lettersquare=\blank - \let\numbersquare=\numbered -% \end{macrocode} -% -% If the following test succeeds, we know that the new parameter specifies a -% number as well as a letter. This code could be expanded to check whether -% the original definition also specified a number, and if so ensure that -% they are the same, but would anybody really be silly enough to give -% different numbers for clues starting from the same square?! -% \begin{macrocode} - \expandafter\ifx#1\Number - \need@dtrue - \fi - \fi - \fi -% \end{macrocode} -% -% Now we know whether we must (re)define the macro which is unique to this -% square. If we must, we expand our {\tt\#1}, so as to get the actual -% number and letter passed in through that parameter, but keep the name of -% the placement macro itself\footnote{This will be the first token of the -% parameter itself.} unexpanded. -% -% \begin{macrocode} - \ifneed@d - \expandafter\edef\csname\ther@w\thec@l\endcsname{\noexpand #1} - \fi -} -% \end{macrocode} -% \end{macro} ^^A \setsquare -% \end{macro} ^^A \letterinnumbersquare -% \end{macro} ^^A \letterinsquare -% + % \subsection{The {\tt\protect\bslash clue} Command} % % \begin{macro}{\clue} @@ -885,8 +817,31 @@ % % \begin{macrocode} \def\clue#1#2#3#4#5#6#7{% +% \end{macrocode} +% The $x$ and $y$ coordinate counters are set from the \meta{column} and +% \meta{row} parameters. +% +% \begin{macrocode} + \Across=#3 \Down=#4 +% \end{macrocode} +% The clue may be spread over more than one number, but the square +% takes only the first of these. +% \begin{macrocode} \findnumber{#1} % \end{macrocode} +% Save the clue number, checking that it was not previously defined +% to be something else. +% \begin{macrocode} + \immediate\edef\Before{\value Number[\Down,\Across]} + \assign Number[\Down,\Across]=\cluenumber; + \immediate\edef\After{\value Number[\Down,\Across]} + \ifnum \Before>0 \ifnum \After=\Before + \else \errhelp + {You probably made a mistake when typing in one of the clues.} + \errmessage{Number {\After} conflicts with earlier {\Before} + in row \the\Down, column \the\Across} + \fi \fi +% \end{macrocode} % % We now examine the second (\meta{Across/Down}) parameter of the % \verb+\clue+ command to determine whether this is an Across or Down @@ -902,13 +857,15 @@ % \meta{Across/Down} parameter is the letter `{\tt A}'. In this case, the % counter to be incremented is \verb+\Across+. % \changes{v2.8a}{96/07/22}{Removed string from \cs{@writefile} arg (FMi)} +% \changes{v2.9}{07/12/19}{Change empty test to use \cs{ifthenelse}. +% Testing by \cs{if} is a bug. (DPL)} % \begin{macrocode} \ifx#2A - \if\@empty#7\relax\else + \global\Barcode=2 + \ifthenelse{\equal{\@empty}{#7}}{}{ \ifx\tf@acr\relax\else \@writefile{acr}{ \item[#1] #6 (#7)}% - \fi - \fi + \fi} \let\Direction=\Across \else % \end{macrocode} @@ -916,11 +873,11 @@ % file, and the \verb+\Down+ counter is incremented. % \begin{macrocode} \ifx#2D - \if\@empty#7\relax\else - \ifx\tf@dwn\relax\else - \@writefile{dwn}{ \item[#1] #6 (#7)}% - \fi - \fi + \global\Barcode=1 + \ifthenelse{\equal{\@empty}{#7}}{}{ + \ifx\tf@dwn\relax\else + \@writefile{dwn}{ \item[#1] #6 (#7)}% + \fi} \let\Direction=\Down \else % \end{macrocode} @@ -937,39 +894,15 @@ \fi % \end{macrocode} % -% The $x$ and $y$ coordinate counters are set from the \meta{column} and -% \meta{row} parameters. -% -% \begin{macrocode} - \Across=#3 \Down=#4 -% \end{macrocode} -% -% \begin{macro}{\letterput} -% \changes{v2.1}{89/04/27}{Replacement for {\tt\protect\bslash firstletter} -% method} -% -% The \verb+\letterput+ macro is defined anew at the start of each clue to -% create the correct definition for the {\em first\/} square of each -% light. The \verb+\setsquare+ macro redefines this macro internally for -% the remaining squares. -% -% \begin{macrocode} - \edef\letterput##1{\noexpand\setsquare - {\noexpand\numbersquare - {\noexpand\cluenumber}{##1}}}% -% \end{macrocode} -% \end{macro} -% % Now we can call \verb+\nextletter+ which will cycle through all the % letters of the \meta{answer} until meeting the token \verb+\@nil+. -% As each letter is processed, it creates a definition for the current -% square, initially using the above definition, and then \verb+\laterletter+ -% for subsequent letters of the \meta{answer}. -% +% It will save the current letter and recursively call itself until no +% letters are left. % Finally, we ensure that the newlines after \verb+\clue+ commands don't % lead to unwanted spaces being typeset. % \changes{v2.6}{89/10/13}{Minor revision of layout} % \begin{macrocode} + \global\lettercount=0 \nextletter{\Direction}#5\@nil \ignorespaces } @@ -1026,7 +959,8 @@ % \changes{v2.6}{89/10/13}{Minor revision of layout} % If the user did not provide a valid \meta{clue\_number} (i.e.\ something % starting with a digit), then \verb+clueNumber+ will have zero assigned to -% it --- seems the user ought to be told about this! +% it. This will cause a diagnostic message at the stage when it is checked +% that the clue numbers run consecutively in reading order from 1 upwards. % % This completes \verb+\findnumber+. % @@ -1055,13 +989,9 @@ % \changes{v2.2}{89/05/17}{Used {\tt\protect\bslash blackenrow} for inner loop} % \changes{v2.8a}{96/07/22}{Fixed command to save val of \cs{iterate} % not \cs{body} (FMi)} -% For each column in a row we create a black square; effectively -% \verb+\setsquare+ will execute the definition -% \begin{macrocode} -% \def\csname\ther@w\thec@l\endcsname{\blacksquare} -% \end{macrocode} -% so that for row~3 column~6 of a $15\times15$ grid, for example, we would -% end up by defining \verb+\def\RiiiCvi{\blacksquare}+. +% For each column in a row we create a black square by setting the +% letter in the square to \texttt{!}. We also initialize the \texttt{Number} +% and \texttt{Bar} macros. % % Before starting the inner loop, we need to save the definition of % \verb+\body+ which was created for the outer loop. We cannot do this by @@ -1070,12 +1000,14 @@ % % Actually with \LaTeXe{} we have to save \verb=\iterate= as the internals % of \verb=\loop= have been streamlined. With the old code only the first -% row was updated---this is the rpcie for using an unpublished implementation +% row was updated---this is the price for using an unpublished implementation % feature. % \begin{macrocode} \def\blackenrow{\let\savediterate\iterate \loop\relax\ifnum\Across>\z@ - \setsquare{\blacksquare}% + \assign Bar[\Down,\Across]=3; + \assign Letter[\Down,\Across]=!; + \assign Number[\Down,\Across]=0; % \end{macrocode} % % We then shift ourselves back to the next column to the left and iterate. @@ -1092,22 +1024,25 @@ % \end{macrocode} % % \begin{macro}{\SetUpGrid} +% \changes{v2.9}{07/12/05}{Rectangular grids} % % This macro creates an empty grid of the appropriate size. % % \begin{macrocode} -\def\SetUpGrid#1{% +\def\SetUpGrid#1#2{% % \end{macrocode} % -% We firstly make a note of the \meta{gridsize} parameter in the -% \verb+\gr@dsize+ counter, from which the width and height of the grid +% We firstly make a note of the \meta{gridcols} parameter in the +% \verb+\gr@dcols+ counter, from which the width and height of the grid % may be computed. We also set the \verb+\p@csize+ counter to be one -% greater than \verb+\gr@dsize+ to save our recomputing this quantity many -% times over. +% greater than \verb+\gridc@ls+ to save our recomputing this quantity many +% times over. Ditto mutatis mutandis for \meta{gridrows}. % % \begin{macrocode} - \gr@dsize=#1 - \p@csize=#1 \advance\p@csize by \@ne + \gridr@ws=#1\gridc@ls=#2 + \p@rsize=#1 \advance\p@rsize by \@ne + \p@csize=#2 \advance\p@csize by \@ne + \typeout{Grid has #1 rows and #2 columns.} % \end{macrocode} % % Right, this is where we start to generate the grid itself. We start at @@ -1116,7 +1051,7 @@ % number attainable. % % \begin{macrocode} - \Down=\gr@dsize + \Down=\gridr@ws % \end{macrocode} % % We now start a loop, so the following code will be repeated for each row @@ -1126,7 +1061,7 @@ % % \begin{macrocode} \loop - \Across=\gr@dsize + \Across=\gridc@ls % \end{macrocode} % % Provided we haven't decremented down to the 0th row, we start off the @@ -1155,22 +1090,6 @@ % \end{macro} ^^A \SetUpGrid % \end{macro} ^^A \blackenrow % -% \begin{macro}{\thec@l} -% \begin{macro}{\ther@w} -% \verb+\thec@l+ and \verb+\ther@w+ macros generate a string of letters, -% starting with `{\tt C}' (for column) and `{\tt R}' (for row) respectively. -% The remainder of the string consists of the lower-case Roman numeral -% equivalent to the current value of the appropriate counter. Such -% all-letter strings are used to create the names for macros which can be -% unique for each square of the grid. -% -% \begin{macrocode} -\def\thec@l{C\romannumeral\Across} -\def\ther@w{R\romannumeral\Down} -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \begin{macro}{\TestAnswers} % This macro interacts with the user, if necessary, to get a yes or no % indication of whether the answers shall be written into the grid. No @@ -1195,7 +1114,7 @@ % \end{macrocode} % We can then extract just the first character % \begin{macrocode} - \edef\answer{\expandafter \f@rst \answer .}% + \edef\answer{\expandafter \f@rst \answer n.}% % \end{macrocode} % The we determine whether it's the letter `{\tt y}' or `{\tt n}'\dots % \begin{macrocode} @@ -1212,7 +1131,7 @@ % \begin{macrocode} \edef\next{\def\noexpand\answer{\answer}}% \uppercase\expandafter{\next}% - \edef\answer{\expandafter \f@rst \answer .}% + \edef\answer{\expandafter \f@rst \answer n.}% } % \end{macrocode} % \end{macro} @@ -1221,25 +1140,27 @@ % % \subsection{Setting the Grid} % -% \begin{macro}{\letter} -% This is the expansion which is used (for \verb+\letterinsquare+, -% and within the expansion of \verb+\numberedsquare+) when the grid is -% actually being {\em typeset\/} from the stored squares' macros. +% \begin{macro}{\putletter} % % \changes{v2.8a}{96/07/22}{use \cs{sffamily} (FMi)} +% These macros put letters, numbers and bars at the current +% \verb+[\Down,\Across]+ position. Note that \verb+\putletter+ +% would be redefined to \verb+\relax+ if no actual letters are required. % \begin{macrocode} -\def\letter#1{{\put(\Across,-\Down){\makebox(1,1){\sffamily #1}}}} +\def\putletter{{\put(\Across,-\Down){\makebox(1,1) + {\sffamily \value Letter[\Down,\Across]}}}} % \end{macrocode} -% -% \begin{macro}{\numberedsquare} -% This macro is used (for \verb+\numbersquare+) when the lights are being -% drawn with light numbering enabled. It puts the number (and the letter of -% the answer too, depending upon the definition of \verb+\letter+ which is -% current) at the current coordinate position specified by -% \verb+(\Across,\Down)+. +% \begin{macro}{\putnumber} +% The \verb+\putnumber+ macro checks whether the clue number is 0 (which +% means an unnumbered square) and whether the clue numbers are in +% sequence. To this end, it makes use of global \verb+\oldnumber+ +% and \texttt{seqtest}. % \begin{macrocode} -\def\numberedsquare#1#2{% - \put(\Across,-\Down){% +\newcount\oldnumber \oldnumber=0 +\newif\ifseqtest \seqtestfalse +\def\putnumber{\immediate\def\Number{\value Number[\Down,\Across]} + \ifnumberit \ifnum\Number>0 + \put(\Across,-\Down){% % \end{macrocode} % % To insert the clue number, we generate it within a sub-picture, of size @@ -1250,37 +1171,57 @@ % \end{macrocode} % % We stick the number in the top-left corner of an (invisible) box which -% fills the central 81\% of the area. -% -% \begin{macrocode} - \put(0.05,0.05){\makebox(0.9,0.9)[tl]{\tiny #1}} - \end{picture}% - } -% \end{macrocode} -% -% We also set the letter in the square (depending upon the definition of -% \verb+\letter+ which applies. +% fills the central 81\% of the area. In the process, we check whether +% the clues are properly numbered in reading order. % % \begin{macrocode} - \letter{#2}} + \put(0.05,0.05){\makebox(0.9,0.9)[tl]{\numbersize\Number}} + \end{picture}} + \ifnum \oldnumber>0 \advance\oldnumber by\m@ne + \ifnum \oldnumber=\Number {\seqtesttrue} \else + \ifseqtest + \errhelp{Clues should be numbered consecutively from top left + to bottom right.} + \errmessage{Found clue number \Number, but expected \the\oldnumber} % \end{macrocode} -% -% \begin{macro}{\unnumberedsquare} -% Despite its name, this macro is invoked (through \verb+\numbersquare+) for -% those squares which would ordinarily carry a light's number, were it not -% for the fact that the numbers have been suppressed by the {\sf crossword*} -% environment. -% -% It just discards the \meta{clue\_number} given in the first parameter and -% sets the current letter by invoking \verb+\letter+, which uses the second -% parameter\dots +% If a clue number was mistyped, it will generate two out-of-sequence +% errors. We suppress the second of these. % % \begin{macrocode} -\def\unnumberedsquare#1{\letter} + \seqtestfalse + \else\seqtesttrue\fi + \fi + \fi + \global \oldnumber=\Number +\fi \fi +} % \end{macrocode} -% \end{macro} ^^A \unnumberedsquare -% \end{macro} ^^A \numberedsquare -% \end{macro} ^^A \letter +% \begin{macro}{\putbars} +% If there are two adjacent light squares not belonging to the same light, +% we draw a bar between them. We use two counters for that: one for the +% previous square, so we can test for its blackness; one for the +% changing value of the barcode for the current square. +% \begin{macrocode} +\newcount \pr@vious +\newcount \c@de +\def\putbars{ \linethickness{\barwidth\unitlength} + \c@de=\value Bar[\Down,\Across] + \ifnum \c@de>1 \advance\c@de by -2 + \ifnum \Across>1 + \pr@vious=\Across \advance \pr@vious by -1 + \immediate\def\pr@vlet{\value Letter[\Down,\pr@vious]} + \if \pr@vlet ! \else \put(\Across,-\Down){\line(0,1){1}} + \fi \fi \fi + \ifnum \c@de>0 + \ifnum \Down>1 + \pr@vious=\Down \advance \pr@vious by -1 + \immediate\def\pr@vlet{\value Letter[\pr@vious,\Across]} + \if \pr@vlet ! \else \put(\Across,-\pr@vious){\line(1,0){1}} + \fi \fi \fi +} +% \end{macrocode} +% +% \end{macro}\end{macro}\end{macro} % % \begin{macro}{\FinishGrid} % Now we can process all the stored macros which define the appearance of @@ -1291,62 +1232,28 @@ % different effects during the filling of the grid. % \changes{v2.2}{89/05/17}{Removed extraneous opening space after brace} % \changes{v2.6}{89/10/13}{Minor revision of layout} +% \changes{v2.9}{07/12/05}{Rectangular grid, top right extra labels} % \begin{macrocode} \def\FinishGrid{% % \end{macrocode} % % If the customer doesn't want the letters put into the grid, then we -% need only throw away any parameter to \verb+letter+. -% -% \begin{macrocode} - \if\answer Y \else \let \letter=\@gobble \fi -% \end{macrocode} -% -% As stated in the introduction, when typesetting the grid in a smaller -% version, there is insufficient space to include the numbers for the -% lights; by testing \verb+\ifnumberit+ we can determine whether a macro -% which expands to \verb+\numbersquare+ shall result in a number being -% printed or not. -% -% \begin{macrocode} - \ifnumberit - \let\numbersquare=\numberedsquare - \else - \let\numbersquare=\unnumberedsquare - \fi -% \end{macrocode} -% -% Anything that's been stored as a \verb+\lettersquare+ is ``set'' using the -% \verb+\letter+ macro (which we might have just \verb+\let+ equal to -% \verb+\@gobble+). -% -% \begin{macrocode} - \let\lettersquare=\letter -% \end{macrocode} -% -% \begin{macro}{\blacksquare} -% Any black squares that are still left in the grid are set by means of this -% command: +% need only let \verb+\putletter+ do nothing. Since \verb+\FinishGrid+ +% is invoked inside the environment, the original definition will be +% restored on exit. % % \begin{macrocode} - \def\blacksquare{% -% \end{macrocode} -% -% The black square itself is merely a rule of the appropriate dimensions. -% -% \begin{macrocode} - \put(\Across,-\Down){\rule{\unitlength}{\unitlength}}} + \if\answer Y \else \let\putletter\relax \fi % \end{macrocode} -% \end{macro} -% % % Now we come to the actual body of \verb+\FinishGrid+. % % \changes{v2.6}{89/10/13}{Minor revision of layout} +% \changes{v2.9}{07/12/05}{Rectangular grid} % We start off at the bottom-most row of the grid\dots % % \begin{macrocode} - \Down=\gr@dsize + \Down=\gridr@ws % \end{macrocode} % % The whole grid is created in a centered \verb+\hbox+ in a {\sf picture} @@ -1356,7 +1263,7 @@ % % \begin{macrocode} \centerline{% - \begin{picture}(\p@csize,\p@csize)(1,-\p@csize) + \begin{picture}(\p@csize,\p@rsize)(1,-\p@rsize) % \end{macrocode} % % We now cycle through each of the rows. The first thing we output is a @@ -1366,14 +1273,14 @@ % % \begin{macrocode} \loop\ifnum\Down>\z@ - \put(1,-\Down){\line(1,0){\the\gr@dsize}} + \put(1,-\Down){\line(1,0){\the\gridc@ls}} % \end{macrocode} % % Now we are about to cycle across all the columns of the current row; % again, it's convenient for us to work backwards to the left\dots % % \begin{macrocode} - \Across=\gr@dsize + \Across=\gridc@ls % \end{macrocode} % % To do this we need an inner loop; this has to be inside a group so as to @@ -1383,13 +1290,16 @@ {\loop \ifnum\Across>\z@ % \end{macrocode} % -% To set the appropriate object in this square, we merely invoke the macro -% which has been associated with the square. Thus we'll end up with a black -% square, or a numbered or plain square, the latter two of which may also -% contain a letter. -% +% A black square is represented by \texttt{!} instead of a letter. +% We need an \verb+\immediate+ definition to force the expansion +% so we can test using \verb+\if+. This test cannot be made inside +% \verb+\putletter+ because that macro may have been redefined +% when the lights are empty. % \begin{macrocode} - \csname\ther@w\thec@l\endcsname + \immediate\def\lett@r{\value Letter[\Down,\Across]} + \if \lett@r ! \put(\Across,-\Down){\rule{\unitlength}{\unitlength}} + \else \putletter \putnumber \putbars + \fi % \end{macrocode} % % Now we advance to the next column and iterate. That's the end of the @@ -1402,18 +1312,23 @@ % \end{macrocode} % % Now we can decrement down to the next row and iterate through the -% rows. +% rows. In the process, we encounter all the clue numbers in opposite +% order, therefore the last clue number found should be 1. % % \begin{macrocode} \advance\Down by \m@ne \repeat + \ifthenelse{\equal{\the\oldnumber}1}{} + {\ifnumberit\errhelp{Clues should be numbered consecutively + from top left to bottom right.} + \errmessage{First clue number is \the\oldnumber, not 1} \fi} % \end{macrocode} % % We've so far drawn a horizontal line {\em under\/} each of the rows; the % next \verb+\put+ draws a final line {\em above\/} the top-most row. % % \begin{macrocode} - \put(1,0){\line(1,0){\the\gr@dsize}} + \put(1,0){\line(1,0){\the\gridc@ls}} % \end{macrocode} % % Similarly, a short loop can draw vertical rules at the left-hand edge of @@ -1424,7 +1339,7 @@ % \begin{macrocode} \Across=\p@csize \loop\ifnum\Across>\z@ - \put(\Across,0){\line(0,-1){\the\gr@dsize}} + \put(\Across,0){\line(0,-1){\the\gridr@ws}} \advance\Across by \m@ne \repeat % \end{macrocode} @@ -1440,12 +1355,20 @@ % \end{macro} % % +% +% \section{A hard crossword with blocks and bars} +% \begin{crossword}[11]{13}{N} +% \MakePercentComment \input{grid2} \MakePercentIgnore +% \end{crossword} + + +% \section{Sample input files} % Finally, here's the input which produced the crossword in -% figure~\ref{crossword:1} +% Figure~\ref{crossword:1} % % \begin{verbatim} % \begin{crossword}{15}{N} -% \input{grid-1} +% \input{grid1} % \end{crossword} % \end{verbatim} % @@ -1574,7 +1497,6 @@ %</exa0> % \end{macrocode} % -% % % \begin{macrocode} %<*exa1> @@ -1586,7 +1508,7 @@ \begin{document} \section*{A Sample Crossword} \textit{(Chamber's Twentieth Century dictionary)} - \begin{crossword}{15}{?} + \begin{crossword}{15}{N} \input{grid1} \end{crossword} \begin{crossword*}{15}{Solution to grid 0} @@ -1595,8 +1517,80 @@ \end{document} %</exa1> % \end{macrocode} -% + % % \Finale -% +% \endinput + + +%<*exa2> +\documentclass[a4paper]{article} +\usepackage{a4wide,charter,crosswrd} +\topmargin -20mm +\textheight 240mm +\begin{document} + \thispagestyle{empty} + \begin{crossword}[11]{13}{N} + \input grid2 + \end{crossword} +\end{document} +%</exa2> +%<*grid2> + \unitlength 7mm + \let\numbersize\scriptsize + \centerline{\large{\textbf{T-shirt design} by Dirk Laurie}} + \def\Preamble{5 27, and that goes for 17 11 25 and 24A 10 too, +I'm sure, so the unclued lights should be entered in red. +The other lights are all +in the rather ancient edition of Chambers consulted by the composer.} +\clue{1}{A}{1}{1}{........}{Murderer's lip in an evil act}{8} +\clue{6}{A}{9}{1}{.....}{Places where vehicles without + resistance get bogged down?}{5} +\clue{10}{A}{2}{2}{..........}{}{} +\clue{12}{A}{1}{3}{....}{Perhaps 27 die here}{4} +\clue{14}{A}{5}{3}{.....}{Obstinate at first and after a smack}{5} +\clue{15}{A}{10}{3}{....}{Seduced girl, as rumoured}{4} +\clue{16}{A}{1}{5}{........}{Paid an unspecified amount in Johannesburg}{8} +\clue{17 \noexpand\& 11D \noexpand\& 25D}{A}{9}{5}{.....}{}{See preamble} +\clue{18}{A}{1}{6}{......}{Butt gives information in a peeve}{6,hyphenated} +\clue{20}{A}{8}{6}{......}{Big folk appearing in spots last month}{6} +\clue{24 \noexpand\& 10}{A}{1}{7}{.....}{}{See preamble} +\clue{26}{A}{6}{7}{........}{Wince after European has knocked back medicine, +leaving out some}{8} +\clue{30}{A}{1}{9}{....}{Recidivist is back, getting old in here}{4} +\clue{31}{A}{5}{9}{.....}{Unwilling to receive a small copper pot}{5} +\clue{32}{A}{10}{9}{....}{Primal wilderness beside a person from the East + ``is Paradise ---''}{4} +\clue{33}{A}{3}{10}{..........}{Denizen of Africa to suffer in the heat +when dose insects get in}{10} +\clue{34}{A}{1}{11}{.....}{Turn around at home and peek outside, like 18?}{5} +\clue{35}{A}{6}{11}{........}{Such as these two from the back going + ahead in copious lovemaking}{8} +\clue{1}{D}{1}{1}{......}{A disc full of French horn music}{6} +\clue{2}{D}{2}{1}{....}{Drams served up in Highland drizzle}{4} +\clue{3}{D}{4}{1}{......}{A gadfly with well-separated feet etc}{6,two words} +\clue{4}{D}{5}{1}{......}{Not many shooting up, in fact only one}{6} +\clue{5 \noexpand\& 27}{D}{7}{1}{.....}{}{See preamble,three words} +\clue{6}{D}{9}{1}{.....}{Tree that will, having had root extracted +at first, turn into mineral!}{5} +\clue{7}{D}{10}{1}{....}{Give me a response that I can hear: + it's no longer a crisis}{4} +\clue{8}{D}{12}{1}{......}{What unreformed head wears is right}{6} +\clue{9}{D}{13}{1}{.....}{Dirk's parrot, found in polar regions}{5} +\clue{11}{D}{11}{2}{........}{}{} +\clue{13}{D}{3}{3}{........}{Saying "Be with you shortly", lassie goes inside +house}{8} +\clue{19}{D}{2}{6}{......}{Invest ten rand judiciously}{6} +\clue{21}{D}{9}{6}{......}{Coin Dirk lost on the way up; Henry gets involved}{6} +\clue{22}{D}{10}{6}{......}{Peek!}{6} +\clue{23}{D}{13}{6}{......}{Neutral sounds and trite sayings arise all around Switzerland}{6} +\clue{24}{D}{1}{7}{.....}{Servants genteel at heart? One of them +is the butler at Blandings Castle!} +{5} +\clue{25}{D}{5}{7}{.....}{}{} +\clue{27}{D}{7}{7}{.....}{}{} +\clue{28}{D}{4}{8}{....}{Serving up only half a beer is a mistake}{4} +\clue{29}{D}{12}{8}{....}{Footplay before strong no-trump not allowed}{4} +%</grid2> +% diff --git a/Master/texmf-dist/source/latex/crosswrd/crosswrd.ins b/Master/texmf-dist/source/latex/crosswrd/crosswrd.ins index 01993bdf41a..49acbbf1bdb 100644 --- a/Master/texmf-dist/source/latex/crosswrd/crosswrd.ins +++ b/Master/texmf-dist/source/latex/crosswrd/crosswrd.ins @@ -1,44 +1,24 @@ -%% crosswrd.ins -%% Copyright 1989 Brian Hamilton Kelly -%% updated for LaTeX2e by Frank Mittelbach 96/12/06 -% -% This work may be distributed and/or modified under the -% conditions of the LaTeX Project Public License, either version 1.3 -% of this license or (at your option) any later version. -% The latest version of this license is in -% http://www.latex-project.org/lppl.txt -% and version 1.3 or later is part of all distributions of LaTeX -% version 2005/12/01 or later. -% -% This work has the LPPL maintenance status `unmaintained'. -% -% This work consists of the files crosswrd.dtx, crosswrd.ins and README -% and the derived files test0.tex, test1.tex, grid0.tex, grid1.tex and crosswrd.sty. -% + \def\batchfile{crosswrd.ins} \input docstrip.tex \preamble - -Copyright 1989 Brian Hamilton Kelly -updated for LaTeX2e by Frank Mittelbach 96/12/06 +Copyright C 1989 Brian Hamilton Kelly crossword macros for LaTeX +updated for LaTeX2e by Frank Mittelbach 96/12/06 +substantially extended by Dirk Laurie 08/01/18 for documentation run latex crosswrd.dtx -This work may be distributed and/or modified under the -conditions of the LaTeX Project Public License, either version 1.3 -of this license or (at your option) any later version. -The latest version of this license is in - http://www.latex-project.org/lppl.txt -and version 1.3 or later is part of all distributions of LaTeX -version 2005/12/01 or later. +distribution consist of -This work has the LPPL maintenance status `unmaintained'. + crosswrd.dtx source + crosswrd.ins installation script + 00readme -This work consists of the files crosswrd.dtx, crosswrd.ins and README -and the derived files test0.tex, test1.tex, grid0.tex, grid1.tex and crosswrd.sty. +don't distribute this file without distributing the above +files as well \endpreamble @@ -48,6 +28,8 @@ and the derived files test0.tex, test1.tex, grid0.tex, grid1.tex and crosswrd.st \file{crosswrd.sty}{\from{crosswrd.dtx}{package}} \file{test0.tex}{\from{crosswrd.dtx}{exa0}} \file{test1.tex}{\from{crosswrd.dtx}{exa1}} + \file{test2.tex}{\from{crosswrd.dtx}{exa2}} \file{grid0.tex}{\from{crosswrd.dtx}{grid0}} \file{grid1.tex}{\from{crosswrd.dtx}{grid1}} + \file{grid2.tex}{\from{crosswrd.dtx}{grid2}} } |