summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty')
-rw-r--r--Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty411
1 files changed, 312 insertions, 99 deletions
diff --git a/Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty b/Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty
index edb04f40e5f..74d6b42cbd5 100644
--- a/Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty
+++ b/Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty
@@ -19,7 +19,7 @@
%%
%% This work consists of all files listed in manifest.txt.
%%
-\ProvidesPackage{logicpuzzle}[2013/03/16 logicpuzzle.sty v1.2a - Josef Kleber (C) 2013]%
+\ProvidesPackage{logicpuzzle}[2013/04/05 logicpuzzle.sty v1.3 - Josef Kleber (C) 2013]%
%
\RequirePackage{xkeyval}%
\RequirePackage{ifthen}%
@@ -37,7 +37,8 @@
%
\newcounter{LP@counti}%
\newcounter{LP@countii}%
-\newcounter{LP@whiledo}%
+\newcounter{LP@whiledo@i}%
+\newcounter{LP@whiledo@ii}%
\newcounter{LP@count@ig@i}%
\newcounter{LP@count@ig@ii}%
\newcounter{LP@count@ig@iii}%
@@ -58,36 +59,113 @@
%
\newcommand*\LP@Pfive{.5}%
%
-\newcommand*\LP@ingrid[5]%
+% init
+%
+% #1 prefix
+\newcommand*\LP@init@counter[1]%
{%
- \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%
+ \newcounter{#1@rows}%
+ \newcounter{#1@columns}%
+ \setcounter{#1@rows}{\csname #1@rows\endcsname}%
+ \setcounter{#1@columns}{\csname #1@columns\endcsname}%
+ \stepcounter{#1@rows}%
+ \stepcounter{#1@columns}%
+}%
+%
+% #1 package prefix
+% #2 package
+% #3 option
+% #4 default
+\newcommand*\LP@define@key[4]%
+{%
+ \expandafter\gdef\csname#1@#3\endcsname{#4}%
+ \define@key{#2.sty}{#3}[#4]%
+ {%
+ \expandafter\gdef\csname#1@#3\endcsname{##1}%
+ }%
+ \define@key{#2}{#3}%
+ {%
+ \expandafter\def\csname#1@#3\endcsname{##1}%
+ }%
+}%
+%
+% #1 package prefix
+% #2 package
+% #3 default
+\newcommand*\LP@define@choicekey@fontsize[3]%
+{%
+ \expandafter\gdef\csname#1@fontsize\endcsname{\Large}%
+ \define@choicekey*{#2.sty}{fontsize}[\LP@dck@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[#3]%
+ {%
+ \ifcase\nr\relax%
+ \expandafter\gdef\csname#1@fontsize\endcsname{\tiny}%
+ \or%
+ \expandafter\gdef\csname#1@fontsize\endcsname{\scriptsize}%
+ \or%
+ \expandafter\gdef\csname#1@fontsize\endcsname{\footnotesize}%
+ \or%
+ \expandafter\gdef\csname#1@fontsize\endcsname{\small}%
+ \or%
+ \expandafter\gdef\csname#1@fontsize\endcsname{\normalsize}%
+ \or%
+ \expandafter\gdef\csname#1@fontsize\endcsname{\large}%
+ \or%
+ \expandafter\gdef\csname#1@fontsize\endcsname{\Large}%
+ \or%
+ \expandafter\gdef\csname#1@fontsize\endcsname{\LARGE}%
+ \or%
+ \expandafter\gdef\csname#1@fontsize\endcsname{\huge}%
+ \or%
+ \expandafter\gdef\csname#1@fontsize\endcsname{\Huge}%
+ \fi%
+ }%
+ \define@choicekey*{#2}{fontsize}[\LP@dck@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[#3]%
+ {%
+ \ifcase\nr\relax%
+ \expandafter\def\csname#1@fontsize\endcsname{\tiny}%
+ \or%
+ \expandafter\def\csname#1@fontsize\endcsname{\scriptsize}%
+ \or%
+ \expandafter\def\csname#1@fontsize\endcsname{\footnotesize}%
+ \or%
+ \expandafter\def\csname#1@fontsize\endcsname{\small}%
+ \or%
+ \expandafter\def\csname#1@fontsize\endcsname{\normalsize}%
+ \or%
+ \expandafter\def\csname#1@fontsize\endcsname{\large}%
+ \or%
+ \expandafter\def\csname#1@fontsize\endcsname{\Large}%
+ \or%
+ \expandafter\def\csname#1@fontsize\endcsname{\LARGE}%
+ \or%
+ \expandafter\def\csname#1@fontsize\endcsname{\huge}%
+ \or%
+ \expandafter\def\csname#1@fontsize\endcsname{\Huge}%
+ \fi%
+ }%
}%
%
+% colors
+%
+% #1 name
+% #2 rgb color
+\newcommand*\LP@definecolor[2]%
+{%
+ \definecolor{#1}{rgb}{#2}%
+}%
+%
+\LP@definecolor{LP@c@i}{.9,.9,.98}%
+\LP@definecolor{LP@c@ii}{.688,.932,.932}%
+\LP@definecolor{LP@c@iii}{.88,1,1}%
+\LP@definecolor{LP@c@iv}{1,1,.88}%
+\LP@definecolor{LP@c@v}{1,.855,.725}%
+\LP@definecolor{LP@c@vi}{.498,1,0}%
+\LP@definecolor{LP@c@vii}{.53,.808,.98}%
+\LP@definecolor{LP@c@viii}{.196,.804,.196}%
+\LP@definecolor{LP@c@ix}{1,.96,.932}%
+%
+% drawing grids
+%
% #1 grid x min
% #2 grid y min
% #3 grid x max
@@ -114,6 +192,8 @@
\draw[ultra thick] (1,10) -- (10,10);%
}%
%
+% drawing grid background
+%
% #1 grid x min
% #2 grid y min
% #3 grid x max
@@ -134,6 +214,38 @@
}%
}%
%
+% In the grid
+%
+\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 column
% #2 row
% #3 content
@@ -191,7 +303,7 @@
%
\newcommand*\setcolumn[2]%
{%
- \LP@setrowcontents{#2}{#1}{1}%
+ \LP@setcolumncontents{#2}{#1}{1}%
}%
%
\newcommand*\setcell[3]%
@@ -204,6 +316,173 @@
\LP@setcellcontent{#1}{#2}{\LP@fontsize#3}%
}%
%
+\newcommand*\setcolorrow[2]%
+{%
+ \setcounter{LP@counti}{1}%
+ \setcounter{LP@countii}{#1}%
+ \forcsvlist\LP@setcolorrow@i{#2}%
+}%
+%
+\newcommand*\LP@setcolorrow@i[1]%
+{%
+ \ifthenelse{\equal{#1}{0}}%
+ {%
+ \gdef\LP@HT@color{black}%
+ \begin{puzzlebackground}%
+ \fillcell{\arabic{LP@counti}}{\arabic{LP@countii}}%
+ \end{puzzlebackground}%
+ }%
+ {%
+ \expandafter\gdef\expandafter\LP@HT@color{LP@c@\romannumeral#1}%
+ \begin{puzzlebackground}%
+ \fillcell{\arabic{LP@counti}}{\arabic{LP@countii}}%
+ \end{puzzlebackground}%
+ \setcell{\arabic{LP@counti}}{\arabic{LP@countii}}{#1}%
+ }%
+ \stepcounter{LP@counti}%
+}%
+%
+\newcommand*\setcolorcolumn[2]%
+{%
+ \setcounter{LP@counti}{#1}%
+ \setcounter{LP@countii}{1}%
+ \forcsvlist\LP@setcolorcolumn@i{#2}%
+}%
+%
+\newcommand*\LP@setcolorcolumn@i[1]%
+{%
+ \ifthenelse{\equal{#1}{0}}%
+ {%
+ \gdef\LP@HT@color{black}%
+ \begin{puzzlebackground}%
+ \fillcell{\arabic{LP@counti}}{\arabic{LP@countii}}%
+ \end{puzzlebackground}%
+ }%
+ {%
+ \expandafter\gdef\expandafter\LP@HT@color{LP@c@\romannumeral#1}%
+ \begin{puzzlebackground}%
+ \fillcell{\arabic{LP@counti}}{\arabic{LP@countii}}%
+ \end{puzzlebackground}%
+ \setcell{\arabic{LP@counti}}{\arabic{LP@countii}}{#1}%
+ }%
+ \stepcounter{LP@countii}%
+}%
+%
+\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*\framearea[2]%
+{%
+ \draw[ultra thick,color=#1] #2;%
+}%
+%
+\newcommand*\fillarea[2]%
+{%
+ \draw[ultra thick,fill=#1] #2 ;%
+}%
+%
+\newcommand*\filldiagonals[1][yellow!20]%
+{%
+ \LP@set@LP@columns{\LP@env@prefix}%
+ \LP@set@LP@rows{\LP@env@prefix}%
+ \LP@set@LP@scale{\LP@env@prefix}%
+ \setcounter{LP@counti}{\LP@columns}%
+ \setcounter{LP@countii}{\LP@rows}%
+ \stepcounter{LP@counti}%
+ \stepcounter{LP@countii}%
+ \ifnum\value{LP@counti}=\value{LP@countii}%
+ \begin{puzzlebackground}%
+ \def\LP@color{#1}%
+ \setcounter{LP@whiledo@i}{1}%
+ \setcounter{LP@whiledo@ii}{\LP@rows}%
+ \whiledo{\value{LP@whiledo@i}<\value{LP@counti}}%
+ {%
+ \LP@setcellcontent{\arabic{LP@whiledo@i}}{\arabic{LP@whiledo@i}}{\LP@Block}%
+ \LP@setcellcontent{\arabic{LP@whiledo@i}}{\arabic{LP@whiledo@ii}}{\LP@Block}%
+ \stepcounter{LP@whiledo@i}%
+ \addtocounter{LP@whiledo@ii}{-1}%
+ }%
+ \end{puzzlebackground}%
+ \else%
+ \PackageError{\LP@package}%
+ {non quadratic grid (\filldiagonals)}%
+ {You tried to fill diagonals,\MessageBreak in a non quadratic grid (1,1) .. (\arabic{LP@counti},\arabic{LP@countii})\MessageBreak doesn't make sense!}%
+ \fi%
+}%
+%
+\newcommand*\framepuzzle[1][black]%
+{%
+ \LP@set@LP@columns{\LP@env@prefix}%
+ \LP@set@LP@rows{\LP@env@prefix}%
+ \setcounter{LP@counti}{\LP@columns}%
+ \setcounter{LP@countii}{\LP@rows}%
+ \stepcounter{LP@counti}%
+ \stepcounter{LP@countii}%
+ \draw[ultra thick,color=#1] (1,1)--(1,\arabic{LP@countii});%
+ \draw[ultra thick,color=#1] (1,\arabic{LP@countii})--(\arabic{LP@countii},\arabic{LP@countii});%
+ \draw[ultra thick,color=#1] (\arabic{LP@countii},\arabic{LP@countii})--(\arabic{LP@countii},1);%
+ \draw[ultra thick,color=#1] (\arabic{LP@countii},1)--(1,1);%
+}%
+%
+\newenvironment{puzzlebackground}%
+{%
+ \begin{pgfonlayer}{LPbackground}%
+}%
+{%
+ \end{pgfonlayer}%
+}%
+%
+\newenvironment{puzzleforeground}%
+{%
+ \begin{pgfonlayer}{LPforeground}%
+}%
+{%
+ \end{pgfonlayer}%
+}%
+%
+% around the grid
+%
\newcommand*\LP@bottomrow[1]%
{%
\LP@setrowcontents{#1}{1}{0}%
@@ -234,6 +513,8 @@
\LP@setcolumncontents{#1}{\csname the#2@columns\endcsname}{1}%
}%
%
+% Presentation
+%
\newcommand*\titleformat[1]%
{%
\renewcommand*\LP@titleformat{#1}%
@@ -265,49 +546,7 @@
%
\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}%
-}%
+% get package options with prefix
%
\newcommand*\LP@set@LP@scale[1]%
{%
@@ -350,30 +589,4 @@
\gdef\LP@package{#1}%
}%
%
-\newcommand*\framearea[2]%
-{%
- \draw[ultra thick,color=#1] #2;%
-}%
-%
-\newcommand*\fillarea[2]%
-{%
- \draw[ultra thick,fill=#1] #2 ;%
-}%
-%
-\newenvironment{puzzlebackground}%
-{%
- \begin{pgfonlayer}{LPbackground}%
-}%
-{%
- \end{pgfonlayer}%
-}%
-%
-\newenvironment{puzzleforeground}%
-{%
- \begin{pgfonlayer}{LPforeground}%
-}%
-{%
- \end{pgfonlayer}%
-}%
-%
\endinput% \ No newline at end of file