summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/cwpuzzle/cwpuzzle.sty
blob: bb2edc551b6f43f4737ed63b30023f293e241a99 (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
%%
%% This is file `cwpuzzle.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% cwpuzzle.dtx 
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% You are *not* allowed to modify this file.
%% 
%% You are *not* allowed to distribute this file.
%% For distribution of the original source see the terms
%% for copying and modification in the file cwpuzzle.dtx.
%% 
%%^^A $Id: cwpuzzle.dtx,v 1.4 1996/11/25 21:20:35 gerd Exp gerd $
\def\DTK@RCS$#1: #2 #3${#2}
\def\filename{cwpuzzle.dtx}
\xdef\fileversion{\DTK@RCS$Revision: 1.4 $}
\xdef\filedate{\DTK@RCS$Date: 1996/11/25 21:20:35 $}
\let\docversion=\fileversion
\let\docdate=\filedate
\typeout{%
%% Purpose:
        Package: cwpuzzle \filedate\space\fileversion\space
        for typesetting crossword puzzles.
}%
%%
%% Documentation:
%%      The documentation  can be generated   from the original  file
%%      cwpuzzle.dtx  with  the  doc  style/package.   LaTeX the file
%% cwpuzzle.dtx to get the full documentation in dvi format.
%%
%%
%% Author: Gerd Neugebauer
%%         Mainzer Str. 8
%%         56321 Rhens
%% Mail:   gerd@informatik.uni-koblenz.de
%%
%% Copyright (C) 1996 Gerd Neugebauer
%%
%%  cwpuzzle.dtx  is distributed in  the hope that  it will be useful,
%%  but  WITHOUT  ANY WARRANTY.    No  author or  distributor  accepts
%%  responsibility to  anyone for the  consequences of using it or for
%%  whether  it serves any particular purpose  or works at all, unless
%%  he says so in writing.
%%
%%  Everyone  is granted permission  to copy,  modify and redistribute
%%  dtk.dtx,  provided this  copyright  notice  is preserved  and  any
%%  modifications are indicated.
%%
%%
%%  This style is still under development and  may be replaced with a
%%  new version which provides an enhanced functionality.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\ProvidesPackage{cwpuzzle}[\filedate gene]
\newdimen\PuzzleUnitlength
\PuzzleUnitlength=20pt
\newcommand\PuzzleClueFont{\footnotesize}
\newcommand\PuzzleFont{\rm\normalsize}
\newcommand\PuzzleNumberFont{\sf\scriptsize}
\let\PuzzleHook=\relax
\newcount\Puzzle@X
\newcount\Puzzle@Y
\begingroup
\catcode`\|=13
\gdef\Puzzle@@solution{
  \let|=\Puzzle@Box@@solution
  \let\Frame=\Puzzle@Frame@@solution
}
\gdef\Puzzle@@normal{
  \let|=\Puzzle@Box@@normal
  \let\Frame=\Puzzle@Frame@@normal
}
\endgroup
\newenvironment{Puzzle}[2]{\par\noindent\mbox{}\hfill
  \catcode`\|=13
  \@nameuse{Puzzle@@\Puzzle@TYPE}%
  \unitlength=\PuzzleUnitlength
  \Puzzle@Y=#2
  \begin{picture}(#1,#2)
    \Puzzle@Box@@normal.
}{%
    \PuzzleHook
  \end{picture}\hfill\null\par\noindent
}
\newcommand\Puzzle@Frame@@normal[5]{\put(#1,#2){\framebox(#3,#4){%
      \begin{minipage}{#3\unitlength}\begin{center} #5
      \end{center}\end{minipage}}}}
\newcommand\Puzzle@Frame@@solution[5]{}
\newcommand\PuzzleBlackBox{\rule{\PuzzleUnitlength}{\PuzzleUnitlength}}
\newcommand\Puzzle@Box@@normal[2][]{%
  \def\Puzzle@tmp{#2}%
  \if\Puzzle@tmp.
    \Puzzle@X=0\relax \advance\Puzzle@Y-1
  \else
    \ifx\@empty\Puzzle@tmp
    \else
    \if\Puzzle@tmp*
    \put(\Puzzle@X,\Puzzle@Y){\framebox(1,1){\PuzzleBlackBox}}
    \else
    \put(\Puzzle@X,\Puzzle@Y){\framebox(1,1){}}
    \fi
    \fi
    \def\Puzzle@tmp{#1}%
    \ifx\@empty\Puzzle@tmp\else
      \put(\Puzzle@X,\Puzzle@Y){%
        \makebox(1,.95)[tl]{\PuzzleNumberFont\,#1}}%
    \fi
    \advance\Puzzle@X 1
  \fi
}
\newcommand\Puzzle@Box@@solution[2][]{%
  \def\Puzzle@tmp{#2}%
  \if\Puzzle@tmp.
    \Puzzle@X=0\relax \advance\Puzzle@Y-1
  \else
    \ifx\Puzzle@tmp\@empty
    \else\if\Puzzle@tmp*
    \put(\Puzzle@X,\Puzzle@Y){\framebox(1,1){\PuzzleBlackBox}}
    \else
    \put(\Puzzle@X,\Puzzle@Y){\framebox(1,1){\uppercase{#2}}}%
    \fi
    \fi
    \def\Puzzle@tmp{#1}%
    \ifx\Puzzle@tmp\@empty\else
      \ifPuzzle@SolutionNumbered
      \put(\Puzzle@X,\Puzzle@Y){%
        \makebox(1,.95)[tl]{\PuzzleNumberFont\,#1}}%
    \fi
    \fi
    \advance\Puzzle@X 1
  \fi
}
\newcommand\Puzzle@Clue@@normal[3]{\textsf{#1} #3 }
\newcommand\Puzzle@Clue@@solution[3]{}
\newenvironment{Puzzle@Clues@@normal}[1]{%
  \null\hfill
  \let\Clue\Puzzle@Clue@@normal
  \begin{minipage}[t]{.45\textwidth}%
    \PuzzleClueFont{#1}%
}{\end{minipage}\hfill\null }
\newenvironment{Puzzle@Clues@@solution}[1]{%
  \let\Clue\Puzzle@Clue@@solution
}{}
\newcommand\PuzzleWordsText[1]{Words of length #1: }
\newenvironment{Puzzle@Words@@normal}[1]{%
  \PuzzleWordsText{#1}%
  \let\Word\relax
}{\par}
\newenvironment{Puzzle@Words@@solution}[1]{%
  \newcommand\Word[1]{}%
}{}
\newcommand\PuzzleNumbers[1]{\begingroup
  \@nameuse{Puzzle@@\Puzzle@TYPE}%
  \Puzzle@Y=0
  \Puzzle@X=1
  \unitlength=\PuzzleUnitlength
  \Puzzle@Numbers#1.\endgroup}
\begingroup
\catcode`\|=13
\gdef\Puzzle@Numbers#1{%
  \if#1.
    \let\next\relax
  \else
    \begin{picture}(1,1)
      \xdef\X{\the\Puzzle@X}%
      \Puzzle@X=0
      |[\X]{#1}%
    \end{picture}%
    \let\next\Puzzle@Numbers
    \advance\Puzzle@X 1
  \fi
  \next
}
\endgroup
\newcommand\PuzzleLettersText{The following letters are used: }
\newcommand\PuzzleLetters[1]{\PuzzleLettersText #1\par}
\newcommand\Puzzle@TYPE{normal}
\newcommand\PuzzleSolution[1][false]{%
  \@nameuse{Puzzle@SolutionNumbered#1}%
  \let\PuzzleClues\Puzzle@Clues@@solution
  \let\endPuzzleClues\endPuzzle@Clues@@solution
  \let\PuzzleWords\Puzzle@Words@@solution
  \let\endPuzzleWords\endPuzzle@Words@@solution
  \xdef\Puzzle@TYPE{solution}}
\newcommand\PuzzleUnsolved{%
  \let\PuzzleClues\Puzzle@Clues@@normal
  \let\endPuzzleClues\endPuzzle@Clues@@normal
  \let\PuzzleWords\Puzzle@Words@@normal
  \let\endPuzzleWords\endPuzzle@Words@@normal
  \xdef\Puzzle@TYPE{normal}}
\newif\ifPuzzle@SolutionNumbered
\Puzzle@SolutionNumberedfalse
\PuzzleUnsolved
\endinput
%%
%% End of file `cwpuzzle.sty'.