summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-11 23:58:09 +0000
committerKarl Berry <karl@freefriends.org>2006-01-11 23:58:09 +0000
commit21f4ffdcbfe9008f3988f8016d3f6d380271895d (patch)
tree666dcd456b1accc1efdeec9259bf47f644928c3f
parent224bc14829bc59b7a4b09255ce1e1bcaf9419688 (diff)
trunk/Master/texmf-dist/source/latex/sudoku
git-svn-id: svn://tug.org/texlive/trunk@536 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/source/latex/sudoku/sudoku.dtx351
-rw-r--r--Master/texmf-dist/source/latex/sudoku/sudoku.ins63
2 files changed, 414 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/sudoku/sudoku.dtx b/Master/texmf-dist/source/latex/sudoku/sudoku.dtx
new file mode 100644
index 00000000000..b6e6129c9a3
--- /dev/null
+++ b/Master/texmf-dist/source/latex/sudoku/sudoku.dtx
@@ -0,0 +1,351 @@
+% \iffalse meta-comment
+%
+% sudoku.dtx
+% Copyright 2005 Paul Abraham <paul.abraham@hotpop.com>
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either
+% version 1.3 of this license or (at your option) any
+% later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of
+% LaTeX version 2003/12/01 or later.
+%
+% This work has the LPPL maintenance status "maintained".
+%
+% This Current Maintainer of this work is Paul Abraham.
+%
+% This work consists of the files sudoku.dtx, sudoku.ins
+% README, CHANGES and the derived file sudoku.sty.
+%
+% \fi
+%
+% \iffalse
+%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<package>\ProvidesPackage{sudoku}
+%<package> [2005/06/29 v1.0 Sudoku grid]
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{sudoku}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{sudoku.dtx}
+ \PrintChanges
+ \PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{84}
+%
+% \CharacterTable
+% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+% \changes{v1.0}{2005/06/29}{Initial version}
+%
+% \GetFileInfo{sudoku.sty}
+%
+% \DoNotIndex{\newcommand,\newenvironment}
+% \setlength{\parindent}{0pt}
+% \setlength{\parskip}{5pt plus 2pt minus 1pt}
+%
+% \title{The \textsf{sudoku} package\thanks{This document
+% corresponds to \textsf{sudoku}~\fileversion, dated \filedate.}}
+% \author{Paul Abraham \\ \texttt{paul.abraham@hotpop.com}}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% The \textsf{sudoku} package allows the user to typeset
+% sudoku\footnote{I~have seen Sudoku written as Sudoku
+% (one word) and Su Doku (two words). I don't know which of them (if
+% either) is more correct than the other. I am just using one word.}
+% puzzles.
+%
+% A~sudoku puzzle is a 9$\times$9 grid where some of the squares in
+% the grid contain numbers. The rules are simple:
+% every column can only contain the digits 1 to 9,
+% every row can only contain the digits 1 to 9 and
+% every 3$\times$3 box can only contain the digits 1 to 9.
+%
+% The puzzle derives its name from the Japanese \textit{Su}, meaning
+% number, and \textit{Doku\/} meaning singular or solitary.
+%
+% More information, including help and example puzzles, can be found
+% at \texttt{www.sudoku.org.uk}. This site also has blank sudoku grids
+% (or worksheets), but you will not need to print them from there if
+% you have this package installed.
+%
+% \section{Acknowledgements}
+%
+% I~want to thank Morten H\o gholm who took my first attempt at
+% creating a sudoku environment in \LaTeX\ and corrected all my
+% mistakes. He then gave me the help and encouragement to publish
+% it as a package.
+%
+% \section{Usage}
+%
+% \DescribeMacro{\sudokuformat}
+% This macro contains the formatting information for each number
+% in the grid. The default value is \verb|\Huge\sffamily|, which
+% gives correctly sized numbers for the default grid size, but it
+% can be changed with \verb|\renewcommand*\sudokuformat[1]{\|\meta{font}|#1}|.
+%
+% \DescribeMacro{\sudokusize}
+% This length contains the size of the grid, defaulting to \verb|10cm|.
+% It can be changed with \verb|\setlength\sudokusize{|\meta{size}|}|.
+%
+% \DescribeEnv{sudoku-block}
+% This environment draws the sudoku grid. The contents of each cell
+% in the grid are delimited by the vertical bar (\verb+|+) character.
+%
+% \DescribeEnv{sudoku}
+% This environment starts a |center| environment, then uses the
+% |sudoku-block| environment to draw the grid.
+%
+% \section{Examples}
+%
+% This should be a relatively easy puzzle to solve.
+%
+% \begin{verbatim}
+% \begin{sudoku}
+% |2|5| | |3| |9| |1|.
+% | |1| | | |4| | | |.
+% |4| |7| | | |2| |8|.
+% | | |5|2| | | | | |.
+% | | | | |9|8|1| | |.
+% | |4| | | |3| | | |.
+% | | | |3|6| | |7|2|.
+% | |7| | | | | | |3|.
+% |9| |3| | | |6| |4|.
+% \end{sudoku}
+% \end{verbatim}
+% The output is shown in figure~\ref{easypuzzle}. The solution is shown in
+% figure~\ref{easysolution}.
+%
+% \begin{figure}[t]
+% \begin{sudoku}
+% |2|5| | |3| |9| |1|.
+% | |1| | | |4| | | |.
+% |4| |7| | | |2| |8|.
+% | | |5|2| | | | | |.
+% | | | | |9|8|1| | |.
+% | |4| | | |3| | | |.
+% | | | |3|6| | |7|2|.
+% | |7| | | | | | |3|.
+% |9| |3| | | |6| |4|.
+% \end{sudoku}
+% \caption{Easy puzzle\label{easypuzzle}}
+% \end{figure}
+%
+% This is a bit more difficult.
+%
+% \begin{verbatim}
+% \begin{sudoku}
+% | |2| | |3| |9| |7|.
+% | |1| | | | | | | |.
+% |4| |7| | | |2| |8|.
+% | | |5|2| | | |9| |.
+% | | | |1|8| |7| | |.
+% | |4| | | |3| | | |.
+% | | | | |6| | |7|1|.
+% | |7| | | | | | | |.
+% |9| |3| |2| |6| |5|.
+% \end{sudoku}
+% \end{verbatim}
+% The output is shown in figure~\ref{difficultpuzzle}. The solution is shown in
+% figure~\ref{difficultsolution}.
+%
+% \begin{figure}[t]
+% \begin{sudoku}
+% | |2| | |3| |9| |7|.
+% | |1| | | | | | | |.
+% |4| |7| | | |2| |8|.
+% | | |5|2| | | |9| |.
+% | | | |1|8| |7| | |.
+% | |4| | | |3| | | |.
+% | | | | |6| | |7|1|.
+% | |7| | | | | | | |.
+% |9| |3| |2| |6| |5|.
+% \end{sudoku}
+% \caption{Difficult puzzle\label{difficultpuzzle}}
+% \end{figure}
+%
+% \newpage
+% This code will create the same grid inline:
+% \begin{verbatim}
+% \renewcommand*\sudokuformat[1]{\sffamily#1}
+% \setlength\sudokusize{5cm}
+% Easy Sudoku Puzzle
+% \begin{sudoku-block}
+% |2|5| | |3| |9| |1|.
+% | |1| | | |4| | | |.
+% |4| |7| | | |2| |8|.
+% | | |5|2| | | | | |.
+% | | | | |9|8|1| | |.
+% | |4| | | |3| | | |.
+% | | | |3|6| | |7|2|.
+% | |7| | | | | | |3|.
+% |9| |3| | | |6| |4|.
+% \end{sudoku-block}
+% \end{verbatim}
+%
+% \StopEventually{}
+%
+%\iffalse
+% 2005/06/29 v1.0 Initial version
+%\fi
+%
+% \section{Implementation}
+%
+% First initialise a couple of counters that keep track of where we are.
+% \begin{macrocode}
+\newcounter{@sudoku@row}
+\newcounter{@sudoku@col}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand*\@sudoku@separator[1]{%
+ \stepcounter{@sudoku@col}%
+ \ifx#1\@sudoku@separator
+ \expandafter#1%
+ \else
+ \ifx.#1%
+ \setcounter{@sudoku@col}{-1}%
+ \addtocounter{@sudoku@row}{-1}%
+ \else
+ \put(\value{@sudoku@col},\value{@sudoku@row})%
+ {\makebox(1,1){\sudokuformat{#1}}}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\begingroup
+ \catcode`\|=\active
+ \gdef\@sudoku@activate{\let|=\@sudoku@separator}
+\endgroup
+% \end{macrocode}
+%
+% Now we can draw the grid. Each 3$\times$3 box has thicker borders
+% than the rest of the grid.
+%
+% \begin{macrocode}
+\newcommand*\@sudoku@grid{%
+ \thinlines
+ \multiput(0,0)(1,0){10}{\line(0,1){9}}%
+ \multiput(0,0)(0,1){10}{\line(1,0){9}}
+ \thicklines
+ \multiput(0,0)(3,0){4}{\line(0,1){9}}%
+ \multiput(0,0)(0,3){4}{\line(1,0){9}}
+}
+% \end{macrocode}
+%
+% The default font is a huge, sans serif font.
+% \begin{macrocode}
+\newcommand*\sudokuformat[1]{\Huge\sffamily#1}
+% \end{macrocode}
+%
+% The grid defaults to a 10 centimetre square.
+% \begin{macrocode}
+\newdimen\sudokusize
+\setlength\sudokusize{10cm}
+% \end{macrocode}
+%
+% Make the size of each square $1/9$ of the size of sudoku grid.
+% \begin{macrocode}
+\newenvironment{sudoku-block}{%
+ \catcode`\|=\active
+ \@sudoku@activate
+ \setcounter{@sudoku@col}{-1}%
+ \setcounter{@sudoku@row}{8}%
+ \setlength\unitlength{.111111\sudokusize}%
+ \begin{picture}(9,9)%
+ \@sudoku@grid\@sudoku@grab@arguments
+ }{\end{picture}}
+% \end{macrocode}
+%
+% As we change the \verb|catcode| of \verb+|+ inside the environment,
+% under normal \TeX\ we can't just use such an environment as an argument
+% of another command. This can be solved by using e\TeX\ as engine for
+% \LaTeX, which is what all the major distributions do currently.
+% \begin{macrocode}
+ \begingroup
+ \@ifundefined{eTeXversion}{\endgroup
+ \def\@sudoku@grab@arguments#1{%
+ \ifx#1\@sudoku@separator
+ \expandafter#1%
+ \else
+ \PackageError{sudoku}{%
+ Sudoku puzzles are not allowed in the arguments\MessageBreak
+ of other commands}{%
+ Either fix this in your source (possibly using the `lrbox'
+ environment) or use an eTeX based LaTeX format}
+ \fi
+ }%
+ }{\endgroup
+ \def\@sudoku@grab@arguments#1.#2.#3.#4.#5.#6.#7.#8.#9.{%
+ \scantokens{#1.#2.#3.#4.#5.#6.#7.#8.#9.}}%
+ }
+% \end{macrocode}
+%
+% The |sudoku| environment simply calls the |sudoku-block|
+% environment inside a |center| environment.
+% \begin{macrocode}
+\newenvironment{sudoku}{%
+ \begin{center}%
+ \begin{sudoku-block}}{\end{sudoku-block}\end{center}}
+% \end{macrocode}
+%
+% \Finale
+%
+% \begin{figure}[b]
+% \begin{sudoku}
+% |2|5|8|7|3|6|9|4|1|.
+% |6|1|9|8|2|4|3|5|7|.
+% |4|3|7|9|1|5|2|6|8|.
+% |3|9|5|2|7|1|4|8|6|.
+% |7|6|2|4|9|8|1|3|5|.
+% |8|4|1|6|5|3|7|2|9|.
+% |1|8|4|3|6|9|5|7|2|.
+% |5|7|6|1|4|2|8|9|3|.
+% |9|2|3|5|8|7|6|1|4|.
+% \end{sudoku}
+% \caption{Solution for easy puzzle\label{easysolution}}
+% \end{figure}
+%
+% \begin{figure}[b]
+% \begin{sudoku}
+% |6|2|8|5|3|4|9|1|7|.
+% |5|1|9|8|7|2|4|3|6|.
+% |4|3|7|9|1|6|2|5|8|.
+% |8|6|5|2|4|7|1|9|3|.
+% |3|9|2|1|8|5|7|6|4|.
+% |7|4|1|6|9|3|5|8|2|.
+% |2|5|4|3|6|9|8|7|1|.
+% |1|7|6|4|5|8|3|2|9|.
+% |9|8|3|7|2|1|6|4|5|.
+% \end{sudoku}
+% \caption{Solution for difficult puzzle\label{difficultsolution}}
+% \end{figure}
+%
+\endinput
diff --git a/Master/texmf-dist/source/latex/sudoku/sudoku.ins b/Master/texmf-dist/source/latex/sudoku/sudoku.ins
new file mode 100644
index 00000000000..2ae2b8359bb
--- /dev/null
+++ b/Master/texmf-dist/source/latex/sudoku/sudoku.ins
@@ -0,0 +1,63 @@
+%% sudoku.ins
+%% Copyright 2005 Paul Abraham <paul.abraham@hotpop.com>
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3 of this license or (at your option) any
+%% later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of
+%% LaTeX version 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% This Current Maintainer of this work is Paul Abraham.
+%%
+%% This work consists of the files sudoku.dtx, sudoku.ins
+%% README, CHANGES and the derived file sudoku.sty.
+%%
+\input docstrip.tex
+\keepsilent
+\preamble
+
+This is a generated file.
+
+Copyright 2005 Paul Abraham <paul.abraham@hotpop.com>
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either
+version 1.3 of this license or (at your option) any
+later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3 or later is part of all distributions of
+LaTeX version 2003/12/01 or later.
+
+This work has the LPPL maintenance status "maintained".
+
+This Current Maintainer of this work is Paul Abraham.
+
+This work consists of the files sudoku.dtx, sudoku.ins
+README, CHANGES and the derived file sudoku.sty.
+
+\endpreamble
+
+\generate{\file{sudoku.sty}{\from{sudoku.dtx}{package}}}
+
+\obeyspaces
+\Msg{****************************************************}
+\Msg{* *}
+\Msg{* To finish the installation you have to move the *}
+\Msg{* following file into a directory searched by TeX: *}
+\Msg{* *}
+\Msg{* sudoku.sty *}
+\Msg{* *}
+\Msg{* To produce the documentation run the file *}
+\Msg{* sudoku.dtx through LaTeX. *}
+\Msg{* *}
+\Msg{* Happy TeXing! *}
+\Msg{* *}
+\Msg{****************************************************}
+
+\endbatchfile