diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/logicpuzzle/logicpuzzle.sty | 306 |
1 files changed, 306 insertions, 0 deletions
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 +%% <josef.kleber@gmx.de> +%% +%% 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 |