summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-03-25 23:28:40 +0000
committerKarl Berry <karl@freefriends.org>2013-03-25 23:28:40 +0000
commitd31e714616b0027159d7748cb2d8f79ae1dbff26 (patch)
tree4063264d8dee8cf463d5feaaeaf1c13271ddd3a0 /Master/texmf-dist/tex/latex
parent87e15cfee2b1cfdc7c288a09bb189a700314b02f (diff)
logicpuzzle (24mar13)
git-svn-id: svn://tug.org/texlive/trunk@29499 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/logicpuzzle/createlpsudoku91
-rw-r--r--Master/texmf-dist/tex/latex/logicpuzzle/lpsmag175
-rw-r--r--Master/texmf-dist/tex/latex/logicpuzzle/lpsudoku.sty213
-rw-r--r--Master/texmf-dist/tex/latex/logicpuzzle/simple.smc7
4 files changed, 486 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/logicpuzzle/createlpsudoku b/Master/texmf-dist/tex/latex/logicpuzzle/createlpsudoku
new file mode 100644
index 00000000000..7738198e33a
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/logicpuzzle/createlpsudoku
@@ -0,0 +1,91 @@
+#!/bin/bash
+#
+# createlpsudoku [options] [-o output] -i input
+#
+# transforms Sudokus in 81 format (-e) or Simple Sudoku format (-s)
+# into lpsudoku environments for lpsudoku.sty
+#
+# License: LPPL
+#
+FORMAT="81"
+VERSION="v1.1"
+LINEENDINGS="UNIX"
+IFILE=""
+OFILE=""
+#
+typeset -i SLBEGIN=1
+typeset -i SLEND=9
+typeset -i COUNT=9
+#
+while getopts "eshwvi:o:" FLAG
+do
+ case "$FLAG" in
+ e) FORMAT="81";;
+ s) FORMAT="ss";;
+ w) LINEENDINGS="WINDOWS";;
+ i) IFILE="$OPTARG";;
+ o) OFILE="$OPTARG";;
+ h) echo "`basename $0` [options] [-o output] -i input"; exit 0;;
+ v) echo "`basename $0` $VERSION (C) 2013 Josef Kleber"; exit 0;;
+ esac
+done
+#
+if [ -z "$IFILE" ]
+then
+ echo "no input file"
+ echo "Usage: `basename $0` [options] [-o output] -i input"
+ exit 1
+fi
+#
+if [ ! -e "$IFILE" ]
+then
+ echo "ERROR: input file $IFILE does not exist"
+ exit 1
+fi
+#
+if [ -n "$OFILE" ]
+then
+ exec 1> $OFILE
+fi
+#
+if [ "$FORMAT" = "ss" ]
+then
+ echo "\begin{lpsudoku}"
+ for SDLINE in `cat $IFILE | sed -e '1d' -e'5d' -e'9d' -e'13,200d' | sed -e 's/|//g' | sed -e's/^[[:space:]]//g'`
+ do
+ ROWARG=`echo $SDLINE | sed -e's/\./{},/g' -e's/\([[:digit:]]\)/\1,/g' | sed -e's/,$//'`
+ echo " \setrow{$COUNT}{$ROWARG}"
+ ((COUNT--))
+ done
+ echo "\end{lpsudoku}"
+ echo
+fi
+#
+if [ "$FORMAT" = "81" ]
+then
+ for SUDOKU in `cat $IFILE | sed -e's/#.*//'`
+ do
+ echo "\begin{lpsudoku}"
+ while [ $COUNT -gt 0 ]
+ do
+ SDLINE=`echo $SUDOKU | cut -c${SLBEGIN}-${SLEND}`
+ ROWARG=`echo $SDLINE | sed -e's/\./{},/g' -e's/\([[:digit:]]\)/\1,/g' | sed -e's/,$//'`
+ echo " \setrow{$COUNT}{$ROWARG}"
+ ((COUNT--))
+ ((SLBEGIN+=9))
+ ((SLEND+=9))
+ done
+ SLBEGIN=1
+ SLEND=9
+ COUNT=9
+ echo "\end{lpsudoku}"
+ echo
+ done
+fi
+#
+if [ -n "$OFILE" -a "$LINEENDINGS" = "WINDOWS" ]
+then
+ unix2dos -q $OFILE
+fi
+#
+exit 0 \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/logicpuzzle/lpsmag b/Master/texmf-dist/tex/latex/logicpuzzle/lpsmag
new file mode 100644
index 00000000000..9e7725b1b47
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/logicpuzzle/lpsmag
@@ -0,0 +1,175 @@
+#!/bin/bash
+#
+# lpsmag CONFIGFILE
+#
+# creates a LaTeX file for the production
+# a Sudoku magazine with lpsudoku.sty
+#
+# License: LPPL
+#
+CONFIGFILE="$1"
+TEXFILE="lpsmag.tex"
+TEXFILEBAK="${TEXFILE}.bak"
+typeset -i COUNT=0
+SUDOKUPP="6"
+SUDOKUPPD="12"
+#
+if [ -z "$CONFIGFILE" ]
+then
+ echo "no config file"
+ echo "Usage: `basename $0` configfile"
+ exit 1
+fi
+#
+exec 1> $TEXFILE
+#
+startpuzzles()
+{
+ echo "\lpsudokusetup{scale=0.75,width=6.8cm,fontsize=Large,cvoffset=-24pt}"
+ echo "\setpuzzlecounter{1}"
+}
+#
+startsolutions()
+{
+ echo "\lpsudokusetup{scale=0.5,width=4.6cm,fontsize=normalsize}"
+ echo "\setpuzzlecounter{1}"
+}
+#
+page()
+{
+ local name="$1"
+ local difficulty="$2"
+ qqwing --generate $SUDOKUPP --one-line --difficulty $difficulty >${name}.81
+ cat ${name}.81 | qqwing --solve --one-line >${name}_sol.81
+}
+#
+typesetpage()
+{
+ local name="$1"
+ local last="$2"
+ local puzzlenummer="uneven"
+ COUNT=0
+ echo "%startpage"
+ for puzzle in `cat ${name}.81`
+ do
+ ((COUNT++))
+ echo $puzzle >puzzle.81
+ createlpsudoku -i puzzle.81
+ if [ "$puzzlenummer" = "uneven" ]
+ then
+ echo "\hfill"
+ # toggle even/uneven
+ puzzlenummer="even"
+ else
+ # no \vfill after last lpsudoku
+ # environment of the page
+ if [ $COUNT -lt $SUDOKUPP ]
+ then
+ echo "\vfill"
+ else
+ if [ "$last" != "last" ]
+ then
+ echo "\clearpage"
+ fi
+ fi
+ puzzlenummer="uneven"
+ fi
+ done
+}
+#
+tspfor()
+{
+ local name="$1"
+ local last="$2"
+ local puzzlepos="one"
+ for puzzle in `cat ${name}.81`
+ do
+ ((COUNT++))
+ if [ $COUNT -eq 1 -o $COUNT -eq 7 ]
+ then
+ echo "%startpage"
+ fi
+ echo $puzzle >puzzle.81
+ createlpsudoku -i puzzle.81
+ if [ "$puzzlepos" = "one" ]
+ then
+ echo "\hfill"
+ puzzlepos="two"
+ elif [ "$puzzlepos" = "two" ]
+ then
+ echo "\hfill"
+ puzzlepos="three"
+ else
+ if [ $COUNT -lt $SUDOKUPPD ]
+ then
+ echo "\vfill"
+ puzzlepos="one"
+ else
+ if [ "$last" = "last" ]
+ then
+ puzzlepos="one"
+ else
+ echo "\clearpage"
+ puzzlepos="one"
+ fi
+ fi
+ fi
+ done
+}
+#
+typesetsolpage()
+{
+ local name1="$1_sol"
+ local name2="$2_sol"
+ local last="$3"
+ COUNT=0
+ tspfor $name1 $last
+ tspfor $name2 $last
+}
+#
+addcounterstyle()
+{
+ grep -ne'startpage' $TEXFILE | cut -d':' -f1 >csl.tmp
+ for linenumber in `cat csl.tmp`
+ do
+ COUNT="$linenumber"
+ ((COUNT++))
+ echo "$COUNT a [counterstyle=left]" >>sed.tmp
+ echo "$linenumber d" >>sed.tmp
+ done
+ sed -f sed.tmp $TEXFILE >$TEXFILEBAK
+ rm $TEXFILE
+ mv $TEXFILEBAK $TEXFILE
+}
+#
+addpercent()
+{
+ sed -e's/$/%/' $TEXFILE >$TEXFILEBAK
+ rm $TEXFILE
+ mv $TEXFILEBAK $TEXFILE
+}
+#
+deleteauxfiles()
+{
+ rm *.81
+ rm *.tmp
+}
+#
+cat >preamble.tmp <<EOF
+\documentclass[a4paper]{article}%
+\usepackage[bottom=3cm,top=3cm,left=2.7cm,right=2.7cm]{geometry}
+\usepackage[width=5cm,scale=0.55,fontsize=normalsize]{lpsudoku}%
+EOF
+#
+cat preamble.tmp
+echo "\begin{document}"
+#
+. $CONFIGFILE
+#
+echo "\end{document}"
+#
+addcounterstyle
+addpercent
+deleteauxfiles
+exit 0
+# \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/logicpuzzle/lpsudoku.sty b/Master/texmf-dist/tex/latex/logicpuzzle/lpsudoku.sty
new file mode 100644
index 00000000000..dfc892e468e
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/logicpuzzle/lpsudoku.sty
@@ -0,0 +1,213 @@
+%%
+%% 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{lpsudoku}[2013/03/22 lpsudoku.sty v1.0 - Josef Kleber (C) 2013]%
+%
+\RequirePackage{logicpuzzle}%
+%
+% options
+\newcommand*\LP@SDK@width{9.1cm}%
+\newcommand*\LP@SDK@fontsize\Large%
+\newcommand*\LP@SDK@rows{9}%
+\newcommand*\LP@SDK@columns{9}%
+\newcommand*\LP@SDK@scale{1}%
+\newcommand*\LP@SDK@bgcolor{}%
+\newcommand*\LP@SDK@cvoffset{-24pt}%
+\newcommand*\LP@SDK@title{}%
+\newcommand*\LP@SDK@titleindent{0cm}%
+\newcommand*\LP@SDK@titlewidth{9.1cm}%
+%
+\newcounter{LP@SDK@rows}%
+\newcounter{LP@SDK@columns}%
+%
+\setcounter{LP@SDK@rows}{\LP@SDK@rows}%
+\setcounter{LP@SDK@columns}{\LP@SDK@columns}%
+\stepcounter{LP@SDK@rows}%
+\stepcounter{LP@SDK@columns}%
+%
+\define@key{lpsudoku.sty}{scale}[1]%
+{%
+ \renewcommand*\LP@SDK@scale{#1}%
+}%
+%
+\define@key{lpsudoku.sty}{counterstyle}[none]%
+{%
+ \renewcommand*\LP@counterstyle{#1}%
+}%
+%
+\define@key{lpsudoku.sty}{bgcolor}[]%
+{%
+ \renewcommand*\LP@SDK@bgcolor{#1}%
+}%
+%
+\define@choicekey*{lpsudoku.sty}{fontsize}[\LP@SDK@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]%
+{%
+ \ifcase\nr\relax%
+ \renewcommand*\LP@SDK@fontsize{\tiny}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\scriptsize}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\footnotesize}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\small}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\normalsize}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\large}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\Large}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\LARGE}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\huge}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\Huge}%
+ \fi%
+}%
+%
+\define@key{lpsudoku.sty}{width}[9.1cm]%
+{%
+ \renewcommand*\LP@SDK@width{#1}%
+}%
+%
+\define@key{lpsudoku.sty}{title}[]%
+{%
+ \renewcommand*\LP@SDK@title{#1}%
+}%
+%
+\define@key{lpsudoku.sty}{cvoffset}[-24pt]%
+{%
+ \renewcommand*\LP@SDK@cvoffset{#1}%
+}%
+%
+\define@key{lpsudoku.sty}{titleindent}[0cm]%
+{%
+ \renewcommand*\LP@SDK@titleindent{#1}%
+}%
+%
+\define@key{lpsudoku.sty}{titlewidth}[9.1cm]%
+{%
+ \renewcommand*\LP@SDK@titlewidth{#1}%
+}%
+%
+\define@key{lpsudoku}{scale}%
+{%
+ \renewcommand*\LP@SDK@scale{#1}%
+}%
+%
+\define@key{lpsudoku}{bgcolor}%
+{%
+ \renewcommand*\LP@SDK@bgcolor{#1}%
+}%
+%
+\define@key{lpsudoku}{counterstyle}%
+{%
+ \renewcommand*\LP@counterstyle{#1}%
+}%
+%
+\define@choicekey*{lpsudoku}{fontsize}[\LP@SDK@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]%
+{%
+ \ifcase\nr\relax%
+ \renewcommand*\LP@SDK@fontsize{\tiny}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\scriptsize}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\footnotesize}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\small}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\normalsize}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\large}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\Large}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\LARGE}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\huge}%
+ \or%
+ \renewcommand*\LP@SDK@fontsize{\Huge}%
+ \fi%
+}%
+%
+\define@key{lpsudoku}{width}%
+{%
+ \renewcommand*\LP@SDK@width{#1}%
+}%
+%
+\define@key{lpsudoku}{title}%
+{%
+ \renewcommand*\LP@SDK@title{#1}%
+}%
+%
+\define@key{lpsudoku}{cvoffset}%
+{%
+ \renewcommand*\LP@SDK@cvoffset{#1}%
+}%
+%
+\define@key{lpsudoku}{titleindent}%
+{%
+ \renewcommand*\LP@SDK@titleindent{#1}%
+}%
+%
+\define@key{lpsudoku}{titlewidth}%
+{%
+ \renewcommand*\LP@SDK@titlewidth{#1}%
+}%
+%
+\ExecuteOptionsX{width,fontsize,scale,bgcolor,cvoffset,counterstyle,title,titleindent,titlewidth}%
+%
+\ProcessOptionsX\relax%
+%
+\let\lpsudokucell\setcell%
+%
+\newcommand*\lpsudokusetup[1]%
+{%
+ \setkeys{lpsudoku.sty}{#1}%
+}%
+%
+\newenvironment{lpsudoku}[1][]%
+{%
+ \setkeys{lpsudoku}{#1}%
+ \LP@set@package{lpsudoku}%
+ \LP@set@env@prefix{LP@SDK}%
+ \setcounter{LP@SDK@rows}{\LP@SDK@rows}%
+ \setcounter{LP@SDK@columns}{\LP@SDK@columns}%
+ \stepcounter{LP@SDK@rows}%
+ \stepcounter{LP@SDK@columns}%
+ \begin{minipage}[t]{\LP@SDK@width}%
+ \ifthenelse{\equal{\LP@SDK@title}{}}%
+ {\par\enspace\par}% empty
+ {\enspace\par\noindent\hspace{\LP@SDK@titleindent}\parbox{\LP@SDK@titlewidth}{\strut\LP@titleformat\LP@SDK@title}\vspace{3mm}\par}%
+ \begin{tikzpicture}[scale=\LP@SDK@scale]%
+ \LP@drawbackground{1}{1}{\LP@SDK@columns}{\LP@SDK@rows}{\LP@SDK@bgcolor}%
+ \LP@drawgrid{1}{1}{\LP@SDK@columns}{\LP@SDK@rows}{1cm}%
+ \LP@drawsudokugrid%
+}%
+{%
+ \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/simple.smc b/Master/texmf-dist/tex/latex/logicpuzzle/simple.smc
new file mode 100644
index 00000000000..0ec2d162199
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/logicpuzzle/simple.smc
@@ -0,0 +1,7 @@
+page p1 easy
+page p2 easy
+startpuzzles
+typesetpage p1
+typesetpage p2
+startsolutions
+typesetsolpage p1 p2 last \ No newline at end of file