| 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 |
\def\filename{cwpuzzle.dtx} |
| 3 |
\def\fileversion{1.17} |
| 4 |
\def\filedate{2026/05/20} |
| 5 |
\let\docversion=\fileversion |
| 6 |
\let\docdate=\filedate |
| 7 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8 |
%\iffalse |
| 9 |
\typeout{% |
| 10 |
%% Purpose: |
| 11 |
Package: cwpuzzle \filedate\space\fileversion\space |
| 12 |
for typesetting crossword puzzles and more. |
| 13 |
}% |
| 14 |
%% |
| 15 |
%% Documentation: |
| 16 |
%% The documentation can be generated from the original file |
| 17 |
%% cwpuzzle.dtx with the doc style/package. LaTeX the file |
| 18 |
%% cwpuzzle.dtx to get the full documentation in dvi format. |
| 19 |
%% |
| 20 |
%% |
| 21 |
%% Author: Gerd Neugebauer |
| 22 |
%% Brechklinge 10 |
| 23 |
%% 69256 Mauer (Germany) |
| 24 |
%% Mail: [email protected] |
| 25 |
%% |
| 26 |
%% Copyright (c) 1995-2026 Gerd Neugebauer |
| 27 |
%% |
| 28 |
%% cwpuzzle.dtx is distributed in the hope that it will be useful, |
| 29 |
%% but WITHOUT ANY WARRANTY. No author or distributor accepts |
| 30 |
%% responsibility to anyone for the consequences of using it or for |
| 31 |
%% whether it serves any particular purpose or works at all, unless |
| 32 |
%% he says so in writing. |
| 33 |
%% |
| 34 |
%% Everyone is granted permission to copy, modify and redistribute |
| 35 |
%% cwpuzzle.dtx, provided this copyright notice is preserved and |
| 36 |
%% any modifications are indicated. |
| 37 |
%% |
| 38 |
%<*driver> |
| 39 |
\documentclass{ltxdoc} |
| 40 |
\usepackage{xcolor} |
| 41 |
\usepackage{cwpuzzle} |
| 42 |
\EnableCrossrefs |
| 43 |
\CodelineIndex |
| 44 |
\RecordChanges |
| 45 |
\setcounter{IndexColumns}2 |
| 46 |
\begin{document} |
| 47 |
\DocInput{cwpuzzle.dtx} |
| 48 |
\newpage |
| 49 |
\PrintChanges |
| 50 |
\end{document} |
| 51 |
%</driver> |
| 52 |
%\fi |
| 53 |
% |
| 54 |
% \title{A \LaTeX\ Package for Typesetting\\ Crossword |
| 55 |
% Puzzles and More\thanks{This file documents \filename\ version |
| 56 |
% \fileversion\ as of \filedate.}} |
| 57 |
% \author{Gerd Neugebauer\\ |
| 58 |
% Brechklinge 10\\ |
| 59 |
% 69256 Mauer (Germany)\\ |
| 60 |
% Net: \texttt{[email protected]}} |
| 61 |
% |
| 62 |
% \date{{\footnotesize Documentation date: \docdate}} |
| 63 |
% |
| 64 |
% \maketitle |
| 65 |
% |
| 66 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 67 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 68 |
% |
| 69 |
% \DoNotIndex{\ ,\|,\",\',\.,\,,\[,\\,\],\^,\`,\~,\@,\@dottedtocline} |
| 70 |
% \DoNotIndex{\@empty,\@namedef,\@nameuse,\advance,\begin,\begingroup} |
| 71 |
% \DoNotIndex{\catcode,\csname,\def,\else,\end,\endcsname,\endgroup} |
| 72 |
% \DoNotIndex{\fi,\filedate,\footnotesize,\framebox,\gdef,\global} |
| 73 |
% \DoNotIndex{\hfill,\if,\ifx,\large,\let,\makebox,\mbox,\newcommand} |
| 74 |
% \DoNotIndex{\newcount,\newdimen,\newenvironment,\newif,\noindent} |
| 75 |
% \DoNotIndex{\normalsize,\null,\par,\put,\raggedright,\raggedleft} |
| 76 |
% \DoNotIndex{\relax,\renewcommand,\RequirePackage,\rm,\rmfamily,\rule} |
| 77 |
% \DoNotIndex{\scriptsize,\sf,\sffamily,\small,\textsf,\texttt,\textwidth} |
| 78 |
% \DoNotIndex{\the,\tiny,\unitlength,\uppercase,\xdef,\ProvidesPackage} |
| 79 |
% |
| 80 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 81 |
% |
| 82 |
% \changes{1.3}{1996/10/28}{First public release.} |
| 83 |
% \changes{1.16}{2026/04/29}{Typos in documentation fixed.} |
| 84 |
% \changes{1.17}{2026/05/20}{Repository moved.} |
| 85 |
% |
| 86 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 87 |
% \CheckSum{675} |
| 88 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 89 |
%% \CharacterTable |
| 90 |
%% {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 |
| 91 |
%% 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 |
| 92 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 93 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 94 |
%% Dollar \$ Percent \% Ampersand \& |
| 95 |
%% Acute accent \' Left paren \( Right paren \) |
| 96 |
%% Asterisk \* Plus \+ Comma \, |
| 97 |
%% Minus \- Point \. Solidus \/ |
| 98 |
%% Colon \: Semicolon \; Less than \< |
| 99 |
%% Equals \= Greater than \> Question mark \? |
| 100 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 101 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 102 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 103 |
%% Right brace \} Tilde \~} |
| 104 |
%% |
| 105 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 106 |
% \MakeShortVerb{|} |
| 107 |
% |
| 108 |
% \begin{abstract} |
| 109 |
% cwpuzzle.dtx provides a package to typeset crossword puzzles. |
| 110 |
% The leading philosophy is that the puzzle and the solution are |
| 111 |
% typeset from the same source. |
| 112 |
% |
| 113 |
% The package can be used to produce several types of puzzles like |
| 114 |
% the classical crossword puzzle, a number puzzle, and fill-in |
| 115 |
% puzzles. In addition to the block separated puzzles the thick |
| 116 |
% line delimited puzzles are supported as well. |
| 117 |
% \end{abstract} |
| 118 |
% |
| 119 |
% \newpage |
| 120 |
% \tableofcontents |
| 121 |
% \newpage |
| 122 |
% |
| 123 |
% \section{About Crossword Puzzles} |
| 124 |
% |
| 125 |
% Crossword puzzles are can be a an amusing but also a challenging |
| 126 |
% hobby. Unfortunately at the time of this writing I am not aware |
| 127 |
% of any good package to typeset crossword puzzles with \LaTeX. |
| 128 |
% Thus I decided to make one which at least fits my needs. |
| 129 |
% |
| 130 |
% There are several types of crossword puzzles among. This |
| 131 |
% package can only be used to typeset several of them. The basic |
| 132 |
% assumption in this package is that puzzles are rectangular |
| 133 |
% arrangements of boxes. Some of these boxes are black and others |
| 134 |
% are prepared to take single letters. |
| 135 |
% Each word in the grid is enclosed in black boxes or the outside. |
| 136 |
% |
| 137 |
% Optionally there may be rectangular regions left blank inside the |
| 138 |
% puzzle. They can be used to place ads or other informative texts |
| 139 |
% inside the puzzle. |
| 140 |
% |
| 141 |
% \subsection{Classical Crossword Puzzles}\label{sec:classical} |
| 142 |
% |
| 143 |
% \PuzzleUnsolved |
| 144 |
% \begin{minipage}{.35\textwidth}% |
| 145 |
% \begin{Puzzle}{5}{3}% |
| 146 |
% |* |* |[1]E|X |* |. |
| 147 |
% |[2]A|[3]S|T |* |[4]T|. |
| 148 |
% |* |[5]P|A |R |T |. |
| 149 |
% \end{Puzzle}% |
| 150 |
% \end{minipage}% |
| 151 |
% \begin{minipage}{.6\textwidth} |
| 152 |
% \begin{PuzzleClues}{Across}% |
| 153 |
% \Clue{1}{EX}{unit of measure}% |
| 154 |
% \Clue{2}{AST}{\(\ast\)}% |
| 155 |
% \Clue{5}{PART}{sectioning unit}% |
| 156 |
% \end{PuzzleClues}% |
| 157 |
% \begin{PuzzleClues}{Down}% |
| 158 |
% \Clue{1}{ETA}{\(\eta\)}% |
| 159 |
% \Clue{3}{SP}{unit of measure}% |
| 160 |
% \Clue{4}{TT}{non-proportional font}% |
| 161 |
% \end{PuzzleClues}% |
| 162 |
% \end{minipage}\medskip |
| 163 |
% |
| 164 |
% The ``classical'' type of a crossword puzzle words are marked |
| 165 |
% with numbers and each word is accompanied with a clue which |
| 166 |
% should help (or confuse) the reader. Those clues are listed after |
| 167 |
% the frame of the puzzle. |
| 168 |
% |
| 169 |
% \subsection{Number Crossword Puzzles}\label{sec:numbered} |
| 170 |
% |
| 171 |
% \begin{minipage}{.35\textwidth}% |
| 172 |
% \begin{Puzzle}{5}{3}% |
| 173 |
% |* |* |[6]E|[1]X|* |. |
| 174 |
% |[5]A|[2]S|[7]T|* |[7]T|. |
| 175 |
% |* |[4]P|[5]A|[3]R|[7]T|. |
| 176 |
% \end{Puzzle}% |
| 177 |
% \end{minipage}% |
| 178 |
% \begin{minipage}{.6\textwidth} |
| 179 |
% \PuzzleLetters{AEPRSTX}\medskip\par |
| 180 |
% \PuzzleNumbers{XSRPAET}% |
| 181 |
% \end{minipage}\medskip |
| 182 |
% |
| 183 |
% The ``number puzzle'' variant contains only numbers instead of |
| 184 |
% letters. Different numbers denote different letters. There are no |
| 185 |
% clues. The reader is assumed to find a complete list of letters |
| 186 |
% by filling appropriate words into the grid. Sometimes a word is |
| 187 |
% already entered into the grid to ease the start. |
| 188 |
% |
| 189 |
% \subsection{Fill-In Crossword Puzzles}\label{sec:fill-in} |
| 190 |
% |
| 191 |
% \begin{minipage}{.35\textwidth}% |
| 192 |
% \begin{Puzzle}{5}{3}% |
| 193 |
% |* |* |E |X |* |. |
| 194 |
% |A |S |T |* |T |. |
| 195 |
% |* |P |A |R |T |. |
| 196 |
% \end{Puzzle}% |
| 197 |
% \end{minipage}% |
| 198 |
% \begin{minipage}{.6\textwidth} |
| 199 |
% \begin{PuzzleWords}{2} |
| 200 |
% \Word{EX}% |
| 201 |
% \Word{SP}% |
| 202 |
% \Word{TT}% |
| 203 |
% \end{PuzzleWords}% |
| 204 |
% \begin{PuzzleWords}{3} |
| 205 |
% \Word{AST}% |
| 206 |
% \Word{ETA}% |
| 207 |
% \end{PuzzleWords}% |
| 208 |
% \begin{PuzzleWords}{4} |
| 209 |
% \Word{PART}% |
| 210 |
% \end{PuzzleWords}% |
| 211 |
% \end{minipage}\medskip |
| 212 |
% |
| 213 |
% The ``fill-in puzzle'' variant consists of a frame containing |
| 214 |
% only black and white boxes. Additionally a list of words is given |
| 215 |
% which have to be put into the frame until none is left and the |
| 216 |
% frame is completed. |
| 217 |
% |
| 218 |
% \subsection{Line delimited Crossword Puzzles}\label{sec:line-delimited} |
| 219 |
% |
| 220 |
% The crossword puzzles we have seen before had the property that |
| 221 |
% words are either delimited by the outer border or by a solid |
| 222 |
% block. In addition line delimited puzzles are common. In this |
| 223 |
% case a thicker line is drawn to indicate the end of a line.\medskip |
| 224 |
% |
| 225 |
% \noindent |
| 226 |
% \begin{minipage}{.35\textwidth}% |
| 227 |
% \begin{Puzzle}{5}{3}% |
| 228 |
% |[1] c |[2] c |[3][l]e |[4] x |[5] p |. |
| 229 |
% |[6] l | o |[][o]t |[7][l]m| u |. |
| 230 |
% | o |[][fl]s|[8][l]a | l |[][o]t |. |
| 231 |
% \end{Puzzle}% |
| 232 |
% \end{minipage}% |
| 233 |
% \begin{minipage}{.6\textwidth} |
| 234 |
% \begin{PuzzleClues}{Across}% |
| 235 |
% \Clue{1}{CC}{unit of measure}% |
| 236 |
% \Clue{3}{EXP}{math function}% |
| 237 |
% \Clue{6}{LOT}{list of tables}% |
| 238 |
% \Clue{7}{MU}{$\mu$}% |
| 239 |
% \Clue{8}{ALT}{key}% |
| 240 |
% \end{PuzzleClues}% |
| 241 |
% \begin{PuzzleClues}{Down}% |
| 242 |
% \Clue{1}{CLO}{class option}% |
| 243 |
% \Clue{2}{COS}{math function}% |
| 244 |
% \Clue{3}{ETA}{\(\eta\)}% |
| 245 |
% \Clue{4}{XML}{all in angle brackets}% |
| 246 |
% \Clue{5}{PUT}{\LaTeX\ place picture element}% |
| 247 |
% \end{PuzzleClues}% |
| 248 |
% \end{minipage} |
| 249 |
% |
| 250 |
% In the example above we can see another feature. This feature is |
| 251 |
% that two letters are circled. This can be used to indicate |
| 252 |
% letters for a solution word of the crossword puzzle. |
| 253 |
% |
| 254 |
% |
| 255 |
% \subsection{Solutions} |
| 256 |
% |
| 257 |
% \PuzzleSolution |
| 258 |
% \begin{minipage}{.35\textwidth}% |
| 259 |
% \begin{Puzzle}{5}{3}% |
| 260 |
% |* |* |[1]E|X |* |. |
| 261 |
% |[2]A|[3]S|T |* |[4]T|. |
| 262 |
% |* |[5]P|A |R |T |. |
| 263 |
% \end{Puzzle}% |
| 264 |
% \end{minipage}% |
| 265 |
% \begin{minipage}{.6\textwidth} |
| 266 |
% \end{minipage}\medskip |
| 267 |
% |
| 268 |
% Often it is not only desirable to typeset the unsolved crossword |
| 269 |
% puzzle but also the solution. This means that all the letters |
| 270 |
% have to be filled in. This should be possible with the same |
| 271 |
% source as the questions to avoid typos or redundancies leading to |
| 272 |
% additional work. |
| 273 |
% |
| 274 |
% Several variants of solutions come to mind. Primarily the |
| 275 |
% solution should show the letters and suppress any clues. One |
| 276 |
% major distinction is also whether or not the numbers of the words |
| 277 |
% should be shown in the solution as well.\medskip |
| 278 |
% |
| 279 |
% \noindent |
| 280 |
% \PuzzleSolution[true]% |
| 281 |
% \begin{minipage}{.35\textwidth}% |
| 282 |
% \begin{Puzzle}{5}{3}% |
| 283 |
% |* |* |[1]E|X |* |. |
| 284 |
% |[2]A|[3]S|T |* |[4]T|. |
| 285 |
% |* |[5]P|A |R |T |. |
| 286 |
% \end{Puzzle}% |
| 287 |
% \end{minipage}% |
| 288 |
% \begin{minipage}{.6\textwidth} |
| 289 |
% \end{minipage}% |
| 290 |
% \medskip |
| 291 |
% |
| 292 |
% Finally there are the lists of letters in numbered puzzles. In |
| 293 |
% the solution they will show the letters in them as well. |
| 294 |
% |
| 295 |
% \medskip |
| 296 |
% \noindent |
| 297 |
% \PuzzleSolution[false]% |
| 298 |
% \begin{minipage}{.35\textwidth}% |
| 299 |
% \begin{Puzzle}{5}{3}% |
| 300 |
% |* |* |[6]E|[1]X|* |. |
| 301 |
% |[5]A|[2]S|[7]T|* |[7]T|. |
| 302 |
% |* |[4]P|[5]A|[3]R|[7]T|. |
| 303 |
% \end{Puzzle}% |
| 304 |
% \end{minipage}% |
| 305 |
% \begin{minipage}{.6\textwidth} |
| 306 |
% \PuzzleLetters{AEPRSTX}\medskip\par |
| 307 |
% \PuzzleNumbers{XSRPAET}% |
| 308 |
% \end{minipage} |
| 309 |
% |
| 310 |
% |
| 311 |
% \section{Crossword Puzzles in \LaTeX} |
| 312 |
% |
| 313 |
% Now we want to typeset crossword puzzles with \LaTeX. The package |
| 314 |
% tries to simplify this task. A puzzle can be shown in two |
| 315 |
% modes. The first one is the puzzle mode. Here the appearance is |
| 316 |
% targeted towards a user who wants to solve the puzzle. Thus he |
| 317 |
% wants to see the unfilled cell field. |
| 318 |
% |
| 319 |
% The other mode is the solution mode. Here the user wants to see |
| 320 |
% the solution in order to compare that his filled puzzle is |
| 321 |
% correct or find correct parts of the puzzle that he didn't got. |
| 322 |
% |
| 323 |
% We can imagine that the creator wants to typeset the unfilled |
| 324 |
% puzzle on one side and the solution on the next side. To achieve |
| 325 |
% this it would be helpful to use the same source for both places |
| 326 |
% to avoid any potential differences. This can be done by placing |
| 327 |
% the puzzle in a separate file. |
| 328 |
% |
| 329 |
% |
| 330 |
% \subsection{Crossword Puzzles from Files} |
| 331 |
% |
| 332 |
% First let us consider the case that we put a puzzle in a |
| 333 |
% file. For example we might have a file |p-1234.tex| for the |
| 334 |
% puzzle. For out example this file contains an environment as |
| 335 |
% follows: |
| 336 |
% |
| 337 |
% \begin{verbatim} |
| 338 |
% \begin{Puzzle}{5}{3}% |
| 339 |
% |* |* |[1]E|X |* |. |
| 340 |
% |[2]A|[3]S|T |* |[4]T|. |
| 341 |
% |* |[5]P|A |R |T |. |
| 342 |
% \end{Puzzle} |
| 343 |
% \begin{PuzzleClues}{\textbf{Across: }}% |
| 344 |
% \Clue{2}{MID}{\(\mid\)}% |
| 345 |
% \Clue{4}{TIMES}{\(\times\)}% |
| 346 |
% \Clue{5}{NEG}{\(\neg\)}% |
| 347 |
% \end{PuzzleClues}% |
| 348 |
% \begin{PuzzleClues}{\textbf{Down: }}% |
| 349 |
% \Clue{1}{SIMEQ}{\(\simeq\)}% |
| 350 |
% \Clue{2}{MIN}{log-like function}% |
| 351 |
% \Clue{3}{DEG}{log-like function}% |
| 352 |
% \end{PuzzleClues}% |
| 353 |
% \end{verbatim} |
| 354 |
% |
| 355 |
% Here a crossword puzzle is defined. It contains empty cells and |
| 356 |
% cells with letters and cells with additional numbers to refer to |
| 357 |
% the clues. You are free to arrange the parts however you |
| 358 |
% want. Here the puzzle is above the clues. The clues are side by |
| 359 |
% side. |
| 360 |
% |
| 361 |
% You can also place the clues above the crossword puzzle. |
| 362 |
% With minipages and options you can place them even in other |
| 363 |
% constellations. |
| 364 |
% |
| 365 |
% In the main document we can now use this file twise -- one time |
| 366 |
% for the unsolved puzzle and one time for the puzzle solution: |
| 367 |
% |
| 368 |
% \begin{verbatim} |
| 369 |
% Lorem ipsum dolor sit... |
| 370 |
% |
| 371 |
% \PuzzleUnsolved |
| 372 |
% \input{p-1234.tex} |
| 373 |
% |
| 374 |
% \newpage |
| 375 |
% Lorem ipsum dolor sit amet, consectetur adipiscing elit,... |
| 376 |
% |
| 377 |
% \PuzzleSolution |
| 378 |
% \input{p-1234.tex}\end{verbatim} |
| 379 |
% |
| 380 |
% The macros |\PuzzleUnsolved| and |\PuzzleSolution| switch into the |
| 381 |
% respective mode. In the first mode the letters are not shown but |
| 382 |
% the clues are shown. In the second mode it is just vice versa. |
| 383 |
% |
| 384 |
% The same trick also works for the other puzzle types in the |
| 385 |
% |cwpuzzle| package. |
| 386 |
% |
| 387 |
% |
| 388 |
% \subsection{Layouting Crossword Puzzles} |
| 389 |
% |
| 390 |
% The various building blocks for crossword puzzles are provided as |
| 391 |
% macros or environments. Some of them have defaults. But most of |
| 392 |
% the layout is left to you. |
| 393 |
% |
| 394 |
% For instance the number puzzle from section~\ref{sec:numbered} is |
| 395 |
% produced with |
| 396 |
% \begin{verbatim} |
| 397 |
% \begin{minipage}{.35\textwidth}% |
| 398 |
% \begin{Puzzle}{5}{3}% |
| 399 |
% |* |* |[6]E|[1]X|* |. |
| 400 |
% |[5]A|[2]S|[7]T|* |[7]T|. |
| 401 |
% |* |[4]P|[5]A|[3]R|[7]T|. |
| 402 |
% \end{Puzzle}% |
| 403 |
% \end{minipage}% |
| 404 |
% \begin{minipage}{.6\textwidth} |
| 405 |
% \PuzzleLetters{AEPRSTX}\medskip\par |
| 406 |
% \PuzzleNumbers{XSRPAET}% |
| 407 |
% \end{minipage}\medskip\end{verbatim} |
| 408 |
% |
| 409 |
% As you can see the environment |Puzzle| and the macros |
| 410 |
% |\PuzzleLetters| and |\PuzzleNumbers| from the |cwpuzzle| package |
| 411 |
% are used. They are combined with minipages and paragraphs. |
| 412 |
% |
| 413 |
% |
| 414 |
% \section{Input for Crossword Puzzles} |
| 415 |
% |
| 416 |
% The package provides a large number of ways to configure the |
| 417 |
% behaviour. Those are mainly encapsulated in \TeX\ macros. |
| 418 |
% |
| 419 |
% Before we describe the various options we will have a |
| 420 |
% look at the basic environments and macros used to specified a |
| 421 |
% crossword puzzle. |
| 422 |
% |
| 423 |
% \DescribeEnv{Puzzle}% |
| 424 |
% This package provides the environment |Puzzle| which typesets the |
| 425 |
% frame of a crossword puzzle. This environment takes two |
| 426 |
% arguments. These arguments are the number of columns and the |
| 427 |
% number of the rows of the puzzle. This means that essentially |
| 428 |
% only rectangular puzzles can be typeset. |
| 429 |
% |
| 430 |
% The example from section~\ref{sec:classical} has been entered as |
| 431 |
% follows: |
| 432 |
% \begin{verbatim} |
| 433 |
% \begin{Puzzle}{5}{3}% |
| 434 |
% |* |* |[1]E|X |* |. |
| 435 |
% |[2]A|[3]S|T |* |[4]T|. |
| 436 |
% |* |[5]P|A |R |T |. |
| 437 |
% \end{Puzzle} |
| 438 |
% \end{verbatim} |
| 439 |
% In this example we can see that inside the |Puzzle| environment |
| 440 |
% there is one special character. This is the bar \verb/|/. This |
| 441 |
% bar is an active character in \TeX. Thus you can think of it |
| 442 |
% like a macro. |
| 443 |
% |
| 444 |
% The \verb/|/ macro takes three arguments. The first two arguments |
| 445 |
% are optional, i.e. enclosed in brackets if present. The first |
| 446 |
% optional argument denotes the number for numbered boxes. The |
| 447 |
% second optional argument specifies the formatting of the cell. |
| 448 |
% |
| 449 |
% The third argument is either empty |{}| or it consists of a |
| 450 |
% single character. This argument describes the action to be |
| 451 |
% performed. |
| 452 |
% |
| 453 |
% \begin{itemize} |
| 454 |
% \item If this argument is a letter then it is simply shown |
| 455 |
% in the solution and suppressed in the unsolved crossword puzzle. |
| 456 |
% |
| 457 |
% \item If this argument is an asterisk |*| then a black box is |
| 458 |
% produced. |
| 459 |
% |
| 460 |
% \item If this argument is a dot |.| then this marks the end of |
| 461 |
% the current row. The next box is typeset at the beginning of the |
| 462 |
% following row. |
| 463 |
% |
| 464 |
% \item If this argument is empty |{}| then a white box is |
| 465 |
% typeset. This box does not contain a letter, nor does it have a |
| 466 |
% frame. This macro can be used to leave room for larger boxed with |
| 467 |
% ads. Alternatively this can be used to disable certain boxes to |
| 468 |
% make a non-rectangular crossword puzzle. |
| 469 |
% \end{itemize} |
| 470 |
% |
| 471 |
% \begin{verbatim} |
| 472 |
% \begin{Puzzle}{5}{5} |
| 473 |
% |{} |{} |[1]S|. |
| 474 |
% |{} |[2]M|I |[3]D|. |
| 475 |
% |[4]T|I |M |E |S |. |
| 476 |
% |{} |[5]N|E |G |. |
| 477 |
% |{} |{} |Q |. |
| 478 |
% \end{Puzzle} |
| 479 |
% \end{verbatim} |
| 480 |
% \PuzzleUnsolved |
| 481 |
% \begin{minipage}{.35\textwidth}% |
| 482 |
% \begin{Puzzle}{5}{5}% |
| 483 |
% |{} |{} |[1]S|. |
| 484 |
% |{} |[2]M|I |[3]D|. |
| 485 |
% |[4]T|I |M |E |S |. |
| 486 |
% |{} |[5]N|E |G |. |
| 487 |
% |{} |{} |Q |. |
| 488 |
% \end{Puzzle}% |
| 489 |
% \end{minipage}% |
| 490 |
% \begin{minipage}{.6\textwidth} |
| 491 |
% \begin{PuzzleClues}{\textbf{Across: }}% |
| 492 |
% \Clue{2}{MID}{\(\mid\)}% |
| 493 |
% \Clue{4}{TIMES}{\(\times\)}% |
| 494 |
% \Clue{5}{NEG}{\(\neg\)}% |
| 495 |
% \end{PuzzleClues}% |
| 496 |
% \begin{PuzzleClues}{\textbf{Down: }}% |
| 497 |
% \Clue{1}{SIMEQ}{\(\simeq\)}% |
| 498 |
% \Clue{2}{MIN}{log-like function}% |
| 499 |
% \Clue{3}{DEG}{log-like function}% |
| 500 |
% \end{PuzzleClues}% |
| 501 |
% \end{minipage}% |
| 502 |
% |
| 503 |
% Note that white-space is ignored after the arguments but not |
| 504 |
% between the bar and the arguments. |
| 505 |
% \bigskip |
| 506 |
% |
| 507 |
% The formatting of the cell is controlled by the second optional |
| 508 |
% argument of the \verb/|/ macro. This optional argument may |
| 509 |
% contain a list of several characters. Each of these characters is |
| 510 |
% interpreted from left to right. The following list describes the |
| 511 |
% meaning of the built-in characters.\medskip |
| 512 |
% |
| 513 |
% \PuzzleUnsolved |
| 514 |
% \newenvironment{CellLetter}[1]{\par\noindent |
| 515 |
% \begin{minipage}{.25\textwidth} |
| 516 |
% \let\PuzzlePre\relax |
| 517 |
% \let\PuzzlePost\relax |
| 518 |
% \begin{Puzzle}{1}{1}|[8][#1]X |
| 519 |
% \end{Puzzle}\tt\quad |
| 520 |
% \char`\|[8][#1]X |
| 521 |
% \end{minipage}% |
| 522 |
% \begin{minipage}{.7\textwidth} |
| 523 |
% }{\end{minipage}\smallskip}% |
| 524 |
% \begin{CellLetter}{f} |
| 525 |
% The letter f produces a simple frame around the cell. This is |
| 526 |
% the default if nothing is specified. |
| 527 |
% \end{CellLetter}% |
| 528 |
% \begin{CellLetter}{.} |
| 529 |
% The character . produces no additional rendering. It can be used |
| 530 |
% to overwrite the default rendering which is to place a frame |
| 531 |
% around the cell. |
| 532 |
% \end{CellLetter}% |
| 533 |
% \begin{CellLetter}{*} |
| 534 |
% The character * produces a black box. This is the same effect |
| 535 |
% which can be achieved by providing the character * to be filled |
| 536 |
% into the cell for the solution. |
| 537 |
% \end{CellLetter}% |
| 538 |
% \begin{CellLetter}{O} |
| 539 |
% The letter O produces an oval which is drawn with the \LaTeX\ macro |
| 540 |
% \verb/\oval/. |
| 541 |
% \end{CellLetter}% |
| 542 |
% \begin{CellLetter}{o} |
| 543 |
% The letter o produces an oval inside a frame. This is is an |
| 544 |
% abbreviation for the two letters fO. |
| 545 |
% \end{CellLetter}% |
| 546 |
% \begin{CellLetter}{t} |
| 547 |
% The letter t produces a frame with a thicker line at the top. |
| 548 |
% The thickness of this line is controlled by the macro |
| 549 |
% |\PuzzleThickline|. |
| 550 |
% \end{CellLetter}% |
| 551 |
% \begin{CellLetter}{T} |
| 552 |
% The letter T produces a thicker line at the top of the cell. |
| 553 |
% The thickness of this line is controlled by the macro |
| 554 |
% |\PuzzleThickline|. |
| 555 |
% \end{CellLetter}% |
| 556 |
% \begin{CellLetter}{b} |
| 557 |
% The letter b produces a frame with a thicker line at the bottom. |
| 558 |
% The thickness of this line is controlled by the macro |
| 559 |
% |\PuzzleThickline|. |
| 560 |
% \end{CellLetter}% |
| 561 |
% \begin{CellLetter}{B} |
| 562 |
% The letter B produces a thicker line at the bottom of the cell. |
| 563 |
% The thickness of this line is controlled by the macro |
| 564 |
% |\PuzzleThickline|. |
| 565 |
% \end{CellLetter}% |
| 566 |
% \begin{CellLetter}{l} |
| 567 |
% The letter l produces a frame with a thicker line at the left |
| 568 |
% side of the cell. The thickness of this line is controlled by |
| 569 |
% the macro |\PuzzleThickline|. |
| 570 |
% \end{CellLetter}% |
| 571 |
% \begin{CellLetter}{L} |
| 572 |
% The letter L produces a thicker line at the left side of the |
| 573 |
% cell. The thickness of this line is controlled by the macro |
| 574 |
% |\PuzzleThickline|. |
| 575 |
% \end{CellLetter}% |
| 576 |
% \begin{CellLetter}{r} |
| 577 |
% The letter r produces a frame with a thicker line at the right |
| 578 |
% side of the cell. The thickness of this line is controlled by |
| 579 |
% the macro |\PuzzleThickline|. |
| 580 |
% \end{CellLetter}% |
| 581 |
% \begin{CellLetter}{R} |
| 582 |
% The letter R produces a thicker line at the right side of the |
| 583 |
% cell. The thickness of this line is controlled by the macro |
| 584 |
% |\PuzzleThickline|. |
| 585 |
% \end{CellLetter}% |
| 586 |
% \begin{CellLetter}{/} |
| 587 |
% The character / produces a line crossing the cell from lower |
| 588 |
% left to upper right. |
| 589 |
% \end{CellLetter}% |
| 590 |
% \begin{CellLetter}{,} |
| 591 |
% The character , produces a line crossing the cell from upper |
| 592 |
% left to lower right. |
| 593 |
% \end{CellLetter}% |
| 594 |
% \begin{CellLetter}{S} |
| 595 |
% The character S produces the solution, i.e. the content of the |
| 596 |
% cell is typeset. No decorations are placed around. For this |
| 597 |
% purpose it should be combined with some other formatting |
| 598 |
% characters. |
| 599 |
% \end{CellLetter}% |
| 600 |
% |
| 601 |
% Whenever you try to use an undefined specification for the cell |
| 602 |
% frame a warning is printed and the letter is ignored. |
| 603 |
% |
| 604 |
% \DescribeMacro{\PuzzleDefineCell} |
| 605 |
% You can define additional cell renderings of your own. For this |
| 606 |
% purpose the macro |\PuzzleDefineCell| is provided. It takes two |
| 607 |
% arguments. The first argument contains the key under which the |
| 608 |
% rendering should be addressed in the optional second argument of |
| 609 |
% the macro \verb/|/. The second argument contains the replacement |
| 610 |
% text like in |\newcommand|. This replacement text can make use of |
| 611 |
% two arguments. They are addressed with |#1| and |#2|. The first |
| 612 |
% one contains the x coordinate of the cell to be rendered. The |
| 613 |
% second one its y coordinate. |
| 614 |
% |
| 615 |
% The following example shows for instance the definition of a new |
| 616 |
% cell type addressed by the key + which draws a thick frame around |
| 617 |
% the cell. |
| 618 |
% \begin{verbatim} |
| 619 |
% \PuzzleDefineCell{+}{ |
| 620 |
% \PuzzleThicklines |
| 621 |
% \put(#1,#2){\framebox(1,1){}} |
| 622 |
% } |
| 623 |
% \end{verbatim} |
| 624 |
% |
| 625 |
% |
| 626 |
% Finally we show how to define a cell type consisting of a colored |
| 627 |
% box. The box itself is drawn with the help of the macro |
| 628 |
% |\colorbox|. Thus it is necessary to load the package |
| 629 |
% \texttt{color} which defines this macro. |
| 630 |
% |
| 631 |
% The two invocations show the combination with the f specifier. |
| 632 |
% The specifier f is the default and used only if the user does not |
| 633 |
% provide the optional argument. Thus we need to provide the f if |
| 634 |
% we want to have it additionally.\medskip |
| 635 |
% |
| 636 |
% \noindent |
| 637 |
% \begin{minipage}{.65\textwidth}\small |
| 638 |
% \begin{verbatim} |
| 639 |
% \definecolor{gray}{gray}{.9} |
| 640 |
% \PuzzleDefineCell{c}{{% |
| 641 |
% \put(#1,#2){\makebox(1,1){% |
| 642 |
% \fboxsep=0pt |
| 643 |
% \colorbox{gray}{\makebox(1,1){}}}} |
| 644 |
% }} |
| 645 |
% \begin{Puzzle}{2}{2} |
| 646 |
% |[1][cf]X | {} |. |
| 647 |
% |{} |[2][c]X |. |
| 648 |
% \end{Puzzle} |
| 649 |
% \end{verbatim} |
| 650 |
% \end{minipage}\hfill |
| 651 |
% \begin{minipage}{.30\textwidth} |
| 652 |
% \definecolor{gray}{gray}{.9} |
| 653 |
% \PuzzleDefineCell{c}{{% |
| 654 |
% \fboxsep=0pt |
| 655 |
% \put(#1,#2){\makebox(1,1){\colorbox{gray}{\makebox(1,1){}}}} |
| 656 |
% }} |
| 657 |
% \begin{Puzzle}{2}{2} |
| 658 |
% |[1][cf]X | {} |. |
| 659 |
% |{} |[2][c]X |. |
| 660 |
% \end{Puzzle} |
| 661 |
% \end{minipage} |
| 662 |
% |
| 663 |
% \DescribeMacro{\DefineColorCell} |
| 664 |
% The macro |\DefineColorCell| simplifies this task by |
| 665 |
% encapsulating the definition above. It has two arguments. The |
| 666 |
% first one is the key character and the second one is the name of |
| 667 |
% the color to use for the background.\medskip |
| 668 |
% |
| 669 |
% \noindent |
| 670 |
% \begin{minipage}{.65\textwidth}\small |
| 671 |
% \begin{verbatim} |
| 672 |
% \definecolor{gray}{gray}{.9} |
| 673 |
% \PuzzleDefineColorCell{c}{gray} |
| 674 |
% \begin{Puzzle}{2}{2} |
| 675 |
% |{} |[1][cf]X |. |
| 676 |
% |[2][c]X |{} |. |
| 677 |
% \end{Puzzle} |
| 678 |
% \end{verbatim} |
| 679 |
% \end{minipage}\hfill |
| 680 |
% \begin{minipage}{.30\textwidth} |
| 681 |
% \definecolor{gray}{gray}{.9} |
| 682 |
% \PuzzleDefineColorCell{c}{gray} |
| 683 |
% \begin{Puzzle}{2}{2} |
| 684 |
% |{} |[1][cf]X |. |
| 685 |
% |[2][c]X |{} |. |
| 686 |
% \end{Puzzle} |
| 687 |
% \end{minipage} |
| 688 |
% |
| 689 |
% \DescribeMacro{\Frame} |
| 690 |
% The macro |\Frame| can be used to typeset ads or other text into |
| 691 |
% larger boxes inside the frame of the crossword puzzle. For this |
| 692 |
% purpose five arguments are required. The first two arguments are |
| 693 |
% used to specify the lower left corner of the frame. The lower |
| 694 |
% left corner has the coordinates 0,0 and the numbers increase |
| 695 |
% upwards and to the right. |
| 696 |
% |
| 697 |
% The third argument is the width of the frame and the fourth |
| 698 |
% argument is the height of the frame measured in number of boxes. |
| 699 |
% Finally, the fifth argument contains the text to be typeset. Per |
| 700 |
% default it is typeset in a mini-page of the appropriate width |
| 701 |
% centered horizontally and vertically. |
| 702 |
% |
| 703 |
% \changes{1.10}{2020/05/23}{Font changing macros modernized} |
| 704 |
% \begin{verbatim} |
| 705 |
% \begin{Puzzle}{8}{6} |
| 706 |
% \Frame{2}{2}{4}{2}{\sffamily Crossword\\Puzzle} |
| 707 |
% |[1]E|* |[2]N |U |L |[3]L |* |[4]V|. |
| 708 |
% |[5]T|[6]R|I |A |N |G |[7]L|E |. |
| 709 |
% |A |U |{} |{} |{} |{} |[8]C|C |. |
| 710 |
% |* |L |{} |{} |{} |{} |E |* |. |
| 711 |
% |[9]B|E |T |[10]A|* |[11]L|I |M |. |
| 712 |
% |F |* |[12]L|A |B |E |L |* |. |
| 713 |
% \end{Puzzle} |
| 714 |
% \end{verbatim} |
| 715 |
% |
| 716 |
% \PuzzleUnsolved\noindent |
| 717 |
% \begin{minipage}{.5\textwidth}\PuzzleUnitlength=18pt |
| 718 |
% \begin{Puzzle}{8}{6}% |
| 719 |
% \Frame{2}{2}{4}{2}{\sffamily Crossword\\Puzzle}% |
| 720 |
% |[1]E|* |[2]N|U|L|[3]L|* |[4]V|. |
| 721 |
% |[5]T|[6]R|I|A|N|G|[7]L|E|. |
| 722 |
% |A|U|{}|{}|{}|{}|[8]C|C|. |
| 723 |
% |* |L|{}|{}|{}|{}|E|* |. |
| 724 |
% |[9]B|E|T|[10]A|* |[11]L|I|M|. |
| 725 |
% |F|* |[12]L|A|B|E|L|* |. |
| 726 |
% \end{Puzzle}% |
| 727 |
% \end{minipage}% |
| 728 |
% \begin{minipage}{.47\textwidth} |
| 729 |
% \begin{PuzzleClues}{\textbf{Across: }}% |
| 730 |
% \Clue{2}{NULL}{empty}% |
| 731 |
% \Clue{5}{TRIANGLE}{\(\triangle\)}% |
| 732 |
% \Clue{8}{CC}{carbon copy (letter.sty)}% |
| 733 |
% \Clue{9}{BETA}{\(\beta\)}% |
| 734 |
% \Clue{11}{LIM}{limes}% |
| 735 |
% \Clue{12}{LABEL}{mark it}% |
| 736 |
% \end{PuzzleClues}% |
| 737 |
% \begin{PuzzleClues}{\textbf{Down: }}% |
| 738 |
% \Clue{1}{ETA}{\(\eta\)}% |
| 739 |
% \Clue{2}{NI}{\(\ni\)}% |
| 740 |
% \Clue{3}{LG}{logarithm}% |
| 741 |
% \Clue{4}{VEC}{\(\vec{}\)}% |
| 742 |
% \Clue{6}{RULE}{black rectangle}% |
| 743 |
% \Clue{7}{LCEIL}{\(\lceil\)}% |
| 744 |
% \Clue{9}{BF}{bold face}% |
| 745 |
% \Clue{10}{AA}{\AA}% |
| 746 |
% \Clue{11}{LE}{\(\le\)}% |
| 747 |
% \end{PuzzleClues}% |
| 748 |
% \end{minipage}% |
| 749 |
% |
| 750 |
% \DescribeEnv{PuzzleClues} |
| 751 |
% The clues in the classical crossword puzzle are typeset with the |
| 752 |
% use of the environment |PuzzleClues|. This environment takes one |
| 753 |
% argument which is typeset before the clues. The environment takes |
| 754 |
% roughly the half of the text width and make a mini-page with this |
| 755 |
% width. Thus two invocations of this environment are typeset side |
| 756 |
% by side. |
| 757 |
% |
| 758 |
% Alternatively if the solution is typeset then the environment |
| 759 |
% |PuzzleClues| has no effect. |
| 760 |
% |
| 761 |
% \begin{verbatim} |
| 762 |
% \begin{PuzzleClues}{\textbf{Across}}% |
| 763 |
% \Clue{1}{EX}{unit of measure}% |
| 764 |
% \Clue{2}{AST}{\(\ast\)}% |
| 765 |
% \Clue{5}{PART}{sectioning unit}% |
| 766 |
% \end{PuzzleClues}% |
| 767 |
% \begin{PuzzleClues}{\textbf{Down}}% |
| 768 |
% \Clue{1}{ETA}{\(\eta\)}% |
| 769 |
% \Clue{3}{SP}{unit of measure}% |
| 770 |
% \Clue{4}{TT}{nonproportional font}% |
| 771 |
% \end{PuzzleClues}% |
| 772 |
% \end{verbatim} |
| 773 |
% |
| 774 |
% \DescribeMacro{\Clue} |
| 775 |
% The environment |PuzzleClues| defines one local macro. This macro |
| 776 |
% is named |\Clue| and takes three arguments. The first argument is |
| 777 |
% the number of the word. This should correspond to the number in |
| 778 |
% the puzzle frame. The second argument is the word itself. |
| 779 |
% Currently this is not used at all. Finally the third argument is the |
| 780 |
% clue for the word. |
| 781 |
% |
| 782 |
% If the unsolved puzzle is typeset then the first and the third |
| 783 |
% argument are used. Otherwise all arguments are silently absorbed. |
| 784 |
% |
| 785 |
% \DescribeMacro{\PuzzleLetters} |
| 786 |
% The macro |\PuzzleLetters| can be used to typeset the list of |
| 787 |
% used letters in numbered crossword puzzles. It has one argument |
| 788 |
% which are the used letters (preferably in alphabetical order). |
| 789 |
% |
| 790 |
% \DescribeMacro{\PuzzleNumbers} |
| 791 |
% The macro |\PuzzleNumbers| can be used to generate a numbered |
| 792 |
% list of boxes for the numbered crossword puzzles. The user is |
| 793 |
% supposed to collect the found letters here. |
| 794 |
% |
| 795 |
% \DescribeEnv{PuzzleWords} |
| 796 |
% The environment |PuzzleWords| can be used to typeset the list of |
| 797 |
% words for a fill-in puzzle. It takes one argument. This is the |
| 798 |
% length of the words listed. For each length there should be an |
| 799 |
% invocation of this environment. The words in this environment are |
| 800 |
% supposed to be ordered alphabetically. |
| 801 |
% |
| 802 |
% \DescribeMacro{\Word} |
| 803 |
% The macro |\Word| is defined inside the environment |
| 804 |
% |PuzzleWords|. It takes one argument which is the word itself. |
| 805 |
% |
| 806 |
% \begin{verbatim} |
| 807 |
% \begin{PuzzleWords}{2} |
| 808 |
% \Word{EX}% |
| 809 |
% \Word{SP}% |
| 810 |
% \Word{TT}% |
| 811 |
% \end{PuzzleWords}% |
| 812 |
% \begin{PuzzleWords}{3} |
| 813 |
% \Word{AST}% |
| 814 |
% \Word{ETA}% |
| 815 |
% \end{PuzzleWords}% |
| 816 |
% \begin{PuzzleWords}{4} |
| 817 |
% \Word{PART}% |
| 818 |
% \end{PuzzleWords}% |
| 819 |
% \end{verbatim} |
| 820 |
% |
| 821 |
% |
| 822 |
% \section{Other Grid-based Puzzles} |
| 823 |
% |
| 824 |
% In addition to the crossword puzzles other puzzles based on a |
| 825 |
% grid can also be typeset with this package. The basic principle |
| 826 |
% is the same. Just some minor simplifications have been provided. |
| 827 |
% |
| 828 |
% \subsection{Sudoku} |
| 829 |
% |
| 830 |
% A Sudoku is a puzzle on a $9\times9$ grid. It is filled with nine |
| 831 |
% numbers. Each number occurs only once in each row, each column |
| 832 |
% and each of the nine $3\times3$ boxes. Initially some of the |
| 833 |
% numbers are shown. The goal is to fill in all missing digits. |
| 834 |
% \medskip |
| 835 |
% |
| 836 |
% \begin{Sudoku} |
| 837 |
% | 7|*2| 4| 1| 3| 5| 6|*9| 8|. |
| 838 |
% |*3| 8|*1|*9| 7|*6|*5| 4|*2|. |
| 839 |
% | 9| 6| 5|*8| 2|*4| 1| 3| 7|. |
| 840 |
% | 2|*9| 6| 7| 1| 8| 3|*5| 4|. |
| 841 |
% |*5| 1| 8|*2| 4|*3| 9| 7|*6|. |
| 842 |
% | 4|*7| 3| 6| 5| 9| 8|*2| 1|. |
| 843 |
% | 6| 3| 9|*4| 8|*7| 2| 1| 5|. |
| 844 |
% |*8| 4|*2|*5| 9|*1|*7| 6|*3|. |
| 845 |
% | 1|*5| 7| 3| 6| 2| 4|*8| 9|. |
| 846 |
% \end{Sudoku} |
| 847 |
% |
| 848 |
% \DescribeEnv{Sudoku} |
| 849 |
% The input for a Sudoku is given in a specialized environment. |
| 850 |
% Since the size is fixed there is no need to specify a size. We |
| 851 |
% separate the cells with a pipe symbol and mark the end of a line |
| 852 |
% with a dot. To mark those cells containing the hints we preceed |
| 853 |
% the number with an asterisk. |
| 854 |
% |
| 855 |
% The Sudoku shown above is typeset from the following source: |
| 856 |
% |
| 857 |
% \begin{verbatim} |
| 858 |
% \begin{Sudoku} |
| 859 |
% | 7|*2| 4| 1| 3| 5| 6|*9| 8|. |
| 860 |
% |*3| 8|*1|*9| 7|*6|*5| 4|*2|. |
| 861 |
% | 9| 6| 5|*8| 2|*4| 1| 3| 7|. |
| 862 |
% | 2|*9| 6| 7| 1| 8| 3|*5| 4|. |
| 863 |
% |*5| 1| 8|*2| 4|*3| 9| 7|*6|. |
| 864 |
% | 4|*7| 3| 6| 5| 9| 8|*2| 1|. |
| 865 |
% | 6| 3| 9|*4| 8|*7| 2| 1| 5|. |
| 866 |
% |*8| 4|*2|*5| 9|*1|*7| 6|*3|. |
| 867 |
% | 1|*5| 7| 3| 6| 2| 4|*8| 9|. |
| 868 |
% \end{Sudoku} |
| 869 |
% \end{verbatim} |
| 870 |
% |
| 871 |
% As for crossword puzzles the macro |\PuzzleSolution| can be used |
| 872 |
% to switch to solution mode. Then all numbers are shown. The |
| 873 |
% parameters to modify the appearance of a puzzle work here as well. \medskip |
| 874 |
% |
| 875 |
% {\PuzzleSolution\PuzzleUnitlength=14pt\sffamily\footnotesize |
| 876 |
% \begin{Sudoku} |
| 877 |
% | 7|*2| 4| 1| 3| 5| 6|*9| 8|. |
| 878 |
% |*3| 8|*1|*9| 7|*6|*5| 4|*2|. |
| 879 |
% | 9| 6| 5|*8| 2|*4| 1| 3| 7|. |
| 880 |
% | 2|*9| 6| 7| 1| 8| 3|*5| 4|. |
| 881 |
% |*5| 1| 8|*2| 4|*3| 9| 7|*6|. |
| 882 |
% | 4|*7| 3| 6| 5| 9| 8|*2| 1|. |
| 883 |
% | 6| 3| 9|*4| 8|*7| 2| 1| 5|. |
| 884 |
% |*8| 4|*2|*5| 9|*1|*7| 6|*3|. |
| 885 |
% | 1|*5| 7| 3| 6| 2| 4|*8| 9|. |
| 886 |
% \end{Sudoku}} |
| 887 |
% |
| 888 |
% Since the characters in the solution are numbers only we can use |
| 889 |
% the following definition to colorize the cells in the solution. |
| 890 |
% |
| 891 |
% \begin{verbatim} |
| 892 |
% \def\PuzzleSolutionContent#1{\fboxsep=0pt |
| 893 |
% \def\myColor{}% |
| 894 |
% \ifcase#1 |
| 895 |
% \def\myColor{white}%0 |
| 896 |
% \or\def\myColor{red}%1 |
| 897 |
% \or\def\myColor{green}%2 |
| 898 |
% \or\def\myColor{yellow}%3 |
| 899 |
% \or\def\myColor{orange}%4 |
| 900 |
% \or\def\myColor{lime}%5 |
| 901 |
% \or\def\myColor{purple}%6 |
| 902 |
% \or\def\myColor{violet}%7 |
| 903 |
% \or\def\myColor{teal}%8 |
| 904 |
% \or\def\myColor{brown}%9 |
| 905 |
% \else\def\myColor{white}%* |
| 906 |
% \fi |
| 907 |
% \colorbox{\myColor}{\makebox(1,1){#1}}} |
| 908 |
% \end{verbatim} |
| 909 |
% |
| 910 |
% With the help of the package \textsf{xcolor} for the predefined |
| 911 |
% colors we get the following output: \medskip |
| 912 |
% |
| 913 |
% {\def\PuzzleSolutionContent#1{\fboxsep=0pt |
| 914 |
% \def\myColor{}\ifcase#1 |
| 915 |
% \def\myColor{white}\or\def\myColor{red}\or\def\myColor{green}\or\def\myColor{yellow}\or\def\myColor{orange}\or\def\myColor{lime}\or\def\myColor{purple}\or\def\myColor{violet}\or\def\myColor{teal}\or\def\myColor{brown}\else\def\myColor{white}\fi |
| 916 |
% \colorbox{\myColor}{\makebox(1,1){#1}}} |
| 917 |
% \PuzzleSolution\PuzzleUnitlength=14pt\sffamily\footnotesize |
| 918 |
% \begin{Sudoku} |
| 919 |
% | 7|*2| 4| 1| 3| 5| 6|*9| 8|. |
| 920 |
% |*3| 8|*1|*9| 7|*6|*5| 4|*2|. |
| 921 |
% | 9| 6| 5|*8| 2|*4| 1| 3| 7|. |
| 922 |
% | 2|*9| 6| 7| 1| 8| 3|*5| 4|. |
| 923 |
% |*5| 1| 8|*2| 4|*3| 9| 7|*6|. |
| 924 |
% | 4|*7| 3| 6| 5| 9| 8|*2| 1|. |
| 925 |
% | 6| 3| 9|*4| 8|*7| 2| 1| 5|. |
| 926 |
% |*8| 4|*2|*5| 9|*1|*7| 6|*3|. |
| 927 |
% | 1|*5| 7| 3| 6| 2| 4|*8| 9|. |
| 928 |
% \end{Sudoku}} |
| 929 |
% |
| 930 |
% Note that this definition has to be restricted to a local block |
| 931 |
% if you have solutions for other puzzle types in the same |
| 932 |
% document. |
| 933 |
% |
| 934 |
% |
| 935 |
% \subsection{Kakuro} |
| 936 |
% |
| 937 |
% In a Kakuro the cells are filled with digits. Each ``word'' |
| 938 |
% consists of different digits; i.e. a number can not be repeated |
| 939 |
% in a consecutive horizontal or vertical sequence of numbers. |
| 940 |
% |
| 941 |
% The hints for the ``words'' are the sums of the digits. |
| 942 |
% |
| 943 |
% \begin{Kakuro}{6}{9} |
| 944 |
% | - |<:13> |<:37> | - |<:41> |<:7> | - |. |
| 945 |
% |<4:> |* 3 | 1 |<14:> | 8 | 6 | - |. |
| 946 |
% |<13:> | 9 |* 7 |<3:20>| 2 | 1 | - |. |
| 947 |
% |<11:> | 1 | 2 | 3 | 5 | - | - |. |
| 948 |
% | - |<23:> | 6 |* 8 | 9 | - | - |. |
| 949 |
% | - |<29:3>| 8 | 9 | 7 | 5 | - |. |
| 950 |
% |<11:> | 2 | 9 |<6:> |* 4 | 2 | - |. |
| 951 |
% |<5:> |* 1 | 4 |<7:> | 6 | 1 | - |. |
| 952 |
% | - | - | - | - | - | - | - |. |
| 953 |
% \end{Kakuro} |
| 954 |
% |
| 955 |
% \DescribeEnv{Kakuro} |
| 956 |
% The input for a Kakuro is given in a specialized environment. It |
| 957 |
% takes the width and the height as arguments. |
| 958 |
% We separate the cells with a pipe symbol and mark the end of a line |
| 959 |
% with a dot. To mark those cells containing the initial digits we |
| 960 |
% preceed the digit with an asterisk. |
| 961 |
% |
| 962 |
% The hints are entered in angle brackets. They contain the |
| 963 |
% horizontal and vertical sums separated by a colon. The sums can |
| 964 |
% be empty if none should be typeset. |
| 965 |
% |
| 966 |
% The Kakuro shown above is typeset from the following source: |
| 967 |
% |
| 968 |
% \begin{verbatim} |
| 969 |
% \begin{Kakuro}{6}{9} |
| 970 |
% | - |<:13> |<:37> | - |<:41> |<:7> | - |. |
| 971 |
% |<4:> |* 3 | 1 |<14:> | 8 | 6 | - |. |
| 972 |
% |<13:> | 9 |* 7 |<3:20>| 2 | 1 | - |. |
| 973 |
% |<11:> | 1 | 2 | 3 | 5 | - | - |. |
| 974 |
% | - |<23:> | 6 |* 8 | 9 | - | - |. |
| 975 |
% | - |<29:3>| 8 | 9 | 7 | 5 | - |. |
| 976 |
% |<11:> | 2 | 9 |<6:> |* 4 | 2 | - |. |
| 977 |
% |<5:> | 1 | 4 |<7:> | 6 | 1 | - |. |
| 978 |
% | - | - | - | - | - | - | - |. |
| 979 |
% \end{Kakuro} |
| 980 |
% \end{verbatim} |
| 981 |
% |
| 982 |
% As for crossword puzzles the macro |\PuzzleSolution| can be used |
| 983 |
% to switch to solution mode. Then all numbers are shown. |
| 984 |
% |
| 985 |
% \begin{minipage}{.25\textwidth} |
| 986 |
% {\PuzzleSolution |
| 987 |
% \PuzzleUnitlength=14pt |
| 988 |
% \sffamily\footnotesize |
| 989 |
% \begin{Kakuro}{6}{9} |
| 990 |
% | - |<:13> |<:37> | - |<:41> |<:7> | - |. |
| 991 |
% |<4:> |* 3 | 1 |<14:> | 8 | 6 | - |. |
| 992 |
% |<13:> | 9 |* 7 |<3:20>| 2 | 1 | - |. |
| 993 |
% |<11:> | 1 | 2 | 3 | 5 | - | - |. |
| 994 |
% | - |<23:> | 6 |* 8 | 9 | - | - |. |
| 995 |
% | - |<29:3>| 8 | 9 | 7 | 5 | - |. |
| 996 |
% |<11:> | 2 | 9 |<6:> |* 4 | 2 | - |. |
| 997 |
% |<5:> | 1 | 4 |<7:> | 6 | 1 | - |. |
| 998 |
% | - | - | - | - | - | - | - |. |
| 999 |
% \end{Kakuro}} |
| 1000 |
% \end{minipage}\hfill |
| 1001 |
% \begin{minipage}{.7\textwidth}\footnotesize |
| 1002 |
% \begin{verbatim} |
| 1003 |
% \PuzzleSolution |
| 1004 |
% \PuzzleUnitlength=14pt |
| 1005 |
% \sffamily\footnotesize |
| 1006 |
% \begin{Kakuro}{6}{9} |
| 1007 |
% | - |<:13> |<:37>| - |<:41>|<:7> | - |. |
| 1008 |
% |<4:> |* 3 | 1 |<14:> | 8 | 6 | - |. |
| 1009 |
% |<13:>| 9 |* 7 |<3:20>| 2 | 1 | - |. |
| 1010 |
% |<11:>| 1 | 2 | 3 | 5 | - | - |. |
| 1011 |
% | - |<23:> | 6 |* 8 | 9 | - | - |. |
| 1012 |
% | - |<29:3>| 8 | 9 | 7 | 5 | - |. |
| 1013 |
% |<11:>| 2 | 9 |<6:> |* 4 | 2 | - |. |
| 1014 |
% |<5:> | 1 | 4 |<7:> | 6 | 1 | - |. |
| 1015 |
% | - | - | - | - | - | - | - |. |
| 1016 |
% \end{Kakuro} |
| 1017 |
% \end{verbatim} |
| 1018 |
% \end{minipage} |
| 1019 |
% |
| 1020 |
% |
| 1021 |
% \section{Parameters and Options} |
| 1022 |
% |
| 1023 |
% The package cwpuzzle can be controlled by a rich set of macros. |
| 1024 |
% In addition some settings can be performed with style options. The |
| 1025 |
% following style options are recognized: |
| 1026 |
% \begin{description} |
| 1027 |
% \item [numbered] |
| 1028 |
% The solution numbering is turned on. |
| 1029 |
% \item [nocenter] |
| 1030 |
% The puzzle is not typeset in a centered paragraph of its own. |
| 1031 |
% \item [unboxed] |
| 1032 |
% The clues are not enclosed in mini-pages and centered on the |
| 1033 |
% page. |
| 1034 |
% \item [normalsize] |
| 1035 |
% The puzzle is set in normalsize. This is the default. |
| 1036 |
% \item [small] |
| 1037 |
% The puzzle is set in small. The size of the cell and the font |
| 1038 |
% size of the solution are adjusted accordingly. |
| 1039 |
% \item [large] |
| 1040 |
% The puzzle is set in large. The size of the cell and the font |
| 1041 |
% size of the solution are adjusted accordingly. |
| 1042 |
% \item [huge] |
| 1043 |
% The puzzle is set in huge. The size of the cell and the font |
| 1044 |
% size of the solution are adjusted accordingly. |
| 1045 |
% \item [Huge] |
| 1046 |
% The puzzle is set in Huge. The size of the cell and the font |
| 1047 |
% size of the solution are adjusted accordingly. |
| 1048 |
% \item [german] |
| 1049 |
% \item [ngerman] |
| 1050 |
% The build in texts are switched to German variants. The |
| 1051 |
% defaults are English. This options is also in effect when given |
| 1052 |
% to the document class. The style inherits it from there. |
| 1053 |
% \item [french] |
| 1054 |
% The build in texts are switched to French variants. The |
| 1055 |
% defaults are English. This options is also in effect when given |
| 1056 |
% to the document class. The style inherits it from there. |
| 1057 |
% \end{description} |
| 1058 |
% |
| 1059 |
% The style options can be passed to the style in the usual way: |
| 1060 |
% \begin{verbatim} |
| 1061 |
% \usepackage[nocenter,unboxed,small]{cwpuzzle} |
| 1062 |
% \end{verbatim} |
| 1063 |
% |
| 1064 |
% The fine tuning can be achieved with the help of several macros. |
| 1065 |
% Those macros are described below. |
| 1066 |
% |
| 1067 |
% \DescribeMacro{\PuzzleUnitlength} |
| 1068 |
% The length |\PuzzleUnitlength| determines the width and height of |
| 1069 |
% each single box in the frame of a crossword puzzle. The default |
| 1070 |
% value is |20pt|. |
| 1071 |
% |
| 1072 |
% \DescribeMacro{\PuzzleBlackBox} |
| 1073 |
% The macro |\PuzzleBlackBox| contains the commands to produce the |
| 1074 |
% black boxes. It has to produce at most of width and height of |
| 1075 |
% |\PuzzleUnitlength|. Per default it just produces a black |
| 1076 |
% rectangle of this size. |
| 1077 |
% |
| 1078 |
% The following list shows some variants which can be achieved by |
| 1079 |
% redefining the macro |\PuzzleBlackBox|.\medskip |
| 1080 |
% |
| 1081 |
% \noindent |
| 1082 |
% \unitlength=\PuzzleUnitlength |
| 1083 |
% \framebox(1,1){\rule{.75\PuzzleUnitlength}{.75\PuzzleUnitlength}} |
| 1084 |
% \hfill |
| 1085 |
% \begin{minipage}{.9\textwidth} |
| 1086 |
% \begin{verbatim} |
| 1087 |
% \renewcommand{\PuzzleBlackBox}{\rule{.75\PuzzleUnitlength}% |
| 1088 |
% {.75\PuzzleUnitlength}} |
| 1089 |
% \end{verbatim} |
| 1090 |
% \end{minipage} |
| 1091 |
% |
| 1092 |
% \noindent |
| 1093 |
% \framebox(1,1){\framebox(.75,.75){\framebox(.5,.5){}}} |
| 1094 |
% \hfill |
| 1095 |
% \begin{minipage}{.9\textwidth} |
| 1096 |
% \begin{verbatim} |
| 1097 |
% \renewcommand{\PuzzleBlackBox}{\framebox(.75,.75){% |
| 1098 |
% \framebox(.5,.5){}}} |
| 1099 |
% \end{verbatim} |
| 1100 |
% \end{minipage} |
| 1101 |
% |
| 1102 |
% Additional effects can be achieved by using shades of gray (with |
| 1103 |
% the |graphics| package). |
| 1104 |
% |
| 1105 |
% \DescribeMacro{\PuzzleFont} |
| 1106 |
% The macro |\PuzzleFont| contains the font changing |
| 1107 |
% command issued before the frame of the crossword puzzle. |
| 1108 |
% |
| 1109 |
% \DescribeMacro{\PuzzleNumberFont} |
| 1110 |
% The macro |\PuzzleNumberFont| contains the font changing |
| 1111 |
% command issued before a number in the frame of the crossword |
| 1112 |
% puzzle is typeset. |
| 1113 |
% |
| 1114 |
% \DescribeMacro{\PuzzleClueFont} |
| 1115 |
% The macro |\PuzzleClueFont| contains the font changing |
| 1116 |
% command issued before the clues are typeset. |
| 1117 |
% |
| 1118 |
% \DescribeMacro{\PuzzleWordsText} |
| 1119 |
% The macro |\PuzzleWordsText| contains the text which is typeset |
| 1120 |
% at the beginning of the environment |PuzzleWords|. It has one |
| 1121 |
% argument which contains the length of the words listed. |
| 1122 |
% |
| 1123 |
% \DescribeMacro{\PuzzleLettersText} |
| 1124 |
% The macro |\PuzzleLettersText| contains the text which is typeset |
| 1125 |
% at the beginning of the macro |\PuzzleLetters|. |
| 1126 |
% |
| 1127 |
% \DescribeMacro{\PuzzleSolution} |
| 1128 |
% The macro |\PuzzleSolution| arranges everything such that the |
| 1129 |
% following puzzles are typeset in the ``solution'' mode, i.e. the |
| 1130 |
% letters are shown and the clues are suppressed. |
| 1131 |
% |
| 1132 |
% This macros has one optional argument which has to be |true| or |
| 1133 |
% |false|. This argument determines whether or not the numbers |
| 1134 |
% should also be shown in the solution. The default is |false| |
| 1135 |
% which means that the numbers are suppressed in the solution. |
| 1136 |
% |
| 1137 |
% \DescribeMacro{\PuzzleUnsolved} |
| 1138 |
% The macro |\PuzzleUnsolved| arranges everything such that the |
| 1139 |
% following puzzles are typeset in the ``unsolved'' mode, i.e. the |
| 1140 |
% letters are suppressed and the clues are shown. |
| 1141 |
% |
| 1142 |
% \DescribeMacro{\PuzzlePutNumber} |
| 1143 |
% The macro |\PuzzlePutNumber| is a configuration macro which |
| 1144 |
% typesets the number in a cell. The first argument is the x |
| 1145 |
% coordinate. The second argument is the y coordinate. The third |
| 1146 |
% argument is the number to be typeset. The coordinates are integer |
| 1147 |
% numbers. The coordinate (0,0) is the lower left corner. |
| 1148 |
% |
| 1149 |
% \DescribeMacro{\PuzzleHook} |
| 1150 |
% The macro |\PuzzleHook| is called at the end of the |Puzzle| |
| 1151 |
% environment. It can be used to place additional graphical |
| 1152 |
% elements in the puzzle frame. |
| 1153 |
% |
| 1154 |
% The following example shows a crossword puzzle which we have seen |
| 1155 |
% before and the definition for the |\PuzzleHook|.\medskip |
| 1156 |
% |
| 1157 |
% \PuzzleUnsolved |
| 1158 |
% \begin{minipage}{.35\textwidth}% |
| 1159 |
% \newcommand\PuzzleHook{% |
| 1160 |
% \put(0,2){\line(1,-1){2}} |
| 1161 |
% \put(0,3){\line(1,1){2}} |
| 1162 |
% \put(5,2){\line(-1,-1){2}} |
| 1163 |
% \put(5,3){\line(-1,1){2}} |
| 1164 |
% } |
| 1165 |
% \begin{Puzzle}{5}{5}% |
| 1166 |
% |{} |{} |[1]S|. |
| 1167 |
% |{} |[2]M|I |[3]D|. |
| 1168 |
% |[4]T|I |M |E |S |. |
| 1169 |
% |{} |[5]N|E |G |. |
| 1170 |
% |{} |{} |Q |. |
| 1171 |
% \end{Puzzle}% |
| 1172 |
% \end{minipage}% |
| 1173 |
% \begin{minipage}{.6\textwidth} |
| 1174 |
% \begin{verbatim} |
| 1175 |
% \newcommand\PuzzleHook{ |
| 1176 |
% \put(0,2){\line(1,-1){2}} |
| 1177 |
% \put(0,3){\line(1,1){2}} |
| 1178 |
% \put(5,2){\line(-1,-1){2}} |
| 1179 |
% \put(5,3){\line(-1,1){2}} |
| 1180 |
% } |
| 1181 |
% \end{verbatim} |
| 1182 |
% \end{minipage} |
| 1183 |
% |
| 1184 |
% \DescribeMacro{\PuzzleLineThickness} |
| 1185 |
% The macro |\PuzzleLineThickness| contains the width of the line |
| 1186 |
% used to frame the cells. |
| 1187 |
% |
| 1188 |
% \DescribeMacro{\PuzzlePre} |
| 1189 |
% This macro contains the code to be inserted before a puzzle is |
| 1190 |
% typeset. It is initialized to begin a new paragraph and center the |
| 1191 |
% puzzle. |
| 1192 |
% |
| 1193 |
% \DescribeMacro{\PuzzlePost} |
| 1194 |
% This macro contains the code to be inserted after a puzzle is |
| 1195 |
% typeset. It is initialized to end the paragraph and center the |
| 1196 |
% puzzle. |
| 1197 |
% |
| 1198 |
% \DescribeMacro{\PuzzleCluePre} |
| 1199 |
% This macro contains the code to be inserted before the clues are |
| 1200 |
% typeset in normal mode. It is initialized to center the puzzle clues. |
| 1201 |
% |
| 1202 |
% \DescribeMacro{\PuzzleCluePost} |
| 1203 |
% This macro contains the code to be inserted after the clues are |
| 1204 |
% typeset in normal mode. It is initialized to center the puzzle clues. |
| 1205 |
% |
| 1206 |
% \DescribeMacro{\PuzzleContent} |
| 1207 |
% This macro contains the content of a cell during formatting this |
| 1208 |
% cell. This enables the cell formating macro to access it. |
| 1209 |
% |
| 1210 |
% \DescribeMacro{\PuzzleSolutionContent} |
| 1211 |
% This macro processes the letter in solution mode. It takes one |
| 1212 |
% argument, the letter. This macro can be redefinied to achieve |
| 1213 |
% special effects for the solution. |
| 1214 |
% |
| 1215 |
% \DescribeMacro{\SudokuLinethickness} |
| 1216 |
% This macro contains the thickness of the thick lines in a sudoku. |
| 1217 |
% |
| 1218 |
% \DescribeMacro{\KakuroNumberFont} |
| 1219 |
% This macro contains the definition of the font switching macros |
| 1220 |
% used when typesetting a Kakuro hint. |
| 1221 |
% |
| 1222 |
% \DescribeMacro{\KakuroHintType} |
| 1223 |
% This macro contains the cell type used when typesetting a Kakuro |
| 1224 |
% hint. It can be used to redefine the appearance. |
| 1225 |
% |
| 1226 |
% |
| 1227 |
% |
| 1228 |
% \section{Further Plans} |
| 1229 |
% |
| 1230 |
% \subsection{General} |
| 1231 |
% |
| 1232 |
% Maybe I will add a mode for further variants of crossword puzzles |
| 1233 |
% sometimes. |
| 1234 |
% |
| 1235 |
% Maybe I can add support for further languages if someone provides |
| 1236 |
% the appropriate texts. Contributions are welcome. |
| 1237 |
% |
| 1238 |
% |
| 1239 |
% \subsection{The Related Program} |
| 1240 |
% |
| 1241 |
% There is a related program written in Perl/Tk. This program can be |
| 1242 |
% used to manually construct crossword puzzles and save them in a |
| 1243 |
% format suitable for this package. |
| 1244 |
% Other features include the creation of a proper frame and filling |
| 1245 |
% with words. |
| 1246 |
% |
| 1247 |
% Right now I have not prepared a distribution of this program yet |
| 1248 |
% since this program requires dictionaries which I can not |
| 1249 |
% distribute legally. |
| 1250 |
% |
| 1251 |
% The crossword examples in this documentation have been computed |
| 1252 |
% with the help of the |cwp| program. |
| 1253 |
% |
| 1254 |
% |
| 1255 |
% \StopEventually{} |
| 1256 |
% \newpage |
| 1257 |
% |
| 1258 |
% |
| 1259 |
% \section{The Implementation} |
| 1260 |
% |
| 1261 |
% The crossword puzzle is basically implemented with the \LaTeX{} |
| 1262 |
% picture environment. This gives us enough flexibility and |
| 1263 |
% provides an high enough abstraction such that we do not have to |
| 1264 |
% fiddle around with to many low level details. |
| 1265 |
% |
| 1266 |
% The natural unit in a crossword puzzle is a box which is empty |
| 1267 |
% or black. Thus the |unitlength| is set to the width (and height) |
| 1268 |
% of such a box. |
| 1269 |
% |
| 1270 |
% |
| 1271 |
% \subsection{Basic Definitions and Parameters} |
| 1272 |
% |
| 1273 |
% First we identify this package. |
| 1274 |
% |
| 1275 |
% \begin{macrocode} |
| 1276 |
\ProvidesPackage{cwpuzzle}[\filedate gene] |
| 1277 |
% \end{macrocode} |
| 1278 |
% Next we load the package amssymb needed for the triangles used |
| 1279 |
% in Kakuros. |
| 1280 |
% \begin{macrocode} |
| 1281 |
\RequirePackage{amssymb} |
| 1282 |
% \end{macrocode} |
| 1283 |
% |
| 1284 |
% The dimen register |\PuzzleUnitlength| stores the height and |
| 1285 |
% width of a box of the puzzle. The default is |20pt| which is |
| 1286 |
% also shown in this documentation. |
| 1287 |
% \begin{macrocode} |
| 1288 |
\newdimen\PuzzleUnitlength |
| 1289 |
\PuzzleUnitlength=20pt |
| 1290 |
% \end{macrocode} |
| 1291 |
% |
| 1292 |
% \begin{macro}{\PuzzleClueFont} |
| 1293 |
% |
| 1294 |
% The macro |\PuzzleClueFont| contains font changing |
| 1295 |
% commands issued before the clues are typeset. |
| 1296 |
% \begin{macrocode} |
| 1297 |
\newcommand\PuzzleClueFont{\footnotesize} |
| 1298 |
% \end{macrocode} |
| 1299 |
% \end{macro} |
| 1300 |
% |
| 1301 |
% \begin{macro}{\PuzzleFont} |
| 1302 |
% |
| 1303 |
% The macro |\PuzzleFont| contains font changing |
| 1304 |
% commands issued before the puzzle is typeset. |
| 1305 |
% \changes{1.10}{2020/05/23}{Font changing macros modernized} |
| 1306 |
% \begin{macrocode} |
| 1307 |
\newcommand\PuzzleFont{\rmfamily\normalsize} |
| 1308 |
% \end{macrocode} |
| 1309 |
% \end{macro} |
| 1310 |
% |
| 1311 |
% \begin{macro}{\PuzzleNumberFont} |
| 1312 |
% The macro |\PuzzleNumberFont| contains font changing |
| 1313 |
% commands issued before the numbers in a puzzle are typeset. |
| 1314 |
% \changes{1.10}{2020/05/23}{Font changing macros modernized} |
| 1315 |
% \begin{macrocode} |
| 1316 |
\newcommand\PuzzleNumberFont{\sffamily\scriptsize} |
| 1317 |
% \end{macrocode} |
| 1318 |
% \end{macro} |
| 1319 |
% |
| 1320 |
% \begin{macro}{\PuzzleHook} |
| 1321 |
% Puzzles are typeset with the \LaTeX{} picture environment. At the |
| 1322 |
% end of this environment the macro |\PuzzleHook| is |
| 1323 |
% called. The package produces an empty default. Users may want to |
| 1324 |
% use this place to typeset additional elements on top of the |
| 1325 |
% puzzle. |
| 1326 |
% |
| 1327 |
% The puzzle uses a |\unitlength| of |\PuzzleUnitlength|. Thus it |
| 1328 |
% is rather easy to address the boxes in the puzzle. |
| 1329 |
% |
| 1330 |
% \begin{macrocode} |
| 1331 |
\let\PuzzleHook=\relax |
| 1332 |
% \end{macrocode} |
| 1333 |
% \end{macro} |
| 1334 |
% |
| 1335 |
% \subsection{The Frame of the Crossword Puzzle} |
| 1336 |
% |
| 1337 |
% To describe the coordinates where the next box should be typeset |
| 1338 |
% we need two counters for the coordinates. These counters are now |
| 1339 |
% allocated (even though we could use temporary counters from |
| 1340 |
% \LaTeX). |
| 1341 |
% \begin{macrocode} |
| 1342 |
\newcount\Puzzle@X |
| 1343 |
\newcount\Puzzle@Y |
| 1344 |
% \end{macrocode} |
| 1345 |
% |
| 1346 |
% \begin{macrocode} |
| 1347 |
\begingroup |
| 1348 |
\catcode`\|=13 |
| 1349 |
\gdef\Puzzle@@solution{ |
| 1350 |
\let|=\Puzzle@Box@@solution |
| 1351 |
\let\Frame=\Puzzle@Frame@@solution |
| 1352 |
} |
| 1353 |
% \end{macrocode} |
| 1354 |
% |
| 1355 |
% \begin{macrocode} |
| 1356 |
\gdef\Puzzle@@normal{ |
| 1357 |
\let|=\Puzzle@Box@@normal |
| 1358 |
\let\Frame=\Puzzle@Frame@@normal |
| 1359 |
} |
| 1360 |
\endgroup |
| 1361 |
% \end{macrocode} |
| 1362 |
% |
| 1363 |
% \begin{environment}{Puzzle} |
| 1364 |
% The environment |Puzzle| typesets the frame of a crossword |
| 1365 |
% puzzle. It is implemented utilizing a |picture| environment. The |
| 1366 |
% unitlength is set to the |\PuzzleUnitlength|. Thus the navigation |
| 1367 |
% is fairly easy. The basic unit is width and height of a single |
| 1368 |
% box. |
| 1369 |
% |
| 1370 |
% The macros which are local to the environment are activated. Thus |
| 1371 |
% we avoid collisions with other packages where the same macro names |
| 1372 |
% might be used. |
| 1373 |
% |
| 1374 |
% Finally the counter which contain the x and the y coordinate have |
| 1375 |
% to be initialized. |
| 1376 |
% |
| 1377 |
% The last action in the |picture| environment is the expansion of |
| 1378 |
% the macro |\PuzzleHook|. This can be used to include additional |
| 1379 |
% material in the |picture| environment. Primarily I have use this |
| 1380 |
% to include the ads. But now there is the macro |\Frame| for this |
| 1381 |
% purpose. |
| 1382 |
% \begin{macrocode} |
| 1383 |
\newenvironment{Puzzle}[2]{\PuzzlePre |
| 1384 |
\catcode`\|=13 |
| 1385 |
\@nameuse{Puzzle@@\Puzzle@TYPE}% |
| 1386 |
\unitlength=\PuzzleUnitlength |
| 1387 |
\linethickness{\PuzzleLineThickness}% |
| 1388 |
\Puzzle@Y=#2 |
| 1389 |
\begin{picture}(#1,#2) |
| 1390 |
\Puzzle@Box@@normal. |
| 1391 |
}{% |
| 1392 |
\PuzzleHook |
| 1393 |
\end{picture}\PuzzlePost |
| 1394 |
} |
| 1395 |
% \end{macrocode} |
| 1396 |
% \end{environment} |
| 1397 |
% |
| 1398 |
% \begin{macro}{\PuzzleLineThickness} |
| 1399 |
% The macro |\PuzzleLineThickness| contains the width of the line |
| 1400 |
% used to frame the cells. |
| 1401 |
% \changes{1.5}{2006/08/11}{New} |
| 1402 |
% \begin{macrocode} |
| 1403 |
\newcommand\PuzzleLineThickness{.25pt} |
| 1404 |
% \end{macrocode} |
| 1405 |
% \end{macro} |
| 1406 |
% |
| 1407 |
% \begin{macro}{\PuzzlePre} |
| 1408 |
% This macro contains the code to be inserted before a puzzle is |
| 1409 |
% typeset. It is initialized to begin a new paragraph and center the |
| 1410 |
% puzzle. |
| 1411 |
% \changes{1.5}{2006/08/11}{New} |
| 1412 |
% \begin{macrocode} |
| 1413 |
\newcommand\PuzzlePre{% |
| 1414 |
\par\noindent\mbox{}\hfill |
| 1415 |
} |
| 1416 |
% \end{macrocode} |
| 1417 |
% \end{macro} |
| 1418 |
% |
| 1419 |
% \begin{macro}{\PuzzlePost} |
| 1420 |
% This macro contains the code to be inserted after a puzzle is |
| 1421 |
% typeset. It is initialized to end the paragraph and center the |
| 1422 |
% puzzle. |
| 1423 |
% \changes{1.5}{2006/08/11}{New} |
| 1424 |
% \begin{macrocode} |
| 1425 |
\newcommand\PuzzlePost{% |
| 1426 |
\hfill\null\par\noindent |
| 1427 |
} |
| 1428 |
% \end{macrocode} |
| 1429 |
% \end{macro} |
| 1430 |
% |
| 1431 |
% \begin{macro}{\Puzzle@Frame@@normal} |
| 1432 |
% The macro |Puzzle@Frame| is used to place additional |
| 1433 |
% rectangular regions into the puzzle frame. This frame can contain |
| 1434 |
% arbitrary text which is typeset in a centered environment. |
| 1435 |
% |
| 1436 |
% This macro takes five arguments. The first two arguments are the |
| 1437 |
% coordinates of the upper left corner of the frame. The |
| 1438 |
% coordinates are logical coordinates starting from the lower left |
| 1439 |
% corner of the puzzle. The next two arguments are the width and the |
| 1440 |
% height of the frame given in the number of boxes covered. Finally |
| 1441 |
% the fifth argument contains the text which should appear in this |
| 1442 |
% frame. |
| 1443 |
% \begin{macrocode} |
| 1444 |
\newcommand\Puzzle@Frame@@normal[5]{\put(#1,#2){\framebox(#3,#4){% |
| 1445 |
\begin{minipage}{#3\unitlength}\begin{center} #5 |
| 1446 |
\end{center}\end{minipage}}}} |
| 1447 |
% \end{macrocode} |
| 1448 |
% \end{macro} |
| 1449 |
% |
| 1450 |
% \begin{macro}{\Puzzle@Frame@@solution} |
| 1451 |
% For the solution the framed ads are simply ignored. |
| 1452 |
% \begin{macrocode} |
| 1453 |
\newcommand\Puzzle@Frame@@solution[5]{} |
| 1454 |
% \end{macrocode} |
| 1455 |
% \end{macro} |
| 1456 |
% |
| 1457 |
% \begin{macro}{\PuzzleBlackBox} |
| 1458 |
% The macro |\PuzzleBlackBox| is called to typeset the black boxes. |
| 1459 |
% It should produce a box of at most width and height of |
| 1460 |
% |\PuzzleUnitlength|. |
| 1461 |
% \begin{macrocode} |
| 1462 |
\newcommand\PuzzleBlackBox{\rule{\PuzzleUnitlength}{\PuzzleUnitlength}} |
| 1463 |
% \end{macrocode} |
| 1464 |
% \end{macro} |
| 1465 |
% |
| 1466 |
% \begin{macro}{\Puzzle@Box@@normal} |
| 1467 |
% The macro |\Puzzle@Box@@normal| performs all tasks when a box |
| 1468 |
% should be typeset in ``normal'' mode. The arguments are evaluated |
| 1469 |
% and the appropriate type of box typeset or other actions performed. |
| 1470 |
% \changes{1.4}{1996/11/25}{Minor bug fix. Using |
| 1471 |
% \texttt{\char`\\ifx} |
| 1472 |
% instead of \texttt{\char`\\if}.} |
| 1473 |
% \changes{1.5}{2006/08/10}{Reimplemented to cope with two optional |
| 1474 |
% arguments.} |
| 1475 |
% \begin{macrocode} |
| 1476 |
\newcommand\Puzzle@Box@@normal[1][]{% |
| 1477 |
\def\Puzzle@tmp@{#1}% |
| 1478 |
\Puzzle@Box@@normal@ |
| 1479 |
} |
| 1480 |
% \end{macrocode} |
| 1481 |
% \end{macro} |
| 1482 |
% |
| 1483 |
% \begin{macro}{\Puzzle@Box@@normal@} |
| 1484 |
% The macro |\Puzzle@Box@@normal@| performs all tasks when a box |
| 1485 |
% should be typeset in ``normal'' mode. The arguments are evaluated |
| 1486 |
% and the appropriate type of box typeset or other actions performed. |
| 1487 |
% \changes{1.5}{2006/08/10}{Extracted from |
| 1488 |
% \texttt{\char`\\Puzzle@Box@@normal}.} |
| 1489 |
% \changes{1.7}{2009/06/09}{\texttt{\char`\\PuzzleContent} added to |
| 1490 |
% transport the letter to the formatting macro.} |
| 1491 |
% \begin{macrocode} |
| 1492 |
\newcommand\Puzzle@Box@@normal@[2][f]{% |
| 1493 |
\def\PuzzleContent{#2}% |
| 1494 |
\def\Puzzle@tmp{#2}% |
| 1495 |
\if\Puzzle@tmp. |
| 1496 |
\Puzzle@X=0 |
| 1497 |
\advance\Puzzle@Y-1 |
| 1498 |
\else |
| 1499 |
\ifx\Puzzle@tmp\@empty |
| 1500 |
\else |
| 1501 |
\if\Puzzle@tmp* |
| 1502 |
\Puzzle@Cell@Loop *#1{}% |
| 1503 |
\else |
| 1504 |
\Puzzle@Cell@Loop #1{}% |
| 1505 |
\fi |
| 1506 |
\fi |
| 1507 |
\ifx\@empty\Puzzle@tmp@\else |
| 1508 |
\PuzzlePutNumber{\Puzzle@X}{\Puzzle@Y}{\Puzzle@tmp@}% |
| 1509 |
\fi |
| 1510 |
\advance\Puzzle@X 1 |
| 1511 |
\fi |
| 1512 |
} |
| 1513 |
% \end{macrocode} |
| 1514 |
% \end{macro} |
| 1515 |
% |
| 1516 |
% \begin{macro}{\PuzzlePutNumber} |
| 1517 |
% The macro |\PuzzlePutNumber| is a configuration macro which |
| 1518 |
% typesets the number in a cell. The first argument is the x |
| 1519 |
% coordinate. The second argument is the y coordinate. The third |
| 1520 |
% argument is the number to be typeset. |
| 1521 |
% \changes{1.5}{2006/08/10}{New} |
| 1522 |
% \begin{macrocode} |
| 1523 |
\def\PuzzlePutNumber#1#2#3{% |
| 1524 |
\put(#1,#2){\makebox(1,.95)[tl]{\PuzzleNumberFont\,#3}}% |
| 1525 |
} |
| 1526 |
% \end{macrocode} |
| 1527 |
% \end{macro} |
| 1528 |
% |
| 1529 |
% \begin{macro}{\Puzzle@Cell@Loop} |
| 1530 |
% The macro |\Puzzle@Cell@Loop| processes its arguments until an |
| 1531 |
% empty argument is found. For each argument it is tried to invoke |
| 1532 |
% the corresponding cell drawing macro. |
| 1533 |
% \changes{1.5}{2006/08/09}{New} |
| 1534 |
% \begin{macrocode} |
| 1535 |
\def\Puzzle@Cell@Loop#1{% |
| 1536 |
\def\Puzzle@tmp{#1}% |
| 1537 |
\ifx\Puzzle@tmp\@empty |
| 1538 |
\let\Puzzle@tmp\relax |
| 1539 |
\else |
| 1540 |
\expandafter\ifx\csname Puzzle@Cell@@#1\endcsname\relax |
| 1541 |
\typeout{cwpuzzle: Cell type #1 is undefined. I am ignoring it}% |
| 1542 |
\else |
| 1543 |
\csname Puzzle@Cell@@#1\endcsname{\Puzzle@X}{\Puzzle@Y}% |
| 1544 |
\fi |
| 1545 |
\let\Puzzle@tmp\Puzzle@Cell@Loop |
| 1546 |
\fi |
| 1547 |
\Puzzle@tmp |
| 1548 |
} |
| 1549 |
% \end{macrocode} |
| 1550 |
% \end{macro} |
| 1551 |
% |
| 1552 |
% \begin{macro}{\Puzzle@Box@@solution} |
| 1553 |
% The macro |\Puzzle@Box@@solution| performs all tasks when a box |
| 1554 |
% should be typeset in ``solution'' mode. The arguments are evaluated |
| 1555 |
% and the appropriate type of box typeset or other actions performed. |
| 1556 |
% \changes{1.4}{1996/11/25}{Minor bug fix. Using \texttt{\char`\\ifx} instead of \texttt{\char`\\if}.} |
| 1557 |
% \changes{1.5}{2006/08/10}{Reimplemented to cope with two optional arguments.} |
| 1558 |
% \begin{macrocode} |
| 1559 |
\newcommand\Puzzle@Box@@solution[1][]{% |
| 1560 |
\def\Puzzle@tmp@{#1}% |
| 1561 |
\Puzzle@Box@@solution@ |
| 1562 |
} |
| 1563 |
% \end{macrocode} |
| 1564 |
% \end{macro} |
| 1565 |
% |
| 1566 |
% \begin{macro}{\Puzzle@Box@@solution@} |
| 1567 |
% The macro |\Puzzle@Box@@solution@| performs all tasks when a box |
| 1568 |
% should be typeset in ``solution'' mode. The arguments are evaluated |
| 1569 |
% and the appropriate type of box typeset or other actions performed. |
| 1570 |
% \changes{1.5}{2006/08/10}{Reimplemented to cope with two optional arguments.} |
| 1571 |
% \changes{1.9}{2014/01/12}{Macro PuzzleSolutionContent introduced as extension point} |
| 1572 |
% \begin{macrocode} |
| 1573 |
\newcommand\Puzzle@Box@@solution@[2][f]{% |
| 1574 |
\def\Puzzle@tmp{#2}% |
| 1575 |
\if\Puzzle@tmp. |
| 1576 |
\Puzzle@X=0 |
| 1577 |
\advance\Puzzle@Y-1 |
| 1578 |
\else |
| 1579 |
\ifx\Puzzle@tmp\@empty |
| 1580 |
\else |
| 1581 |
\if\Puzzle@tmp* |
| 1582 |
\Puzzle@Cell@Loop *#1{}% |
| 1583 |
\else |
| 1584 |
\Puzzle@Cell@Loop #1{}% |
| 1585 |
\put(\Puzzle@X,\Puzzle@Y){\PuzzleSolutionContent{#2}}% |
| 1586 |
\fi |
| 1587 |
\fi |
| 1588 |
\def\Puzzle@tmp{#1}% |
| 1589 |
\ifx\Puzzle@tmp\@empty\else |
| 1590 |
\ifPuzzle@SolutionNumbered |
| 1591 |
\PuzzlePutNumber{\Puzzle@X}{\Puzzle@Y}{\Puzzle@tmp@}% |
| 1592 |
\fi |
| 1593 |
\fi |
| 1594 |
\advance\Puzzle@X 1 |
| 1595 |
\fi |
| 1596 |
} |
| 1597 |
% \end{macrocode} |
| 1598 |
% \end{macro} |
| 1599 |
% |
| 1600 |
% \begin{macro}{\PuzzleSolutionContent} |
| 1601 |
% The macro |\PuzzleSolutionContent| process the character in |
| 1602 |
% solution mode. Per default it converts the argument to upper |
| 1603 |
% case and sets it in a box of size $1\times1$. |
| 1604 |
% \changes{1.9}{2014/01/12}{Macro PuzzleSolutionContent introduced as extension point} |
| 1605 |
% \begin{macrocode} |
| 1606 |
\def\PuzzleSolutionContent#1{\makebox(1,1){\uppercase{#1}}} |
| 1607 |
% \end{macrocode} |
| 1608 |
% \end{macro} |
| 1609 |
% |
| 1610 |
% \subsection{Predefined Cell Types} |
| 1611 |
% In this section a series of frame types are defined. |
| 1612 |
% |
| 1613 |
% \begin{macro}{\PuzzleDefineCell} |
| 1614 |
% The macro |\PuzzleDefineCell| is a user command to define a new |
| 1615 |
% cell type. The first argument contains the key under which the |
| 1616 |
% cell type should be addressed. This key should be expandable and |
| 1617 |
% should result into a single letter. Special effects can be |
| 1618 |
% achieved with keys constituted of non letters or several |
| 1619 |
% characters. |
| 1620 |
% |
| 1621 |
% The second argument contains the code to be stored for the key |
| 1622 |
% given. |
| 1623 |
% \changes{1.5}{2006/08/08}{New} |
| 1624 |
% \begin{macrocode} |
| 1625 |
\newcommand\PuzzleDefineCell[2]{ |
| 1626 |
\global\@namedef{Puzzle@Cell@@#1}##1##2{#2}% |
| 1627 |
} |
| 1628 |
% \end{macrocode} |
| 1629 |
% \end{macro} |
| 1630 |
% |
| 1631 |
% |
| 1632 |
% \begin{macro}{\PuzzleDefineColorCell} |
| 1633 |
% |
| 1634 |
% \changes{1.5}{2006/08/11}{New} |
| 1635 |
% \begin{macrocode} |
| 1636 |
\newcommand\PuzzleDefineColorCell[2]{ |
| 1637 |
\global\@namedef{Puzzle@Cell@@#1}##1##2{% |
| 1638 |
\fboxsep=0pt |
| 1639 |
\put(##1,##2){\makebox(1,1){\colorbox{#2}{\makebox(1,1){}}}} |
| 1640 |
}% |
| 1641 |
} |
| 1642 |
% \end{macrocode} |
| 1643 |
% \end{macro} |
| 1644 |
% |
| 1645 |
% \begin{macro}{\PuzzleThickine} |
| 1646 |
% The parameter |\PuzzleThickine| contains the expansion text to |
| 1647 |
% be inserted. whenever a thick line is required. This means that |
| 1648 |
% this macro arranges everything that a thick line is drawn. |
| 1649 |
% Usually it contains an invocation to |\linethickness|. It can |
| 1650 |
% be redefined to achieve other effects like even thicker lines |
| 1651 |
% or colored lines. Note that the macro is used inside a group in |
| 1652 |
% the predefined cell types. |
| 1653 |
% \begin{macrocode} |
| 1654 |
\def\PuzzleThickline{\linethickness{2pt}} |
| 1655 |
% \end{macrocode} |
| 1656 |
% \end{macro} |
| 1657 |
% |
| 1658 |
% \begin{macro}{\Puzzle@Cell@@T} |
| 1659 |
% The letter T produces a thicker line at the top of the cell. |
| 1660 |
% The thickness of this line is controlled by the macro |
| 1661 |
% |\PuzzleThickline|. |
| 1662 |
% \changes{1.5}{2006/08/08}{New} |
| 1663 |
% \begin{macrocode} |
| 1664 |
\PuzzleDefineCell{T}{{% |
| 1665 |
\advance#2 1 |
| 1666 |
\PuzzleThickline |
| 1667 |
\put(#1,#2){{\line(1,0){1}}} |
| 1668 |
}} |
| 1669 |
% \end{macrocode} |
| 1670 |
% \end{macro} |
| 1671 |
% |
| 1672 |
% \begin{macro}{\Puzzle@Cell@@t} |
| 1673 |
% The letter t produces a frame with a thicker line at the top. |
| 1674 |
% The thickness of this line is controlled by the macro |
| 1675 |
% |\PuzzleThickline|. |
| 1676 |
% \changes{1.5}{2006/08/08}{New} |
| 1677 |
% \begin{macrocode} |
| 1678 |
\PuzzleDefineCell{t}{{% |
| 1679 |
\put(#1,#2){\framebox(1,1){}} |
| 1680 |
\advance#2 1 |
| 1681 |
\PuzzleThickline |
| 1682 |
\put(#1,#2){{\line(1,0){1}}} |
| 1683 |
}} |
| 1684 |
% \end{macrocode} |
| 1685 |
% \end{macro} |
| 1686 |
% |
| 1687 |
% |
| 1688 |
% \begin{macro}{\Puzzle@Cell@@B} |
| 1689 |
% The letter B produces a thicker line at the bottom of the cell. |
| 1690 |
% The thickness of this line is controlled by the macro |
| 1691 |
% |\PuzzleThickline|. |
| 1692 |
% \changes{1.5}{2006/08/10}{New} |
| 1693 |
% \begin{macrocode} |
| 1694 |
\PuzzleDefineCell{B}{{% |
| 1695 |
\PuzzleThickline |
| 1696 |
\put(#1,#2){{\line(1,0){1}}} |
| 1697 |
}} |
| 1698 |
% \end{macrocode} |
| 1699 |
% \end{macro} |
| 1700 |
% |
| 1701 |
% \begin{macro}{\Puzzle@Cell@@b} |
| 1702 |
% The letter b produces a frame with a thicker line at the bottom. |
| 1703 |
% The thickness of this line is controlled by the macro |
| 1704 |
% |\PuzzleThickline|. |
| 1705 |
% \changes{1.5}{2006/08/10}{New} |
| 1706 |
% \begin{macrocode} |
| 1707 |
\PuzzleDefineCell{b}{{% |
| 1708 |
\put(#1,#2){\framebox(1,1){}} |
| 1709 |
\PuzzleThickline |
| 1710 |
\put(#1,#2){{\line(1,0){1}}} |
| 1711 |
}} |
| 1712 |
% \end{macrocode} |
| 1713 |
% \end{macro} |
| 1714 |
% |
| 1715 |
% \begin{macro}{\Puzzle@Cell@@l} |
| 1716 |
% The letter l produces a frame with a thicker line at the left |
| 1717 |
% side of the cell. The thickness of this line is controlled by |
| 1718 |
% the macro |\PuzzleThickline|. |
| 1719 |
% \changes{1.5}{2006/08/10}{New} |
| 1720 |
% \begin{macrocode} |
| 1721 |
\PuzzleDefineCell{l}{{% |
| 1722 |
\put(#1,#2){\framebox(1,1){}} |
| 1723 |
\PuzzleThickline |
| 1724 |
\put(#1,#2){{\line(0,1){1}}} |
| 1725 |
}} |
| 1726 |
% \end{macrocode} |
| 1727 |
% \end{macro} |
| 1728 |
% |
| 1729 |
% \begin{macro}{\Puzzle@Cell@@L} |
| 1730 |
% The letter L produces a thicker line at the left side of the |
| 1731 |
% cell. The thickness of this line is controlled by the macro |
| 1732 |
% |\PuzzleThickline|. |
| 1733 |
% \changes{1.5}{2006/08/10}{New} |
| 1734 |
% \begin{macrocode} |
| 1735 |
\PuzzleDefineCell{L}{{% |
| 1736 |
\PuzzleThickline |
| 1737 |
\put(#1,#2){{\line(0,1){1}}} |
| 1738 |
}} |
| 1739 |
% \end{macrocode} |
| 1740 |
% \end{macro} |
| 1741 |
% |
| 1742 |
% \begin{macro}{\Puzzle@Cell@@r} |
| 1743 |
% The letter r produces a frame with a thicker line at the right |
| 1744 |
% side of the cell. The thickness of this line is controlled by |
| 1745 |
% the macro |\PuzzleThickline|. |
| 1746 |
% \changes{1.5}{2006/08/10}{New} |
| 1747 |
% \begin{macrocode} |
| 1748 |
\PuzzleDefineCell{r}{{% |
| 1749 |
\put(#1,#2){\framebox(1,1){}} |
| 1750 |
\advance #1 1 |
| 1751 |
\PuzzleThickline |
| 1752 |
\put(#1,#2){{\line(0,1){1}}} |
| 1753 |
}} |
| 1754 |
% \end{macrocode} |
| 1755 |
% \end{macro} |
| 1756 |
% |
| 1757 |
% \begin{macro}{\Puzzle@Cell@@R} |
| 1758 |
% The letter R produces a thicker line at the right side of the |
| 1759 |
% cell. The thickness of this line is controlled by the macro |
| 1760 |
% |\PuzzleThickline|. |
| 1761 |
% \changes{1.5}{2006/08/10}{New} |
| 1762 |
% \begin{macrocode} |
| 1763 |
\PuzzleDefineCell{R}{{% |
| 1764 |
\advance #1 1 |
| 1765 |
\PuzzleThickline |
| 1766 |
\put(#1,#2){{\line(0,1){1}}} |
| 1767 |
}} |
| 1768 |
% \end{macrocode} |
| 1769 |
% \end{macro} |
| 1770 |
% |
| 1771 |
% \begin{macro}{\Puzzle@Cell@@f} |
| 1772 |
% The letter f produces a simple frame around the cell. This is |
| 1773 |
% the default if nothing is specified. |
| 1774 |
% \changes{1.5}{2006/08/08}{New} |
| 1775 |
% \begin{macrocode} |
| 1776 |
\PuzzleDefineCell{f}{{% |
| 1777 |
\put(#1,#2){\framebox(1,1){}} |
| 1778 |
}} |
| 1779 |
% \end{macrocode} |
| 1780 |
% \end{macro} |
| 1781 |
% |
| 1782 |
% \begin{macro}{\Puzzle@Cell@@S} |
| 1783 |
% The letter S produces the solution without any other formatting |
| 1784 |
% around it. |
| 1785 |
% \changes{1.7}{2009/06/09}{New} |
| 1786 |
% \begin{macrocode} |
| 1787 |
\PuzzleDefineCell{S}{{% |
| 1788 |
\put(#1,#2){\makebox(1,1){\expandafter\uppercase{\PuzzleContent}}} |
| 1789 |
}} |
| 1790 |
% \end{macrocode} |
| 1791 |
% \end{macro} |
| 1792 |
% |
| 1793 |
% |
| 1794 |
% \begin{macro}{\Puzzle@Cell@@.} |
| 1795 |
% The character . produces no additional rendering. It can be used |
| 1796 |
% to overwrite the default rendering which is to place a frame |
| 1797 |
% around the cell. |
| 1798 |
% \changes{1.5}{2006/08/11}{New} |
| 1799 |
% \begin{macrocode} |
| 1800 |
\PuzzleDefineCell{.}{} |
| 1801 |
% \end{macrocode} |
| 1802 |
% \end{macro} |
| 1803 |
% |
| 1804 |
% \begin{macro}{\Puzzle@Cell@@O} |
| 1805 |
% The letter O produces an oval which is drawn with the \LaTeX\ macro |
| 1806 |
% \verb/\oval/. |
| 1807 |
% \changes{1.5}{2006/08/11}{New} |
| 1808 |
% \begin{macrocode} |
| 1809 |
\PuzzleDefineCell{O}{{% |
| 1810 |
\put(\the#1.5,\the#2.5){\oval(1,1){}} |
| 1811 |
}} |
| 1812 |
% \end{macrocode} |
| 1813 |
% \end{macro} |
| 1814 |
% |
| 1815 |
% \begin{macro}{\Puzzle@Cell@@o} |
| 1816 |
% The letter o produces an oval inside a frame. This is is an |
| 1817 |
% abbreviation for the two letters fO. |
| 1818 |
% \changes{1.5}{2006/08/08}{New} |
| 1819 |
% \begin{macrocode} |
| 1820 |
\PuzzleDefineCell{o}{{% |
| 1821 |
\put(#1,#2){\framebox(1,1){}} |
| 1822 |
\put(\the#1.5,\the#2.5){\oval(1,1){}} |
| 1823 |
}} |
| 1824 |
% \end{macrocode} |
| 1825 |
% \end{macro} |
| 1826 |
% |
| 1827 |
% \begin{macro}{\Puzzle@Cell@@*} |
| 1828 |
% The letter * produces a solid black box. |
| 1829 |
% \changes{1.5}{2006/08/08}{New} |
| 1830 |
% \begin{macrocode} |
| 1831 |
\PuzzleDefineCell{*}{% |
| 1832 |
\put(#1,#2){\framebox(1,1){\PuzzleBlackBox}} |
| 1833 |
} |
| 1834 |
% \end{macrocode} |
| 1835 |
% \end{macro} |
| 1836 |
% |
| 1837 |
% \begin{macro}{\Puzzle@Cell@@/} |
| 1838 |
% The character / produces a line crossing the cell from lower |
| 1839 |
% left to upper right. |
| 1840 |
% \changes{1.5}{2006/08/08}{New} |
| 1841 |
% \begin{macrocode} |
| 1842 |
\PuzzleDefineCell{/}{{% |
| 1843 |
\put(#1,#2){{\line(1,1){1}}} |
| 1844 |
}} |
| 1845 |
% \end{macrocode} |
| 1846 |
% \end{macro} |
| 1847 |
% |
| 1848 |
% \begin{macro}{\Puzzle@Cell@@,} |
| 1849 |
% The character , produces a line crossing the cell from upper |
| 1850 |
% left to lower right. |
| 1851 |
% \changes{1.5}{2006/08/11}{New} |
| 1852 |
% \begin{macrocode} |
| 1853 |
\PuzzleDefineCell{,}{{% |
| 1854 |
\advance#2 1 |
| 1855 |
\put(#1,#2){{\line(1,-1){1}}} |
| 1856 |
}} |
| 1857 |
% \end{macrocode} |
| 1858 |
% \end{macro} |
| 1859 |
% |
| 1860 |
% |
| 1861 |
% \subsection{Clues} |
| 1862 |
% |
| 1863 |
% \begin{macro}{\Puzzle@Clue@@normal} |
| 1864 |
% The first and the third argument are shown as clue. This macro is |
| 1865 |
% used for unsolved puzzles. |
| 1866 |
% \begin{macrocode} |
| 1867 |
\newcommand\Puzzle@Clue@@normal[3]{\textsf{#1} #3 } |
| 1868 |
% \end{macrocode} |
| 1869 |
% \end{macro} |
| 1870 |
% |
| 1871 |
% \begin{macro}{\Puzzle@Clue@@solution} |
| 1872 |
% In solutions clues are simply suppressed. Thus all three |
| 1873 |
% arguments are discarded. |
| 1874 |
% \begin{macrocode} |
| 1875 |
\newcommand\Puzzle@Clue@@solution[3]{} |
| 1876 |
% \end{macrocode} |
| 1877 |
% \end{macro} |
| 1878 |
% |
| 1879 |
% \begin{environment}{Puzzle@Clues@@normal} |
| 1880 |
% The environment |Puzzle@Clues@@normal| is mapped to |PuzzleClues| |
| 1881 |
% in ``normal'' mode. It typesets its contents in a mini-page of |
| 1882 |
% approximately half text width. |
| 1883 |
% \begin{macrocode} |
| 1884 |
\newenvironment{Puzzle@Clues@@normal}[1]{% |
| 1885 |
\let\Clue\Puzzle@Clue@@normal |
| 1886 |
\PuzzleCluePre |
| 1887 |
\PuzzleClueFont{#1}% |
| 1888 |
}{\PuzzleCluePost } |
| 1889 |
% \end{macrocode} |
| 1890 |
% \end{environment} |
| 1891 |
% |
| 1892 |
% \begin{macro}{\PuzzleCluePre} |
| 1893 |
% The macro |\PuzzleCluePre| contains the code which is inserted |
| 1894 |
% before the clues are typeset in normal mode. |
| 1895 |
% \begin{macrocode} |
| 1896 |
\newcommand\PuzzleCluePre{% |
| 1897 |
\null\hfill |
| 1898 |
\begin{minipage}[t]{\PuzzleClueWidth}% |
| 1899 |
} |
| 1900 |
% \end{macrocode} |
| 1901 |
% \end{macro} |
| 1902 |
% |
| 1903 |
% \begin{macro}{\PuzzleClueWidth} |
| 1904 |
% The macro |\PuzzleClueWidth| contains the default width of the |
| 1905 |
% PuzzleClue environment. |
| 1906 |
% \changes{1.14}{2026/02/11}{PuzzleClueWidth introduced.} |
| 1907 |
% \begin{macrocode} |
| 1908 |
\newcommand\PuzzleClueWidth{.45\textwidth} |
| 1909 |
% \end{macrocode} |
| 1910 |
% \end{macro} |
| 1911 |
% |
| 1912 |
% \begin{macro}{\PuzzleCluePost} |
| 1913 |
% The macro |\PuzzleCluePost| contains the code which is inserted |
| 1914 |
% after the clues are typeset in normal mode. |
| 1915 |
% \begin{macrocode} |
| 1916 |
\newcommand\PuzzleCluePost{ |
| 1917 |
\end{minipage}\hfill\null |
| 1918 |
} |
| 1919 |
% \end{macrocode} |
| 1920 |
% \end{macro} |
| 1921 |
% |
| 1922 |
% \begin{environment}{Puzzle@Clues@@solution} |
| 1923 |
% The environment |Puzzle@Clues@@solution| is mapped to |PuzzleClues| |
| 1924 |
% in ``solution'' mode. It just suppresses any output. |
| 1925 |
% \begin{macrocode} |
| 1926 |
\newenvironment{Puzzle@Clues@@solution}[1]{% |
| 1927 |
\let\Clue\Puzzle@Clue@@solution |
| 1928 |
}{} |
| 1929 |
% \end{macrocode} |
| 1930 |
% \end{environment} |
| 1931 |
% |
| 1932 |
% \begin{macro}{\PuzzleWordsText} |
| 1933 |
% The macro |\PuzzleWordsText| is the text typeset at the beginning |
| 1934 |
% of the environment |PuzzleWords|. It takes one argument which is |
| 1935 |
% the length of the words listed. |
| 1936 |
% \begin{macrocode} |
| 1937 |
\newcommand\PuzzleWordsText[1]{Words of length #1: } |
| 1938 |
% \end{macrocode} |
| 1939 |
% \end{macro} |
| 1940 |
% |
| 1941 |
% \begin{environment}{Puzzle@Words@@normal} |
| 1942 |
% The environment |Puzzle@Words@@normal| will be mapped to the |
| 1943 |
% environment |PuzzleWords| in ``normal'' mode. It just arranges |
| 1944 |
% that words are typeset after the |\PuzzleWordsText| has shown the |
| 1945 |
% length of the words. Finally a new paragraph is started. |
| 1946 |
% \begin{macrocode} |
| 1947 |
\newenvironment{Puzzle@Words@@normal}[1]{% |
| 1948 |
\PuzzleWordsText{#1}% |
| 1949 |
\let\Word\relax |
| 1950 |
}{\par} |
| 1951 |
% \end{macrocode} |
| 1952 |
% \end{environment} |
| 1953 |
% |
| 1954 |
% \begin{environment}{Puzzle@Words@@solution} |
| 1955 |
% The environment |Puzzle@Words@@solution| will be mapped to the |
| 1956 |
% environment |PuzzleWords| in ``solution'' mode. It arranges |
| 1957 |
% things such that the contents is silently ignored. |
| 1958 |
% \begin{macrocode} |
| 1959 |
\newenvironment{Puzzle@Words@@solution}[1]{% |
| 1960 |
\newcommand\Word[1]{}% |
| 1961 |
}{} |
| 1962 |
% \end{macrocode} |
| 1963 |
% \end{environment} |
| 1964 |
% |
| 1965 |
% \subsection{Numbers} |
| 1966 |
% |
| 1967 |
% \begin{macro}{\PuzzleNumbers} |
| 1968 |
% The macro |\PuzzleNumbers| will produce a list of boxes with |
| 1969 |
% numbers for letters. It is intended for numbered crossword puzzles. |
| 1970 |
% \begin{macrocode} |
| 1971 |
\newcommand\PuzzleNumbers[1]{\begingroup |
| 1972 |
\@nameuse{Puzzle@@\Puzzle@TYPE}% |
| 1973 |
\Puzzle@Y=0 |
| 1974 |
\Puzzle@X=1 |
| 1975 |
\unitlength=\PuzzleUnitlength |
| 1976 |
\Puzzle@Numbers#1.\endgroup} |
| 1977 |
% \end{macrocode} |
| 1978 |
% \end{macro} |
| 1979 |
% |
| 1980 |
% \begin{macro}{\Puzzle@Numbers} |
| 1981 |
% The macro |\Puzzle@Numbers| loops through the arguments until it |
| 1982 |
% finds a dot. For each argument it produces a box, either with the |
| 1983 |
% numbers or with the letters or both, depending on the current |
| 1984 |
% settings. |
| 1985 |
% |
| 1986 |
% The loop is implemented via recursion. The box is typeset by the |
| 1987 |
% \verb/|/ macro which takes care of the current settings. For this |
| 1988 |
% purpose this character has to be made active temporarily. |
| 1989 |
% \begin{macrocode} |
| 1990 |
\begingroup |
| 1991 |
\catcode`\|=13 |
| 1992 |
\gdef\Puzzle@Numbers#1{% |
| 1993 |
\if#1. |
| 1994 |
\let\next\relax |
| 1995 |
\else |
| 1996 |
\begin{picture}(1,1) |
| 1997 |
\xdef\X{\the\Puzzle@X}% |
| 1998 |
\Puzzle@X=0 |
| 1999 |
|[\X]{#1}% |
| 2000 |
\end{picture}% |
| 2001 |
\let\next\Puzzle@Numbers |
| 2002 |
\advance\Puzzle@X 1 |
| 2003 |
\fi |
| 2004 |
\next |
| 2005 |
} |
| 2006 |
\endgroup |
| 2007 |
% \end{macrocode} |
| 2008 |
% \end{macro} |
| 2009 |
% |
| 2010 |
% \begin{macro}{\PuzzleLettersText} |
| 2011 |
% The macro |\PuzzleLettersText| contains the text typeset at the |
| 2012 |
% beginning of the |\PuzzleLetters| environment. |
| 2013 |
% \begin{macrocode} |
| 2014 |
\newcommand\PuzzleLettersText{The following letters are used: } |
| 2015 |
% \end{macrocode} |
| 2016 |
% \end{macro} |
| 2017 |
% |
| 2018 |
% \begin{macro}{\PuzzleLetters} |
| 2019 |
% The macro |\PuzzleLetters| is intended to show the letters used |
| 2020 |
% in a numbered crossword puzzle. The argument is the (sorted) list |
| 2021 |
% of characters used. |
| 2022 |
% \begin{macrocode} |
| 2023 |
\newcommand\PuzzleLetters[1]{\PuzzleLettersText #1\par} |
| 2024 |
% \end{macrocode} |
| 2025 |
% \end{macro} |
| 2026 |
% |
| 2027 |
% \begin{macro}{\Puzzle@TYPE} |
| 2028 |
% The macro |\Puzzle@TYPE| contains the type of the puzzle. It is |
| 2029 |
% used to find the appropriate initialization macro. |
| 2030 |
% \begin{macrocode} |
| 2031 |
\newcommand\Puzzle@TYPE{normal} |
| 2032 |
% \end{macrocode} |
| 2033 |
% \end{macro} |
| 2034 |
% |
| 2035 |
% \begin{macro}{\PuzzleSolution} |
| 2036 |
% The macro |\PuzzleSolution| arranges everything such that the |
| 2037 |
% following puzzles are typeset in the ``solution'' mode, i.e. the |
| 2038 |
% letters are shown and the clues are suppressed. |
| 2039 |
% |
| 2040 |
% This macros has one optional argument which has to be |true| or |
| 2041 |
% |false|. This argument determines whether or not the numbers |
| 2042 |
% should also be shown in the solution. The default is |false| |
| 2043 |
% which means that the numbers are suppressed in the solution. |
| 2044 |
% \begin{macrocode} |
| 2045 |
\newcommand\PuzzleSolution[1][false]{% |
| 2046 |
\@nameuse{Puzzle@SolutionNumbered#1}% |
| 2047 |
\let\Kakuro@HINT\Kakuro@nohint |
| 2048 |
\let\PuzzleClues\Puzzle@Clues@@solution |
| 2049 |
\let\endPuzzleClues\endPuzzle@Clues@@solution |
| 2050 |
\let\PuzzleWords\Puzzle@Words@@solution |
| 2051 |
\let\endPuzzleWords\endPuzzle@Words@@solution |
| 2052 |
\def\Puzzle@TYPE{solution}% |
| 2053 |
} |
| 2054 |
% \end{macrocode} |
| 2055 |
% \end{macro} |
| 2056 |
% |
| 2057 |
% \begin{macro}{\PuzzleUnsolved} |
| 2058 |
% The macro |\PuzzleUnsolved| arranges everything such that the |
| 2059 |
% following puzzles are typeset in the ``unsolved'' mode, i.e. the |
| 2060 |
% letters are suppressed and the clues are shown. |
| 2061 |
% \begin{macrocode} |
| 2062 |
\newcommand\PuzzleUnsolved{% |
| 2063 |
\let\Kakuro@HINT\Kakuro@hint |
| 2064 |
\let\PuzzleClues\Puzzle@Clues@@normal |
| 2065 |
\let\endPuzzleClues\endPuzzle@Clues@@normal |
| 2066 |
\let\PuzzleWords\Puzzle@Words@@normal |
| 2067 |
\let\endPuzzleWords\endPuzzle@Words@@normal |
| 2068 |
\xdef\Puzzle@TYPE{normal}} |
| 2069 |
% \end{macrocode} |
| 2070 |
% \end{macro} |
| 2071 |
% |
| 2072 |
% The boolean |Puzzle@SolutionNumbered| determines whether or |
| 2073 |
% not the solution should contain numbers. Initially it is set to |
| 2074 |
% ``false''. |
| 2075 |
% |
| 2076 |
% \begin{macrocode} |
| 2077 |
\newif\ifPuzzle@SolutionNumbered |
| 2078 |
\Puzzle@SolutionNumberedfalse |
| 2079 |
% \end{macrocode} |
| 2080 |
% |
| 2081 |
% \subsection{Sudoku} |
| 2082 |
% |
| 2083 |
% The challenge for the sudoku is to implement a convenient input syntax. |
| 2084 |
% |
| 2085 |
% \begin{environment}{Sudoku} |
| 2086 |
% The environemnt |Sudoku| is used to typeset the puzzle. |
| 2087 |
% The implementation defines the begin and end macro separately. |
| 2088 |
% \changes{1.8}{2009/09/13}{New} |
| 2089 |
% \changes{1.13}{2025/01/23}{Minor fix for the solution mode} |
| 2090 |
% \changes{1.15}{2026/02/11}{Using macro |\PuzzleFont|} |
| 2091 |
% \begin{macrocode} |
| 2092 |
\begingroup |
| 2093 |
\catcode`\|=13 |
| 2094 |
\gdef\Sudoku{\begin{Puzzle}{9}{9}% |
| 2095 |
\PuzzleFont |
| 2096 |
\def\PuzzleContent{} |
| 2097 |
\let\Puzzle@pipe=|% |
| 2098 |
\def\PPa{\Puzzle@pipe[][fS]}% |
| 2099 |
\def|##1{\ifx##1*\let\next\PPa\else |
| 2100 |
\Puzzle@pipe{##1}\let\next\relax\fi\next} |
| 2101 |
} |
| 2102 |
\endgroup |
| 2103 |
% \end{macrocode} |
| 2104 |
% |
| 2105 |
% The macro |\endSudoku| contains the code to be expanded at the |
| 2106 |
% end of the environment. It draws the field with the $3\times3$ |
| 2107 |
% boxes. |
| 2108 |
% \changes{1.8}{2009/09/13}{New} |
| 2109 |
% \begin{macrocode} |
| 2110 |
\gdef\endSudoku{% |
| 2111 |
\multiput(0,0)(1,0)9{\framebox(1,1){}} |
| 2112 |
\multiput(0,1)(1,0)9{\framebox(1,1){}} |
| 2113 |
\multiput(0,2)(1,0)9{\framebox(1,1){}} |
| 2114 |
\multiput(0,3)(1,0)9{\framebox(1,1){}} |
| 2115 |
\multiput(0,4)(1,0)9{\framebox(1,1){}} |
| 2116 |
\multiput(0,5)(1,0)9{\framebox(1,1){}} |
| 2117 |
\multiput(0,6)(1,0)9{\framebox(1,1){}} |
| 2118 |
\multiput(0,7)(1,0)9{\framebox(1,1){}} |
| 2119 |
\multiput(0,8)(1,0)9{\framebox(1,1){}} |
| 2120 |
\linethickness{\SudokuLinethickness}% |
| 2121 |
\put(0,0){\framebox(9,9){}} |
| 2122 |
\put(3,0){\framebox(3,9){}} |
| 2123 |
\put(0,3){\framebox(9,3){}} |
| 2124 |
\end{Puzzle}} |
| 2125 |
% \end{macrocode} |
| 2126 |
% \end{environment} |
| 2127 |
% |
| 2128 |
% \begin{macro}{\SudokuLinethickness} |
| 2129 |
% The macro |\SudokuLinethickness| contains the thickness of thick |
| 2130 |
% lines in a Sudoku. |
| 2131 |
% \changes{1.8}{2009/09/13}{New} |
| 2132 |
% \begin{macrocode} |
| 2133 |
\newcommand\SudokuLinethickness{2pt} |
| 2134 |
% \end{macrocode} |
| 2135 |
% \end{macro} |
| 2136 |
% |
| 2137 |
% |
| 2138 |
% \subsection{Kakuro} |
| 2139 |
% |
| 2140 |
% \begin{macro}{\KakuroNumberFont} |
| 2141 |
% The macro |\KakuroNumberFont| is used to typeset the hints, i.e. |
| 2142 |
% the horizontal and vertical sums. |
| 2143 |
% \changes{1.8}{2009/09/13}{New} |
| 2144 |
% \changes{1.10}{2020/05/23}{Font changing macros modernized} |
| 2145 |
% \begin{macrocode} |
| 2146 |
\newcommand\KakuroNumberFont{\sffamily\tiny} |
| 2147 |
% \end{macrocode} |
| 2148 |
% \end{macro} |
| 2149 |
% |
| 2150 |
% \begin{macro}{\Kakuro@cell} |
| 2151 |
% The macro |\Kakuro@cell| is used to typeset the cells. It |
| 2152 |
% analyzes the argument and acts accordingly. |
| 2153 |
% \changes{1.8}{2009/09/13}{New} |
| 2154 |
% \changes{1.10}{2020/05/23}{Font changing macros modernized} |
| 2155 |
% \begin{macrocode} |
| 2156 |
\def\Kakuro@cell#1{% |
| 2157 |
\ifx#1. \def\next{\Puzzle@pipe.}% |
| 2158 |
\else\ifx#1< \let\next\Kakuro@HINT |
| 2159 |
\else\ifx#1* \let\next\Kakuro@always |
| 2160 |
\else\ifx#1- \let\next\Kakuro@empty |
| 2161 |
\else\Puzzle@pipe#1 \let\next\relax |
| 2162 |
\fi\fi\fi\fi |
| 2163 |
\next |
| 2164 |
}% |
| 2165 |
% \end{macrocode} |
| 2166 |
% \end{macro} |
| 2167 |
% |
| 2168 |
% \begin{macro}{\Kakuro@always} |
| 2169 |
% The macro |\Kakuro@always| is used to draw a cell with an inital number. |
| 2170 |
% \changes{1.8}{2009/09/13}{New} |
| 2171 |
% \begin{macrocode} |
| 2172 |
\def\Kakuro@always{\Puzzle@pipe[][fS]}% |
| 2173 |
% \end{macrocode} |
| 2174 |
% \end{macro} |
| 2175 |
% |
| 2176 |
% \begin{macro}{\Kakuro@empty} |
| 2177 |
% The macro |\Kakuro@empty| is used to draw an empty cell. |
| 2178 |
% \changes{1.8}{2009/09/13}{New} |
| 2179 |
% \begin{macrocode} |
| 2180 |
\def\Kakuro@empty{\Puzzle@pipe{}}% |
| 2181 |
% \end{macrocode} |
| 2182 |
% \end{macro} |
| 2183 |
% |
| 2184 |
% \begin{macro}{\Kakuro@hint} |
| 2185 |
% The macro |\Kakuro@hint| is used to draw hints. |
| 2186 |
% \changes{1.8}{2009/09/13}{New} |
| 2187 |
% \begin{macrocode} |
| 2188 |
\def\Kakuro@hint#1:#2>{% |
| 2189 |
\def\x{#2}% |
| 2190 |
\ifx\x\empty\else |
| 2191 |
\put(\Puzzle@X,\Puzzle@Y){% |
| 2192 |
\makebox(1,.8)[r]{\parbox{.95\unitlength}{% |
| 2193 |
\raggedright\KakuroNumberFont |
| 2194 |
$\blacktriangledown$\\#2}}} |
| 2195 |
\fi |
| 2196 |
\def\x{#1}% |
| 2197 |
\ifx\x\empty\else |
| 2198 |
\put(\Puzzle@X,\Puzzle@Y){% |
| 2199 |
\makebox(1,1.2){\parbox{.95\unitlength}{% |
| 2200 |
\raggedleft\KakuroNumberFont |
| 2201 |
#1 $\blacktriangleright$\\\mbox{}}}} |
| 2202 |
\fi |
| 2203 |
\Puzzle@pipe[][\KakuroHintType]{ }}% |
| 2204 |
% \end{macrocode} |
| 2205 |
% \end{macro} |
| 2206 |
% |
| 2207 |
% \begin{macro}{\Kakuro@nohint} |
| 2208 |
% The macro |\Kakuro@nohint| is used to suppress hints in solution mode. |
| 2209 |
% \changes{1.8}{2009/09/13}{New} |
| 2210 |
% \begin{macrocode} |
| 2211 |
\def\Kakuro@nohint#1:#2>{% |
| 2212 |
\Puzzle@pipe[][,]{ }}% |
| 2213 |
% \end{macrocode} |
| 2214 |
% \end{macro} |
| 2215 |
% |
| 2216 |
% \begin{macro}{\Kakuro@HINT} |
| 2217 |
% The macro |\Kakuro@HINT| contains the definition to be used to |
| 2218 |
% typeset hints. This indirection is needed to suppress hints in |
| 2219 |
% solution mode. |
| 2220 |
% \changes{1.8}{2009/09/13}{New} |
| 2221 |
% \begin{macrocode} |
| 2222 |
\let\Kakuro@HINT\Kakuro@hint |
| 2223 |
% \end{macrocode} |
| 2224 |
% \end{macro} |
| 2225 |
% |
| 2226 |
% |
| 2227 |
% \begin{environment}{Kakuro} |
| 2228 |
% The environemnt |Kakuro| is used to typeset the puzzle. |
| 2229 |
% The implementation defines the begin and end macro separately to |
| 2230 |
% cope with catcode changes. |
| 2231 |
% \changes{1.8}{2009/09/13}{New} |
| 2232 |
% \begin{macrocode} |
| 2233 |
\begingroup |
| 2234 |
\catcode`\|=13 |
| 2235 |
\gdef\Kakuro#1#2{\begin{Puzzle}{#1}{#2}% |
| 2236 |
\catcode`\|=13 |
| 2237 |
\let\Puzzle@pipe=| |
| 2238 |
\let|=\Kakuro@cell |
| 2239 |
} |
| 2240 |
\endgroup |
| 2241 |
% \end{macrocode} |
| 2242 |
% |
| 2243 |
% The macro |\endKakuro| contains the code to be expanded at the |
| 2244 |
% end of the environment. |
| 2245 |
% \changes{1.8}{2009/09/13}{New} |
| 2246 |
% \begin{macrocode} |
| 2247 |
\def\endKakuro{\end{Puzzle}} |
| 2248 |
% \end{macrocode} |
| 2249 |
% \end{environment} |
| 2250 |
% |
| 2251 |
% \begin{macro}{\KakuroHintType} |
| 2252 |
% The macro |\KakuroHintType| contains the cell type for |
| 2253 |
% typesetting hint cells. It can be used to achieve a different |
| 2254 |
% look and feel. |
| 2255 |
% \changes{1.8}{2009/09/13}{New} |
| 2256 |
% \begin{macrocode} |
| 2257 |
\def\KakuroHintType{,} |
| 2258 |
% \end{macrocode} |
| 2259 |
% \end{macro} |
| 2260 |
% |
| 2261 |
% |
| 2262 |
% \subsection{Initialization} |
| 2263 |
% |
| 2264 |
% Finally we arrange that the default behavior is to typeset an |
| 2265 |
% unsolved crossword puzzle. |
| 2266 |
% |
| 2267 |
% \begin{macrocode} |
| 2268 |
\PuzzleUnsolved |
| 2269 |
% \end{macrocode} |
| 2270 |
% |
| 2271 |
% Now, that everything is in place we can arrange some package |
| 2272 |
% options. |
| 2273 |
% \changes{1.6}{2006/08/12}{Several style options defined} |
| 2274 |
% \changes{1.10}{2020/05/23}{Font changing macros modernized} |
| 2275 |
% \begin{macrocode} |
| 2276 |
\DeclareOption{numbered}{\Puzzle@SolutionNumberedtrue} |
| 2277 |
\DeclareOption{nocenter}{\let\PuzzlePre=\relax |
| 2278 |
\let\PuzzlePost=\relax} |
| 2279 |
\DeclareOption{unboxed}{\let\PuzzleCluePre=\relax |
| 2280 |
\let\PuzzleCluePost=\relax} |
| 2281 |
\DeclareOption{normalsize}{\PuzzleUnitlength=20pt |
| 2282 |
\def\PuzzleFont{\rmfamily\normalsize}} |
| 2283 |
\DeclareOption{small}{\PuzzleUnitlength=16pt |
| 2284 |
\def\PuzzleFont{\rmfamily\small}} |
| 2285 |
\DeclareOption{large}{\PuzzleUnitlength=24pt |
| 2286 |
\def\PuzzleFont{\rmfamily\large}} |
| 2287 |
% \end{macrocode} |
| 2288 |
% \changes{1.14}{2026/01/11}{huge option added} |
| 2289 |
% \begin{macrocode} |
| 2290 |
\DeclareOption{huge}{\PuzzleUnitlength=32pt |
| 2291 |
\def\PuzzleFont{\rmfamily\huge} |
| 2292 |
\def\PuzzleNumberFont{\large} |
| 2293 |
\def\PuzzleClueFont{\large} |
| 2294 |
} |
| 2295 |
\DeclareOption{Huge}{\PuzzleUnitlength=38pt |
| 2296 |
\def\PuzzleFont{\rmfamily\Huge} |
| 2297 |
\def\PuzzleNumberFont{\Large} |
| 2298 |
\def\PuzzleClueFont{\Large} |
| 2299 |
} |
| 2300 |
\DeclareOption{german}{% |
| 2301 |
\renewcommand\PuzzleWordsText[1]{Worte der L\"ange #1: }% |
| 2302 |
\renewcommand\PuzzleLettersText{Benutzte Buchstaben: }% |
| 2303 |
} |
| 2304 |
\DeclareOption{ngerman}{% |
| 2305 |
\renewcommand\PuzzleWordsText[1]{Worte der L\"ange #1: }% |
| 2306 |
\renewcommand\PuzzleLettersText{Benutzte Buchstaben: }% |
| 2307 |
} |
| 2308 |
% \end{macrocode} |
| 2309 |
% \changes{1.15}{2026/01/13}{french option added} |
| 2310 |
% \begin{macrocode} |
| 2311 |
\DeclareOption{french}{% |
| 2312 |
\renewcommand\PuzzleWordsText[1]{Mots de longueur #1 : }% |
| 2313 |
\renewcommand\PuzzleLettersText{Les lettres suivantes sont utilisées : }% |
| 2314 |
} |
| 2315 |
\ProcessOptions\relax |
| 2316 |
% \end{macrocode} |
| 2317 |
% |
| 2318 |
% That's all. |
| 2319 |
% |
| 2320 |
% \PrintChanges |
| 2321 |
% \newpage |
| 2322 |
% \PrintIndex |
| 2323 |
% |
| 2324 |
% \Finale |
| 2325 |
% |
| 2326 |
\endinput |
| 2327 |
% |
| 2328 |
% Local Variables: |
| 2329 |
% mode: latex |
| 2330 |
% TeX-master: t |
| 2331 |
% End: |