16-MEgal1/xwords.sty

90 lines
3.2 KiB
TeX

%%
%% This is file `xwords.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xwords.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Copyright (C) 2006 J{\accent 19 e}r{\accent 94 o}me Pl{\accent 94 u}t
%% (jerome.plut@normalesup.org)
%%
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 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.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{xwords}[2006/01/01 v1.0 Crosswords grid builder]
\newdimen\cwcell \cwcell 13pt
\newdimen\cwrule \cwrule .7pt
\let\cwlabelv=\Roman
\let\cwlabelh=\arabic
\countdef\c@cw@it=2
\begingroup
\catcode`\^^M=12\catcode`\#=12%
\gdef\crosswords{\begingroup%
\catcode`\^^M=12 \catcode`\#=12 \let\cw@nl\relax%
\setbox1=\copy\voidb@x \setbox0=\copy\voidb@x%
\c@cw@it=0 \count1=0 \count0=0 %
\afterassignment\cw@cell\let\cw@tok}%
\gdef\cw@cell{%
\def\next{\afterassignment\cw@cell\let\cw@tok}%
\ifx ^^M\cw@tok\cw@nl\def\cw@nl{\let\next\endcrosswords}\else%
\let\cw@nl\cw@line%
\ifx \\\cw@tok\cw@nl\let\cw@nl\relax\else%
\ifx .\cw@tok\cw@white\else%
\ifx #\cw@tok\cw@black\else%
\ifx *\cw@tok\cw@black\else%
\ifcat a\noexpand\cw@tok\cw@letter\cw@tok\else%
% Handle \begin{crosswords}...\end{crosswords}%
\ifx \end\cw@tok\let\next\cw@tok\else%
\let\next\endcrosswords\fi\fi\fi\fi\fi\fi\fi%
\next}%
\endgroup
\def\endcrosswords{\cw@end\box0\endgroup}%
\def\cw@end{%
\setbox1=\hbox{%
\c@cw@it=0 \loop \ifnum\c@cw@it<\count1 \advance\c@cw@it by 1
\hbox to \cwcell{\hss\cwlabelh{cw@it}\hss}\repeat}%
\dimen2=0pt \c@cw@it=0 \loop \ifnum\c@cw@it<\count0 \advance \c@cw@it by 1
\setbox2=\hbox{\cwlabelv{cw@it}}%
\ifdim\wd2>\dimen2 \dimen2=\wd2\fi
\repeat
\lineskip 0pt \advance\dimen2 by 2\cwrule
\setbox2=\vbox{\hsize \dimen2 \leftskip 0pt plus 1fil
\c@cw@it=0 \loop \ifnum\c@cw@it<\count0 \advance\c@cw@it by 1
\vbox to\cwcell{\vss\hbox to\dimen2{\hss
\cwlabelv{cw@it}\hskip 2\cwrule}\vss}%
\repeat}%
\setbox0=\vbox{%
\dimen0=\count0\cwcell \advance\dimen0\cwrule % height
\dimen1=\count1\cwcell \advance\dimen1\cwrule % width
\vtop to 0pt{\rlap{\vrule depth \dimen0 width \cwrule}\vss}%
\hrule height \cwrule width \dimen1
\moveright \cwrule \box0}%
\setbox0=\vbox{\moveright \wd2 \box1 \lineskip 2\cwrule
\hbox{\box2 \box0}}%
}%
\def\cw@line{\setbox0=\vbox{\unvbox0\box1}%
\ifnum \count1<\count2 \count1=\count2\fi \count2=0
\advance\count0 by 1}%
\def\cw@adv#1{\advance\count2 by1 \setbox1=\hbox{\unhbox1
\hbox to \cwcell{#1}}}%
\def\cw@black{\cw@adv{\vrule depth 0pt height \cwcell width \cwcell}}%
\def\cw@white{\cw@adv{\vrule depth 0pt height \cwrule width \cwcell
\hskip -\cwrule \vrule depth 0pt height \cwcell width \cwrule}}%
\def\cw@letter#1{\setbox1=\hbox{\unhbox1%
\rlap{\vbox to \cwcell {\vss\hbox to \cwcell{\hss#1\hss}\vss
\vskip \cwrule}}}%
\cw@white}%
\endinput
%%
%% End of file `xwords.sty'.