From 4f2468f5b9802ecb8d04a49657a9343139044d2a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 2 Mar 2013 00:08:06 +0000 Subject: logicpuzzle (1mar13) git-svn-id: svn://tug.org/texlive/trunk@29255 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/latex/logicpuzzle/battleship.sty | 436 +++++++++++++++++++++ .../texmf-dist/tex/latex/logicpuzzle/bokkusu.sty | 241 ++++++++++++ .../tex/latex/logicpuzzle/logicpuzzle.sty | 306 +++++++++++++++ 3 files changed, 983 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/logicpuzzle/battleship.sty create mode 100644 Master/texmf-dist/tex/latex/logicpuzzle/bokkusu.sty create mode 100644 Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty (limited to 'Master/texmf-dist/tex/latex/logicpuzzle') diff --git a/Master/texmf-dist/tex/latex/logicpuzzle/battleship.sty b/Master/texmf-dist/tex/latex/logicpuzzle/battleship.sty new file mode 100644 index 00000000000..af5715ab8a1 --- /dev/null +++ b/Master/texmf-dist/tex/latex/logicpuzzle/battleship.sty @@ -0,0 +1,436 @@ +%% +%% Copyright (C) 2013 by: +%% Josef Kleber +%% +%% +%% This file 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 "author-maintained". +%% +%% The Current Maintainer of this work is Josef Kleber. +%% +%% This work consists of all files listed in manifest.txt. +%% +% for more infos see: +% http://en.wikipedia.org/wiki/Battleship_%28puzzle%29 +% http://de.wikipedia.org/wiki/Bimaru +% +\ProvidesPackage{battleship}[2013/02/28 battleship.sty v1.3 - Josef Kleber (C) 2013]% +% +\RequirePackage{logicpuzzle}% +\tikzstyle{island} = [fill=yellow!30,draw, decorate, decoration={random steps,segment length=2.7pt,amplitude=1.7pt}]% +% +% options +\newcommand*\BS@width{6cm}% +\newcommand*\BS@fontsize\Large% +\newcommand*\BS@rows{5}% +\newcommand*\BS@columns{5}% +\newcommand*\BS@scale{1}% +\newcommand*\BS@bgcolor{}% +\newcommand*\BS@shipcolor{green}% +\newcommand*\BS@title{}% +\newcommand*\BS@titleindent{0.75cm}% +\newcommand*\BS@titlewidth{5.15cm}% +\newcommand*\BS@cvoffset{-23pt}% +\newcommand*\BS@SB@indent{0.75cm}% +\newcommand*\BS@SB@width{5.15cm}% +\newcommand*\BS@SB@shipboxscale{1}% +% +\newcounter{BS@rows}% +\newcounter{BS@columns}% +% +\setcounter{BS@rows}{\BS@rows}% +\setcounter{BS@columns}{\BS@columns}% +\stepcounter{BS@rows}% +\stepcounter{BS@columns}% +% +\define@key{battleship.sty}{rows}[5]% +{% + \renewcommand*\BS@rows{#1}% +}% +% +\define@key{battleship.sty}{columns}[5]% +{% + \renewcommand*\BS@columns{#1}% +}% +% +\define@key{battleship.sty}{shipcolor}[green]% +{% + \renewcommand*\BS@shipcolor{#1}% +}% +% +\define@key{battleship.sty}{scale}[1]% +{% + \renewcommand*\BS@scale{#1}% +}% +% +\define@key{battleship.sty}{counterstyle}[none]% +{% + \renewcommand*\LP@counterstyle{#1}% +}% +% +\define@key{battleship.sty}{bgcolor}[]% +{% + \renewcommand*\BS@bgcolor{#1}% +}% +% +\define@choicekey*{battleship.sty}{fontsize}[\BS@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]% +{% + \ifcase\nr\relax% + \renewcommand*\BS@fontsize{\tiny}% + \or% + \renewcommand*\BS@fontsize{\scriptsize}% + \or% + \renewcommand*\BS@fontsize{\footnotesize}% + \or% + \renewcommand*\BS@fontsize{\small}% + \or% + \renewcommand*\BS@fontsize{\normalsize}% + \or% + \renewcommand*\BS@fontsize{\large}% + \or% + \renewcommand*\BS@fontsize{\Large}% + \or% + \renewcommand*\BS@fontsize{\LARGE}% + \or% + \renewcommand*\BS@fontsize{\huge}% + \or% + \renewcommand*\BS@fontsize{\Huge}% + \fi% +}% +% +\define@key{battleship.sty}{width}[6cm]% +{% + \renewcommand*\BS@width{#1}% +}% +% +\define@key{battleship.sty}{title}[]% +{% + \renewcommand*\BS@title{#1}% +}% +% +\define@key{battleship.sty}{cvoffset}[-23pt]% +{% + \renewcommand*\BS@cvoffset{#1}% +}% +% +\define@key{battleship.sty}{titleindent}[0.75cm]% +{% + \renewcommand*\BS@titleindent{#1}% +}% +% +\define@key{battleship.sty}{titlewidth}[5.15cm]% +{% + \renewcommand*\BS@titlewidth{#1}% +}% +% +\define@key{battleship.sty}{sbindent}[0.75cm]% +{% + \renewcommand*\BS@SB@indent{#1}% +}% +% +\define@key{battleship.sty}{sbwidth}[5.15cm]% +{% + \renewcommand*\BS@SB@width{#1}% +}% +% +\define@key{battleship.sty}{sbshipscale}[1]% +{% + \renewcommand*\BS@SB@shipboxscale{#1}% +}% +% +\define@key{battleship}{rows}% +{% + \renewcommand*\BS@rows{#1}% +}% +% +\define@key{battleship}{columns}% +{% + \renewcommand*\BS@columns{#1}% +}% +% +\define@key{battleship}{shipcolor}% +{% + \renewcommand*\BS@shipcolor{#1}% +}% +% +\define@key{battleship}{scale}% +{% + \renewcommand*\BS@scale{#1}% +}% +% +\define@key{battleship}{bgcolor}% +{% + \renewcommand*\BS@bgcolor{#1}% +}% +% +\define@key{battleship}{counterstyle}% +{% + \renewcommand*\LP@counterstyle{#1}% +}% +% +\define@choicekey*{battleship}{fontsize}[\BS@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]% +{% + \ifcase\nr\relax% + \renewcommand*\BS@fontsize{\tiny}% + \or% + \renewcommand*\BS@fontsize{\scriptsize}% + \or% + \renewcommand*\BS@fontsize{\footnotesize}% + \or% + \renewcommand*\BS@fontsize{\small}% + \or% + \renewcommand*\BS@fontsize{\normalsize}% + \or% + \renewcommand*\BS@fontsize{\large}% + \or% + \renewcommand*\BS@fontsize{\Large}% + \or% + \renewcommand*\BS@fontsize{\LARGE}% + \or% + \renewcommand*\BS@fontsize{\huge}% + \or% + \renewcommand*\BS@fontsize{\Huge}% + \fi% +}% +% +\define@key{battleship}{width}% +{% + \renewcommand*\BS@width{#1}% +}% +% +\define@key{battleship}{title}% +{% + \renewcommand*\BS@title{#1}% +}% +% +\define@key{battleship}{cvoffset}% +{% + \renewcommand*\BS@cvoffset{#1}% +}% +% +\define@key{battleship}{titleindent}% +{% + \renewcommand*\BS@titleindent{#1}% +}% +% +\define@key{battleship}{titlewidth}% +{% + \renewcommand*\BS@titlewidth{#1}% +}% +% +\define@key{battleship}{sbindent}% +{% + \renewcommand*\BS@SB@indent{#1}% +}% +% +\define@key{battleship}{sbwidth}% +{% + \renewcommand*\BS@SB@width{#1}% +}% +% +\define@key{battleship}{sbshipscale}% +{% + \renewcommand*\BS@SB@shipboxscale{#1}% +}% +% +\ExecuteOptionsX{rows,columns,width,fontsize,shipcolor,scale,bgcolor,cvoffset,counterstyle,title,titleindent,titlewidth,sbindent,sbwidth,sbshipscale}% +% +\ProcessOptionsX\relax% +% +\gdef\BS@shipbox{}% +% +\newcommand*\Ship{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor] (0,0) circle (1);}% +\newcommand*\ShipC{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor] (0,0)--(0,2)--(2,2)--(2,0)--cycle;}% +\newcommand*\ShipT{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor](2,1)--(2,0)--(0,0)--(0,1) arc (180:0:1);}% +\newcommand*\ShipB{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor](2,1)--(2,2)--(0,2)--(0,1) arc (180:360:1);}% +\newcommand*\ShipL{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}% +\newcommand*\ShipR{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}% +\newcommand*\Island{\tikz[scale=\BS@scale]\draw[scale=.36,island] (0,0) rectangle (2,2);}% +\newcommand*\Water{\tikz[scale=\BS@scale]\draw[scale=.36,fill,blue!40] (1,1) circle (0.2);}% +% versions for \shipbox without second scale +\newcommand*\@Ship{\tikz\draw[scale=.144,fill=\BS@shipcolor] (0,0) circle (1);}% +\newcommand*\@ShipC{\tikz\draw[scale=.144,fill=\BS@shipcolor] (0,0)--(0,2)--(2,2)--(2,0)--cycle;}% +\newcommand*\@ShipT{\tikz\draw[scale=.144,fill=\BS@shipcolor](2,1)--(2,0)--(0,0)--(0,1) arc (180:0:1);}% +\newcommand*\@ShipB{\tikz\draw[scale=.144,fill=\BS@shipcolor](2,1)--(2,2)--(0,2)--(0,1) arc (180:360:1);}% +\newcommand*\@ShipL{\tikz\draw[scale=.144,fill=\BS@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}% +\newcommand*\@ShipR{\tikz\draw[scale=.144,fill=\BS@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}% +% +\newcommand*\BS@printship[1]% +{% + \ifthenelse{\equal{#1}{1}}{\scalebox{\BS@SB@shipboxscale}{\@Ship}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{2}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{3}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{4}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{5}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{6}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{7}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{8}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{9}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% + \ifthenelse{\equal{#1}{10}}{\scalebox{\BS@SB@shipboxscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}% +}% +% +\newcommand*\BS@printshipbox[1]% +{% \expandafters needed because csv list is stored in macro + \expandafter\forcsvlist\expandafter\BS@printship\expandafter{#1}% +}% +% +\newcommand*\shipH[1]% +{% + \LP@setrowcontents{#1}{1}{\value{BS@rows}}% +}% +% +\newcommand*\shipV[1]% +{% + \LP@setcolumncontents{#1}{0}{1}% +}% +% +\newcommand*\placesegment[3]% +{% + \LP@ingrid{#1}{#2}{\BS@columns}{\BS@rows}{battleship}% + \LP@setcellcontent{#1}{#2}{#3}% +}% +% +\let\ship\placesegment% +% +\newcommand*\placeisland[2]% +{% + \LP@ingrid{#1}{#2}{\BS@columns}{\BS@rows}{battleship}% + \LP@setcellcontent{#1}{#2}{\Island}% +}% +% +\newcommand*\placewater[2]% +{% + \LP@ingrid{#1}{#2}{\BS@columns}{\BS@rows}{battleship}% + \LP@setcellcontent{#1}{#2}{\Water}% +}% +% +\newcommand*\shipbox[2][]% +{% + \setkeys{shipbox}{#1}% + \gdef\BS@shipbox{#2}% +}% +% +\newcommand*\placeship[4]% +{% + \setcounter{LP@counti}{#4}% length + \ifnum\value{LP@counti}<1% + \PackageError{battleship}% + {ship length < 1}% + {The length of your ship should be at least 1}% + \fi% + \ifnum\value{LP@counti}>10% + \PackageError{battleship}% + {ship length > 10}% + {The supported max length of ships is 10!}% + \fi% + \ifnum\value{LP@counti}=1% + \placesegment{#2}{#3}{\Ship}% + \else% + \setcounter{LP@whiledo}{\value{LP@counti}}% + \addtocounter{LP@whiledo}{-2}% length of middle ship + \ifthenelse{\equal{#1}{V}}% + {% + \placesegment{#2}{#3}{\ShipB}% + \setcounter{LP@countii}{#3}% + \whiledo{\value{LP@whiledo}>0}% + {% + \addtocounter{LP@whiledo}{-1}% + \stepcounter{LP@countii}% + \placesegment{#2}{\theLP@countii}{\ShipC}% + }% + \stepcounter{LP@countii}% + \placesegment{#2}{\theLP@countii}{\ShipT}% + }% + {% + \ifthenelse{\equal{#1}{H}}% + {% + \placesegment{#2}{#3}{\ShipL}% + \setcounter{LP@counti}{#2}% + \whiledo{\value{LP@whiledo}>0}% + {% + \addtocounter{LP@whiledo}{-1}% + \stepcounter{LP@counti}% + \placesegment{\theLP@counti}{#3}{\ShipC}% + }% + \stepcounter{LP@counti}% + \placesegment{\theLP@counti}{#3}{\ShipR}% + }% + {\PackageError{battleship}% + {invalid direction (H/V)}% + {You can place your ship only\MessageBreak% + horizontally (H) or vertically (V)!}% + }% + }% + \fi% +}% +% +\newcommand*\battleshipsetup[1]% +{% + \setkeys{battleship.sty}{#1}% +}% +% +\newcommand{\classicgame}[1]% +{% + \begin{center}% + \begin{battleship}[rows=10,columns=10,width=6.5cm,title=Me,sbindent=0.65cm,titleindent=0.55cm,titlewidth=5.7cm,sbwidth=5.7cm,scale=0.59,fontsize=normalsize]% + \shipV{J,I,H,G,F,E,D,C,B,A}% + \shipH{1,2,3,4,5,6,7,8,9,10}% + \shipbox{#1}% + \end{battleship}% + \hspace{1cm}% + \begin{battleship}[rows=10,columns=10,width=6.5cm,title=Enemy,sbindent=0.65cm,titleindent=0.55cm,titlewidth=5.7cm,sbwidth=5.7cm,scale=0.59,fontsize=normalsize]% + \shipV{J,I,H,G,F,E,D,C,B,A}% + \shipH{1,2,3,4,5,6,7,8,9,10}% + \end{battleship}% + \end{center}% + \par\vspace{1cm}% + \begin{center}% + \begin{battleship}[rows=10,columns=10,width=6.5cm,title=Me,sbindent=0.65cm,titleindent=0.55cm,titlewidth=5.7cm,sbwidth=5.7cm,scale=0.59,fontsize=normalsize]% + \shipV{J,I,H,G,F,E,D,C,B,A}% + \shipH{1,2,3,4,5,6,7,8,9,10}% + \shipbox{#1}% + \end{battleship}% + \hspace{1cm}% + \begin{battleship}[rows=10,columns=10,width=6.5cm,title=Enemy,sbindent=0.65cm,titleindent=0.55cm,titlewidth=5.7cm,sbwidth=5.7cm,scale=0.59,fontsize=normalsize]% + \shipV{J,I,H,G,F,E,D,C,B,A}% + \shipH{1,2,3,4,5,6,7,8,9,10}% + \end{battleship}% + \end{center}% +}% +% +\newenvironment{battleship}[1][]% +{% + \setkeys{battleship}{#1}% + \LP@set@package{battleship}% + \LP@set@env@prefix{BS}% + \shipbox{}% clear shipbox + \setcounter{BS@rows}{\BS@rows}% + \setcounter{BS@columns}{\BS@columns}% + \stepcounter{BS@rows}% + \stepcounter{BS@columns}% + \begin{minipage}[t]{\BS@width}% + \ifthenelse{\equal{\BS@title}{}}% + {\par\enspace\par}% empty + {\enspace\par\noindent\hspace{\BS@titleindent}\parbox{\BS@titlewidth}{\strut\LP@titleformat\BS@title}\vspace{3mm}\par}% + \begin{tikzpicture}[scale=\BS@scale]% + \LP@drawbackground{1}{1}{\BS@columns}{\BS@rows}{\BS@bgcolor}% + \LP@drawgrid{1}{1}{\BS@columns}{\BS@rows}{1cm}% +}% +{% + \end{tikzpicture}% + \LP@drawcounter{\LP@counterstyle}% + \par\hbadness=10000\medskip\noindent\hspace{\BS@SB@indent}\begin{minipage}{\BS@SB@width}{\hbadness=10000\RaggedRight\BS@printshipbox{\BS@shipbox}}\end{minipage}% + \stepcounter{LP@puzzlecounter}% + \end{minipage}% +}% +% +\endinput% \ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/logicpuzzle/bokkusu.sty b/Master/texmf-dist/tex/latex/logicpuzzle/bokkusu.sty new file mode 100644 index 00000000000..27857baaedc --- /dev/null +++ b/Master/texmf-dist/tex/latex/logicpuzzle/bokkusu.sty @@ -0,0 +1,241 @@ +%% +%% Copyright (C) 2013 by: +%% Josef Kleber +%% +%% +%% This file 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 "author-maintained". +%% +%% The Current Maintainer of this work is Josef Kleber. +%% +%% This work consists of all files listed in manifest.txt. +%% +% +\ProvidesPackage{bokkusu}[2013/02/28 bokkusu.sty v1.0 - Josef Kleber (C) 2013]% +% +\RequirePackage{logicpuzzle}% +% +% options +\newcommand*\BK@width{6.7cm}% +\newcommand*\BK@fontsize\Large% +\newcommand*\BK@rows{5}% +\newcommand*\BK@columns{5}% +\newcommand*\BK@scale{1}% +\newcommand*\BK@color{black}% +\newcommand*\BK@bgcolor{}% +\newcommand*\BK@cvoffset{-23pt}% +\newcommand*\BK@title{}% +\newcommand*\BK@titleindent{0.75cm}% +\newcommand*\BK@titlewidth{5.85cm}% +% +\newcounter{BK@rows}% +\newcounter{BK@columns}% +% +\setcounter{BK@rows}{\BK@rows}% +\setcounter{BK@columns}{\BK@columns}% +\stepcounter{BK@rows}% +\stepcounter{BK@columns}% +% +\define@key{bokkusu.sty}{rows}[5]% +{% + \renewcommand*\BK@rows{#1}% +}% +% +\define@key{bokkusu.sty}{columns}[5]% +{% + \renewcommand*\BK@columns{#1}% +}% +% +\define@key{bokkusu.sty}{scale}[1]% +{% + \renewcommand*\BK@scale{#1}% +}% +% +\define@key{bokkusu.sty}{counterstyle}[none]% +{% + \renewcommand*\LP@counterstyle{#1}% +}% +% +\define@key{bokkusu.sty}{color}[black]% +{% + \renewcommand*\BK@color{#1}% +}% +% +\define@key{bokkusu.sty}{bgcolor}[]% +{% + \renewcommand*\BK@bgcolor{#1}% +}% +% +\define@choicekey*{bokkusu.sty}{fontsize}[\BK@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]% +{% + \ifcase\nr\relax% + \renewcommand*\BK@fontsize{\tiny}% + \or% + \renewcommand*\BK@fontsize{\scriptsize}% + \or% + \renewcommand*\BK@fontsize{\footnotesize}% + \or% + \renewcommand*\BK@fontsize{\small}% + \or% + \renewcommand*\BK@fontsize{\normalsize}% + \or% + \renewcommand*\BK@fontsize{\large}% + \or% + \renewcommand*\BK@fontsize{\Large}% + \or% + \renewcommand*\BK@fontsize{\LARGE}% + \or% + \renewcommand*\BK@fontsize{\huge}% + \or% + \renewcommand*\BK@fontsize{\Huge}% + \fi% +}% +% +\define@key{bokkusu.sty}{width}[6.7cm]% +{% + \renewcommand*\BK@width{#1}% +}% +% +\define@key{bokkusu.sty}{title}[]% +{% + \renewcommand*\BK@title{#1}% +}% +% +\define@key{bokkusu.sty}{cvoffset}[-38pt]% +{% + \renewcommand*\BK@cvoffset{#1}% +}% +% +\define@key{bokkusu.sty}{titleindent}[0.75cm]% +{% + \renewcommand*\BK@titleindent{#1}% +}% +% +\define@key{bokkusu.sty}{titlewidth}[5.85cm]% +{% + \renewcommand*\BK@titlewidth{#1}% +}% +% +\define@key{bokkusu}{rows}% +{% + \renewcommand*\BK@rows{#1}% +}% +% +\define@key{bokkusu}{columns}% +{% + \renewcommand*\BK@columns{#1}% +}% +% +\define@key{bokkusu}{scale}% +{% + \renewcommand*\BK@scale{#1}% +}% +% +\define@key{bokkusu}{color}% +{% + \renewcommand*\BK@color{#1}% +}% +% +\define@key{bokkusu}{bgcolor}% +{% + \renewcommand*\BK@bgcolor{#1}% +}% +% +\define@key{bokkusu}{counterstyle}% +{% + \renewcommand*\LP@counterstyle{#1}% +}% +% +\define@choicekey*{bokkusu}{fontsize}[\BK@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]% +{% + \ifcase\nr\relax% + \renewcommand*\BK@fontsize{\tiny}% + \or% + \renewcommand*\BK@fontsize{\scriptsize}% + \or% + \renewcommand*\BK@fontsize{\footnotesize}% + \or% + \renewcommand*\BK@fontsize{\small}% + \or% + \renewcommand*\BK@fontsize{\normalsize}% + \or% + \renewcommand*\BK@fontsize{\large}% + \or% + \renewcommand*\BK@fontsize{\Large}% + \or% + \renewcommand*\BK@fontsize{\LARGE}% + \or% + \renewcommand*\BK@fontsize{\huge}% + \or% + \renewcommand*\BK@fontsize{\Huge}% + \fi% +}% +% +\define@key{bokkusu}{width}% +{% + \renewcommand*\BK@width{#1}% +}% +% +\define@key{bokkusu}{title}% +{% + \renewcommand*\BK@title{#1}% +}% +% +\define@key{bokkusu}{cvoffset}% +{% + \renewcommand*\BK@cvoffset{#1}% +}% +% +\define@key{bokkusu}{titleindent}% +{% + \renewcommand*\BK@titleindent{#1}% +}% +% +\define@key{bokkusu}{titlewidth}% +{% + \renewcommand*\BK@titlewidth{#1}% +}% +% +\ExecuteOptionsX{rows,columns,width,fontsize,scale,color,bgcolor,cvoffset,counterstyle,title,titleindent,titlewidth}% +% +\ProcessOptionsX\relax% +% +\newcommand*\bokkususetup[1]% +{% + \setkeys{bokkusu.sty}{#1}% +}% +% +\newenvironment{bokkusu}[1][]% +{% + \setkeys{bokkusu}{#1}% + \LP@set@package{bokkusu}% + \LP@set@env@prefix{BK}% + \setcounter{BK@rows}{\BK@rows}% + \setcounter{BK@columns}{\BK@columns}% + \stepcounter{BK@rows}% + \stepcounter{BK@columns}% + \begin{minipage}[t]{\BK@width}% + \ifthenelse{\equal{\BK@title}{}}% + {\par\enspace\par}% empty + {\enspace\par\noindent\hspace{\BK@titleindent}\parbox{\BK@titlewidth}{\strut\LP@titleformat\BK@title}\vspace{3mm}\par}% + \begin{tikzpicture}[scale=\BK@scale]% + \LP@drawbackground{1}{1}{\BK@columns}{\BK@rows}{\BK@bgcolor}% + \LP@drawgrid{1}{1}{\BK@columns}{\BK@rows}{1cm}% +}% +{% + \end{tikzpicture}% + \LP@drawcounter{\LP@counterstyle}% + \stepcounter{LP@puzzlecounter}% + \end{minipage}% +}% +% +\endinput% \ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty b/Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty new file mode 100644 index 00000000000..47fb93c326a --- /dev/null +++ b/Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty @@ -0,0 +1,306 @@ +%% +%% Copyright (C) 2013 by: +%% Josef Kleber +%% +%% +%% This file 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 "author-maintained". +%% +%% The Current Maintainer of this work is Josef Kleber. +%% +%% This work consists of all files listed in manifest.txt. +%% +\ProvidesPackage{logicpuzzle}[2013/02/28 logicpuzzle.sty v1.1 - Josef Kleber (C) 2013]% +% +\RequirePackage{xkeyval}% +\RequirePackage{ifthen}% +\RequirePackage{ragged2e}% +\RequirePackage{etoolbox}% +\RequirePackage{marginnote}% +\RequirePackage{tikz}% +\usetikzlibrary{decorations.pathmorphing}% +% +\newcounter{LP@counti}% +\newcounter{LP@countii}% +\newcounter{LP@whiledo}% +\newcounter{LP@count@ig@i}% +\newcounter{LP@count@ig@ii}% +\newcounter{LP@count@ig@iii}% +\newcounter{LP@count@ig@iv}% +\newcounter{LP@puzzlecounter}% +\setcounter{LP@puzzlecounter}{1}% +% +\newcommand*\LP@counterstyle{none}% +\newcommand*\LP@titleformat{}% +\gdef\LP@env@prefix{}% +\gdef\LP@package{}% +\gdef\LP@rows{}% +\gdef\LP@columns{}% +\gdef\LP@scale{1}% +\gdef\LP@color{black}% +\gdef\LP@cvoffset{0pt}% +% +\newcommand*\LP@Pfive{.5}% +% +\newcommand*\LP@ingrid[5]% +{% + \setcounter{LP@count@ig@i}{#1}% column + \setcounter{LP@count@ig@ii}{#2}% row + \setcounter{LP@count@ig@iii}{#3}% max column + \setcounter{LP@count@ig@iv}{#4}% max row + %#5 style + % + \ifnum\value{LP@count@ig@i}<1% + \PackageError{#5}% + {element outside of the grid}% + {You tried to set an element at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (#3,#4)}% + \fi% + \ifnum\value{LP@count@ig@ii}<1% + \PackageError{#5}% + {element outside of the grid}% + {You tried to set an element at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (#3,#4)}% + \fi% + \ifnum\value{LP@count@ig@i}>\value{LP@count@ig@iii}% + \PackageError{#5}% + {element outside of the grid}% + {You tried to set an element at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (#3,#4)}% + \fi% + \ifnum\value{LP@count@ig@ii}>\value{LP@count@ig@iv}% + \PackageError{#5}% + {element outside of the grid}% + {You tried to set an element at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (#3,#4)}% + \fi% +}% +% +% #1 grid x min +% #2 grid y min +% #3 grid x max +% #4 grid y max +% #5 step +\newcommand*\LP@drawgrid[5]% +{% + \setcounter{LP@counti}{#3}% max column + \setcounter{LP@countii}{#4}% max row + \stepcounter{LP@counti}% + \stepcounter{LP@countii}% + \draw[step=#5] (#1,#2) grid (\value{LP@counti},\value{LP@countii});% +}% +% +% #1 grid x min +% #2 grid y min +% #3 grid x max +% #4 grid y max +% #5 bgcolor +\newcommand*\LP@drawbackground[5]% +{% + \ifthenelse{\equal{#5}{}}% + {}% no bgcolor + {% + \setcounter{LP@counti}{#3}% max column + \setcounter{LP@countii}{#4}% max row + \stepcounter{LP@counti}% + \stepcounter{LP@countii}% + \draw[fill=#5] (#1,#2) rectangle (\value{LP@counti},\value{LP@countii});% + }% +}% +% +% #1 column +% #2 row +% #3 content +\newcommand*\LP@setcellcontent[3]% +{% + \node at (#1\LP@Pfive,#2\LP@Pfive){#3};% +}% +% +% #1 csv list +% #2 column +% #3 row +\newcommand*\LP@setrowcontents[3]% +{% + \setcounter{LP@counti}{#2}% + \setcounter{LP@countii}{#3}% + \forcsvlist\LP@setrowcontents@i{#1}{\LP@env@prefix}% +}% +% +\newcommand*\LP@setrowcontents@i[1]% +{% + \LP@setrowcontents@ii{#1}{\LP@env@prefix}% +}% +% +\newcommand*\LP@setrowcontents@ii[2]% +{% + \LP@setcellcontent{\arabic{LP@counti}}{\arabic{LP@countii}}{\csname #2@fontsize\endcsname#1}% + \stepcounter{LP@counti}% +}% +% +% #1 csv list +% #2 column +% #3 row +\newcommand*\LP@setcolumncontents[3]% +{% + \setcounter{LP@counti}{#2}% + \setcounter{LP@countii}{#3}% + \forcsvlist\LP@setcolumncontents@i{#1}% +}% +% +\newcommand*\LP@setcolumncontents@i[1]% +{% + \LP@setcolumncontents@ii{#1}{\LP@env@prefix}% +}% +% +\newcommand*\LP@setcolumncontents@ii[2]% +{% + \LP@setcellcontent{\arabic{LP@counti}}{\arabic{LP@countii}}{\csname #2@fontsize\endcsname#1}% + \stepcounter{LP@countii}% +}% +% +\newcommand*\valueH[1]% +{% + \LP@setrowcontents{#1}{1}{0}% +}% +% +\newcommand*\valueV[1]% +{% + \LP@setcolumncontents{#1}{0}{1}% +}% +% +\newcommand*\sumH[1]% +{% + \sumH@i{#1}{\LP@env@prefix}% +}% +% +\newcommand*\sumH@i[2]% +{% + \LP@setrowcontents{#1}{1}{\csname the#2@rows\endcsname}% +}% +% +\newcommand*\sumV[1]% +{% + \sumV@i{#1}{\LP@env@prefix}% +}% +% +\newcommand*\sumV@i[2]% +{% + \LP@setcolumncontents{#1}{\csname the#2@columns\endcsname}{1}% +}% +% +\newcommand*\titleformat[1]% +{% + \renewcommand*\LP@titleformat{#1}% +}% +\titleformat{\centering\Large\color{blue}}% +% +\newcommand*\puzzlecounter{\theLP@puzzlecounter}% +% +\newcommand*\setpuzzlecounter[1]% +{% + \setcounter{LP@puzzlecounter}{#1}% +}% +% +% #1 counterstyle +\newcommand*\LP@drawcounter[1]% +{% + \LP@set@LP@cvoffset{\LP@env@prefix}% + \csname LP@cs@#1\endcsname% +}% +% +\newcommand*{\definecounterstyle}[2]% +{% + \expandafter\gdef\csname LP@cs@#1\endcsname{#2}% +}% +% +\definecounterstyle{none}{}% +\definecounterstyle{left}{\begingroup\reversemarginpar\marginnote{\tikz\node[shape=rectangle,fill=yellow!40,inner sep=7pt,draw,rounded corners=3pt,thick]{\Huge\puzzlecounter};}[\LP@cvoffset]\endgroup}% +\definecounterstyle{right}{\marginnote{\tikz\node[shape=rectangle,fill=yellow!40,inner sep=7pt,draw,rounded corners=3pt,thick]{\Huge\puzzlecounter};}[\LP@cvoffset]}% +% +\newcommand*\LP@Block{\tikz[scale=\LP@scale]\draw[fill=\LP@color] (0,0) rectangle (1,1);}% +% +\newcommand*\fillcell[2]% +{% + \LP@set@LP@scale{\LP@env@prefix}% + \LP@set@LP@color{\LP@env@prefix}% + \LP@set@LP@rows{\LP@env@prefix}% + \LP@set@LP@columns{\LP@env@prefix}% + \LP@ingrid{#1}{#2}{\LP@columns}{\LP@rows}{\LP@package}% + \LP@setcellcontent{#1}{#2}{\LP@Block}% +}% +% +% #1 row +% #2 csv list +\newcommand*\fillrow[2]% +{% + \setcounter{LP@counti}{1}% + \setcounter{LP@countii}{#1}% + \forcsvlist\LP@fillrow@i{#2}% +}% +% +\newcommand*\LP@fillrow@i[1]% +{% + \ifthenelse{\equal{#1}{1}}% + {\fillcell{\arabic{LP@counti}}{\arabic{LP@countii}}}% + {}% + \stepcounter{LP@counti}% +}% +% +% #1 column +% #2 csv list +\newcommand*\fillcolumn[2]% +{% + \setcounter{LP@counti}{#1}% + \setcounter{LP@countii}{1}% + \forcsvlist\LP@fillcolumn@i{#2}% +}% +% +\newcommand*\LP@fillcolumn@i[1]% +{% + \ifthenelse{\equal{#1}{1}}% + {\fillcell{\arabic{LP@counti}}{\arabic{LP@countii}}}% + {}% + \stepcounter{LP@countii}% +}% +% +\newcommand*\LP@set@LP@scale[1]% +{% + \expandafter\xdef\expandafter\LP@scale{\csname #1@scale\endcsname}% +}% +% +\newcommand*\LP@set@LP@color[1]% +{% + \expandafter\xdef\expandafter\LP@color{\csname #1@color\endcsname}% +}% +% +\newcommand*\LP@set@LP@rows[1]% +{% + \expandafter\xdef\expandafter\LP@rows{\csname #1@rows\endcsname}% +}% +% +\newcommand*\LP@set@LP@columns[1]% +{% + \expandafter\xdef\expandafter\LP@columns{\csname #1@columns\endcsname}% +}% +% +\newcommand*\LP@set@LP@cvoffset[1]% +{% + \expandafter\xdef\expandafter\LP@cvoffset{\csname #1@cvoffset\endcsname}% +}% +% +\newcommand*\LP@set@env@prefix[1]% +{% + \gdef\LP@env@prefix{#1}% +}% +% +\newcommand*\LP@set@package[1]% +{% + \gdef\LP@package{#1}% +}% +% +\endinput% \ No newline at end of file -- cgit v1.2.3