% \iffalse meta-comment
% !TEX program  = pdfLaTeX
%<*internal>
\iffalse
%</internal>
%<*readme>
The logicpuzzle bundle allows you to typeset various logic
puzzles. At the moment the following puzzles are supported:

* 2D-Sudoku (aka Magiequadrat, Diagon, ...)
* Battleship (aka Bimaru, Marinespiel, Batalla Naval, ...)
* Bokkusu (aka Kakurasu, Feldersummenrätsel, ...)
* Bridges (aka Brückenbau, Hashi, ...)
* Chaos Sudoku
* Four Winds (aka Eminent Domain, Lichtstrahl, ...)
* Hakyuu (aka Seismic, Ripple Effect, ...)
* Hitori
* Kakuro
* Kendoku (aka Mathdoku, Calcudoku, Basic, MiniPlu, Ken Ken,
               Square Wisdom, Sukendo, Caldoku, ...)
* Killer Sudoku (aka Samunapure, Sum Number Place, Sumdoku,
                     Gebietssummen, ...)
* Laser Beam (aka Laserstrahl, ...)
* Magic Labyrinth (aka Magic Spiral, Magisches Labyrinth, ...)
* Magnets (aka Magnetplatte, Magnetfeld, ...)
* Masyu (aka Mashi, {White|Black} Pearls, ...)
* Minesweeper (aka Minensuche, ...)
+ Nonogram (aka Griddlers, Hanjie, Tsunami, Logic Art,
                Logimage, ...)
* Number Link (aka Alphabet Link, Arukone, Buchstabenbund, ...)
* Resuko
* Schatzsuche
* Skyline (aka Skycrapers, Wolkenkratzer, Hochhäuser, ...)
  incl. Skyline Sudoku and Skyline Sudoku (N*N) variants
* Slitherlink (aka Fences, Number Line, Dotty Dilemma,
               Sli-Lin, Takegaki, Great Wall of China,
               Loop the Loop, Rundweg, Gartenzaun, ...)
* Star Battle (aka Sternenschlacht, ...)
* Stars and Arrows (aka Sternenhimmel, ...)
* Sudoku
* Sun and Moon (aka Sternenhaufen, Munraito, ...)
* Tents and Trees (aka Zeltlager, Zeltplatz, Camping, ...)
* Tunnel

License: LPPL

Changes in v2.5:

- added support for Nonogram puzzle
  https://bitbucket.org/kleberj/logicpuzzle/wiki/Nonogram
  https://bitbucket.org/kleberj/logicpuzzle/downloads/example-nonogram.pdf
  
  feature request by: Theresa Spannbauer

- added documented source (dtx)

- added LPpreset TikZ style to all puzzle environments plus some minor
  changes
  
  INSTALL
===========

First of all, install the package with the package manager of your
TeX distribution, if possible.

Or download logicpuzzle.tds.zip and unzip it in the root directory
of your local TeX tree! Run texhash, that's it!

Manual installation:

- download logicpuzzle.dtx and qrcode.png

- extract all other files with pdftex logicpuzzle.dtx
  If you also want to create logicpuzzle.pdf, you can also run 
  pdflatex logicpuzzle.dtx
  
- finish logicpuzzle.pdf by running:

  (pdflatex logicpuzzle.dtx)  already done???
  bibtex logicpuzzle
  makeindex -s gind.ist logicpuzzle
  makeindex -s gglo.ist logicpuzzle.glo -o logicpuzzle.gls
  pdflatex logicpuzzle.dtx
  bibtex logicpuzzle
  makeindex -s gind.ist logicpuzzle
  makeindex -s gglo.ist logicpuzzle.glo -o logicpuzzle.gls
  pdflatex logicpuzzle.dtx
  
- rename some files:

  createlpsudoku.sh -> createlpsudoku
  lpsmag.sh -> lpsmag
  README.txt -> README
  
  or use one of the scripts:
  
  * Linux: simply run ./rename.sh
  * Windows: rename rename.win -> rename.bat and run it
             Windows does pdftex not allow to write a batch file (.bat)

- move the files:

  *.sty -> localtexmf/tex/latex/logicpuzzle/
  *.pdf -> localtexmf/doc/latex/logicpuzzle/
  *.dtx -> localtexmf/doc/latex/logicpuzzle/
  *.txt -> localtexmf/doc/latex/logicpuzzle/
  README -> localtexmf/doc/latex/logicpuzzle/
  bash scripts + *.smc -> somewhere in $PATH

- update your FNDB (Filename database)

  run texhash
  
You really should use the package manager! ;-)

%</readme>
%<*manifest>
This work consists of the following files:

logicpuzzle.dtx
logicpuzzle.pdf
qrcode.png
README
%</manifest>
%<*renamebat>
ren createlpsudoku.sh createlpsudoku
ren lpsmag.sh lpsmag
ren README.txt README
%</renamebat>
%<*renamesh>
#!/bin/bash
#
mv createlpsudoku.sh createlpsudoku
mv lpsmag.sh lpsmag
mv README.txt README
%</renamesh>
%<*lpsmag>
#!/bin/bash
#
# lpsmag CONFIGFILE
#
# creates a LaTeX file for the production
# a Sudoku magazine with lpsudoku.sty
#
# License: LPPL
#
VERSION="v1.1 (06/05/2013)"
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{logicpuzzle}%
\lpsudokusetup{width=5cm,scale=0.55,fontsize=normalsize}%
EOF
#
cat preamble.tmp
echo "\begin{document}"
#
. $CONFIGFILE
#
echo "\end{document}"
#
addcounterstyle
addpercent
deleteauxfiles
exit 0
#
%</lpsmag>
%<*createlpsudoku>
#!/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
%</createlpsudoku>
%<*simple>
page p1 easy
page p2 easy
startpuzzles
typesetpage p1
typesetpage p2
startsolutions
typesetsolpage p1 p2 last
%</simple>
%<*bibfile>
@misc{bib:webbb:logigpuzzle,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/}(https://bitbucket.org/kleberj/logicpuzzle/)},
 title                = {The logicpuzzle bundle},
 year                 = {2013},
 }

@misc{bib:weblp:logigpuzzle,
 author               = {Josef Kleber},
 note                 = {\href{http://logicpuzzle.square7.de/}(http://logicpuzzle.square7.de/)},
 title                = {{logicpuzzle -- A LaTeX style file for typesetting logic puzzles}},
 year                 = {2013},
 }

@misc{bib:wiki:createlpsudoku,
 author               = {Josef Kleber},
 note                 = {\href{http://logicpuzzle.square7.de/createlpsudoku}(http://logicpuzzle.square7.de/createlpsudoku)},
 title                = {createlpsudoku},
 year                 = {2013},
 }

@misc{bib:wiki:lpsmag,
 author               = {Josef Kleber},
 note                 = {\href{http://logicpuzzle.square7.de/lpsmag}(http://logicpuzzle.square7.de/lpsmag)},
 title                = {lpsmag},
 year                 = {2013},
 }

@misc{bib:wiki:howtosudoku,
 author               = {Josef Kleber},
 note                 = {\href{http://logicpuzzle.square7.de/sudoku_magazine}(http://logicpuzzle.square7.de/sudoku\_magazine)},
 title                = {{How to create a Sudoku magazine}},
 year                 = {2013},
 }

@misc{bib:web:qqwing,
 author               = {Stephen Ostermiller},
 note                 = {\href{http://ostermiller.org/qqwing/}(http://ostermiller.org/qqwing/)},
 title                = {{QQwing -- Sudoku Generator and Solver}},
 year                 = {2011},
 }

@misc{bib:web:hodoku,
 author               = {Bernhard Hobiger},
 note                 = {\href{http://hodoku.sourceforge.net/en/index.php}(http://hodoku.sourceforge.net/en/index.php)},
 title                = {{HoDoKu}},
 year                 = {2012},
 }

@misc{bib:ex:ddsudoku,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-ddsudoku.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-ddsudoku.pdf)},
 title                = {{Examples \& Solutions (ddsudoku)}},
 year                 = {2013},
 }

@misc{bib:ex:battleship,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-battleship.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-battleship.pdf)},
 title                = {{Examples \& Solutions (battleship)}},
 year                 = {2013},
 }

@misc{bib:ex:bokkusu,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-bokkusu.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-bokkusu.pdf)},
 title                = {{Examples \& Solutions (bokkusu)}},
 year                 = {2013},
 }

@misc{bib:ex:chaossudoku,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-chaossudoku.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-chaossudoku.pdf)},
 title                = {{Examples \& Solutions (chaossudoku)}},
 year                 = {2013},
 }

@misc{bib:ex:hakyuu,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-hakyuu.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-hakyuu.pdf)},
 title                = {{Examples \& Solutions (hakyuu)}},
 year                 = {2013},
 }

@misc{bib:ex:hitori,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-hitor.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-hitori.pdf)},
 title                = {{Examples \& Solutions (hitori)}},
 year                 = {2013},
 }

@misc{bib:ex:kendoku,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-kendoku.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-kendoku.pdf)},
 title                = {{Examples \& Solutions (kendoku)}},
 year                 = {2013},
 }

@misc{bib:ex:killersudoku,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-killersudoku.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-killersudoku.pdf)},
 title                = {{Examples \& Solutions (killersudoku)}},
 year                 = {2013},
 }

@misc{bib:ex:laserbeam,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-laserbeam.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-laserbeam.pdf)},
 title                = {{Examples \& Solutions (laserbeam)}},
 year                 = {2013},
 }

@misc{bib:ex:minesweeper,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-minesweeper.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-minesweeper.pdf)},
 title                = {{Examples \& Solutions (minesweeper)}},
 year                 = {2013},
 }

@misc{bib:ex:skyline,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-skyline.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-skyline.pdf)},
 title                = {{Examples \& Solutions (skyline)}},
 year                 = {2013},
 }

@misc{bib:ex:slitherlink,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-slitherlink.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-slitherlink.pdf)},
 title                = {{Examples \& Solutions (slitherlink)}},
 year                 = {2013},
 }

@misc{bib:ex:lpsudoku,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-lpsudoku.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-lpsudoku.pdf)},
 title                = {{Examples \& Solutions (lpsudoku)}},
 year                 = {2013},
 }

@misc{bib:ex:tunnel,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-tunnel.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-tunnel.pdf)},
 title                = {{Examples \& Solutions (tunnel)}},
 year                 = {2013},
 }

@misc{bib:ex:schatzsuche,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-schatzsuche.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-schatzsuche.pdf)},
 title                = {{Examples \& Solutions (schatzsuche)}},
 year                 = {2013},
 }

@misc{bib:ex:kakuro,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-kakuro.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-kakuro.pdf)},
 title                = {{Examples \& Solutions (kakuro)}},
 year                 = {2013},
 }

@misc{bib:ex:tentsandtrees,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-tentsandtrees.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-tentsandtrees.pdf)},
 title                = {{Examples \& Solutions (tentsandtrees)}},
 year                 = {2013},
 }

@misc{bib:ex:sunandmoon,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-sunandmoon.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-sunandmoon.pdf)},
 title                = {{Examples \& Solutions (sunandmoon)}},
 year                 = {2013},
 }

@misc{bib:ex:bridges,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-bridges.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-bridges.pdf)},
 title                = {{Examples \& Solutions (bridges)}},
 year                 = {2013},
 }

@misc{bib:ex:fourwinds,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-fourwinds.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-fourwinds.pdf)},
 title                = {{Examples \& Solutions (fourwinds)}},
 year                 = {2013},
 }

@misc{bib:ex:numberlink,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-numberlink.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-numberlink.pdf)},
 title                = {{Examples \& Solutions (numberlink)}},
 year                 = {2013},
 }

@misc{bib:ex:magiclabyrinth,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-magiclabyrinth.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-magiclabyrinth.pdf)},
 title                = {{Examples \& Solutions (magiclabyrinth)}},
 year                 = {2013},
 }

@misc{bib:ex:masyu,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-masyu.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-masyu.pdf)},
 title                = {{Examples \& Solutions (masyu)}},
 year                 = {2013},
 }

@misc{bib:ex:magnets,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-magnets.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-magnets.pdf)},
 title                = {{Examples \& Solutions (magnets)}},
 year                 = {2013},
 }

@misc{bib:ex:nonogram,
 author               = {Josef Kleber},
 note                 = {\href{https://bitbucket.org/kleberj/logicpuzzle/downloads/example-nonogram.pdf}(https://bitbucket.org/kleberj/logicpuzzle/downloads/example-nonogram.pdf)},
 title                = {{Examples \& Solutions (nonogram)}},
 year                 = {2014},
 }
 
%</bibfile>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble

Copyright (C) 2013-2014 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.

\endpreamble

\usedir{tex/latex/logicpuzzle}
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\generate{
  \file{lpenv.sty}{\from{\jobname.dtx}{lpenv}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\nopreamble\nopostamble
\usedir{source/latex/logicpuzzle}
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\usedir{doc/latex/logicpuzzle}
\generate{
  \file{README.txt}{\from{\jobname.dtx}{readme}}
}
\generate{
  \file{manifest.txt}{\from{\jobname.dtx}{manifest}}
}
\generate{
  \file{\jobname.bib}{\from{\jobname.dtx}{bibfile}}
}
\usedir{scripts/logicpuzzle}
\generate{
  \file{simple.smc}{\from{\jobname.dtx}{simple}}
}
\generate{
  \file{lpsmag.sh}{\from{\jobname.dtx}{lpsmag}}
}
\generate{
  \file{createlpsudoku.sh}{\from{\jobname.dtx}{createlpsudoku}}
}
\generate{
  \file{rename.sh}{\from{\jobname.dtx}{renamesh}}
}
\generate{
  \file{rename.win}{\from{\jobname.dtx}{renamebat}}
}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*lpenv>
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{lpenv}[2015/06/15 v2.5 lpenv.sty - Josef Kleber (C) 2013-2014]%
%</lpenv>
%<*driver>
\documentclass[a4paper]{ltxdoc}%
\usepackage[english]{babel}%
\usepackage[utf8]{inputenc}%
\usepackage[T1]{fontenc}%
\usepackage{textcomp}%
\usepackage{lmodern}%
\usepackage{bera}%
\usepackage{makeidx}
\usepackage{ccicons}
\usepackage{tabularx}
\usepackage{microtype}%
\usepackage{listings}
\usepackage{nicefrac}
\usepackage[numbered]{hypdoc}
\usepackage{marginnote}%
\usepackage[svgnames,rgb]{xcolor}%
\usepackage[automark,nouppercase]{scrpage2}
\usepackage[tocgraduated]{tocstyle}
\usetocstyle{classic}
\usepackage{logicpuzzle}
\usepackage{hyperref}
\makeatletter
\global\let\tikz@ensure@dollar@catcode=\relax
\makeatother
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\makeatletter
\setlength{\headheight}{1.1\baselineskip}%
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
            {-2.5ex\@plus -1ex \@minus -.25ex}%
            {1.25ex \@plus .25ex}%
            {\normalfont\normalsize\bfseries}}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\AtBeginDocument{\IfFileExists{qrcode.png}{}{\write18{wget -O qrcode.png http://i.imgur.com/KAunnuS.png}}}%
\hypersetup{colorlinks=true,urlcolor=NavyBlue,linkcolor=NavyBlue,citecolor=CornflowerBlue}%
\lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny, basicstyle=\ttfamily, aboveskip=\baselineskip, frame=single, backgroundcolor=\color{LightGoldenrodYellow}, keywordstyle=\color{Blue},
emph={ddsudoku, battleship, bokkusu, chaossudoku, hakyuu, hitori, kakuro, kendoku, killersudoku, laserbeam, skyline, slitherlink, lpsudoku, minesweeper, schatzsuche, tentsandtrees, tunnel, bridges, starsandarrows, starbattle, sunandmoon, fourwinds, numberlink, resuko, magiclabyrinth, masyu, magnets, nonogram
,minipage, tikzpicture, puzzlebackground, puzzleforeground, center, pgfonlayer, left,
shape, fill, inner, sep, draw, rounded, corners, thick},
emphstyle=\color{Tomato}, emph={[2]Wheat, HotPink, GreenYellow, LightBlue, LightSalmon,
LightYellow, green, sudoku, rows, columns, scale, layer, color, bgcolor, counterstyle, title,
titleindent, titlewidth, cvoffset, width, grid, fontsize, extracells, helplines, solution},
emphstyle={[2]\color{OliveDrab}}, morekeywords={LP@definecolor, LP@define@choicekey@fontsize,
ExecuteOptionsX, ProcessOptionsX, LP@init@counter, valueH, valueV, sumH, sumV, LP@bottomrow,
LP@toprow, LP@rightcolumn, bokkususetup, setkeys, LP@set@package, LP@set@env@prefix,
ifthenelse, equal, LP@drawbackground, LP@drawgrid, LP@drawcounter, ProvidesPackage,
RequirePackage, LP@BK@init@prefix, LP@BK@init@package, LP@leftcolumn, skylineL,
LP@define@key, framearea, framepuzzle, fillarea, filldiagonals, tikzpath, setrule, colorarea,
ddsudokucell, chaossudokucell, hakyuucell, setrow, LP@cvoffset, titleformat, definecounterstyle,
marginnote, tikz, node, placesegment, placeship, shipH, shipV, shipbox, puzzlecounter, color,
fillrow, setcolorrow, laserV, laserH, mirrorV, mirrorH, placearrow, placecross, placemirror,
laser, skylineT, skylineB, skylineR, skylineL, skylinecell, setbigcell, slitherlinkcell,
tunnelH, tunnelV, tube, portal, Mine, Diamond, ShipR, kakurosetup, kakurorow, KKR, Black,
Tent, Tree, definecolor, tentH, tentV, bridgesrow, starbattlecell, starsH, starsV, [, ],
RightDown, Right, LeftDown, LeftUp, Up, RightUp, Left, Star, Cloud, Moon, MoonTL, MoonR,
MoonT, colorlet, bridge, fourwindscell, numberlinkcell, link, resukosetup, resukocell,
Graveltrap, Cross, StraightV, StraightH, CurveTR, CurveBR, trackH, trackV, track,
parkinglot, pitlane, xtikzpath, mlline, setcells, magiclabyrinthcell, magnetssetup, minusH,
minusV, plusH, plusV, magnetsH, magnetsV, PMH, PMV, MPH, MPV, masyucell, masyuline,
masyusetup, MasyuW, MasyuB, nonogramV, nonogramH, nonogramrow, puzzlestrut}}
\renewcommand{\maketitle}%
{%
  \thispagestyle{empty}%
  \pagecolor{Ivory}%
  \begin{titlepage}%
    \begin{tikzpicture}[remember picture,overlay]%
      \node[yshift=-2cm] at (current page.north west)%
      {%
        \begin{tikzpicture}[remember picture, overlay]%
          \draw[fill=CornflowerBlue,color=CornflowerBlue] (0,0) rectangle%
            (\paperwidth,2cm);%
          \draw[anchor=west,yshift=-4cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\RaggedRight\Huge\sffamily\textbf{\@title}}};%
          \draw[anchor=west,yshift=-6cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\huge\sffamily\textbf{\@fileversion}}};%
          \draw[anchor=west,yshift=-9cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\RaggedRight\huge\sffamily\textbf{\@subtitle}}};%
          \draw[anchor=west,yshift=-13cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\usebox\logo};%
          \draw[anchor=west,yshift=-17cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\huge\sffamily\textbf{\@date}}};%
          \draw[anchor=west,yshift=-20cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\Large\sffamily{\@authorline\\\textbf{\@author}}}};%
        \end{tikzpicture}%
      };%
      \node[yshift=0cm] at (current page.south west)%
      {%
        \begin{tikzpicture}[remember picture, overlay]%
          \draw[fill=NavyBlue,color=NavyBlue,yshift=6cm,xshift=2cm] (0,0) rectangle (0.2cm,19cm);%
          \draw[fill=CornflowerBlue,color=CornflowerBlue] (0,0) rectangle (\paperwidth,2cm);%
          \draw[anchor=west,yshift=1cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\large\sffamily{\@refline}}};%
        \end{tikzpicture}%
      };%
    \end{tikzpicture}%
  \end{titlepage}%
  \pagecolor{white}%
}%
%
\newcommand*{\@tikzhead}[1]%
{%
  \begin{tikzpicture}[remember picture,overlay]%
    \node[yshift=-2cm] at (current page.north west)%
    {%
      \begin{tikzpicture}[remember picture, overlay]%
        \draw[fill=CornflowerBlue] (0,0) rectangle (\paperwidth,2cm);%
        \draw[anchor=west,yshift=1cm,xshift=1.5cm,color=NavyBlue] (0,0) node%
          {\parbox{15cm}{\LARGE\sffamily\textbf{\@title}}};%
        \node[anchor=east,xshift=.9\paperwidth,rectangle,%
              rounded corners=15pt,inner sep=11pt,fill=NavyBlue]%
              {\color{white}\textsc{#1}};%
      \end{tikzpicture}%
    };%
  \end{tikzpicture}%
}%
\clearscrheadings%
\ihead{\@tikzhead{\headmark}}%
\cfoot{\upshape\thepage}%
\pagestyle{scrheadings}%
%
\newcommand*{\Headline}[1]{\@mkboth{#1}{#1}}%
%
\renewcommand{\headfont}{\normalfont\mdseries\scshape}
%
\gdef\@subtitle{}%
\providecommand*{\Subtitle}[1]{\gdef\@subtitle{#1}}%
\gdef\@fileversion{}%
\providecommand*{\Fileversion}[1]{\gdef\@fileversion{#1}}%
\gdef\@author{}%
\providecommand*{\Author}[1]{\gdef\@author{#1}}%
\gdef\@authorline{Package author:}%
\providecommand*{\Authorline}[1]{\gdef\@authorline{#1}}%
\gdef\@refline{}%
\providecommand*{\Refline}[1]{\gdef\@refline{#1}}%
\gdef\and{\unskip{}, }%
\newcommand\doubledash{-\kern0.5pt-}
\def\filename{logicpuzzle.sty}%
\def\XeLaTeX{Xe\LaTeX}%
%
\newenvironment{optionlist}
{\begin{trivlist}\setlength\leftskip{2em}}
{\end{trivlist}}
\newcommand\optitem[3]{\item [\texttt{\textbf{\textcolor{DodgerBlue}{#1}} \lbrack\textcolor{Crimson}{#2}\rbrack}] #3}
\renewcommand\tableofcontents%
{%
%  \section*{\contentsname}%
  \@mkboth{%
  \MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
  \@starttoc{toc}%
}%
%
\newcommand\env[1]{\texttt{#1}}%
\newcommand\layer[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (PGF layer)}%
                     \SortIndex{PGF layer>#1}{\texttt{#1}}}%
\newcommand\styleoption[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Style option)}%
                     \SortIndex{Style option>#1}{\texttt{#1}}}%
\newcommand\envoption[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Puzzle option)}%
                     \SortIndex{Puzzle option>#1}{\texttt{#1}}}%
\newcommand\stylename[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Style file)}%
                     \SortIndex{Style file>#1}{\texttt{#1}}}%
\newcommand\package[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Package)}%
                     \SortIndex{Package>#1}{\texttt{#1}}}%
\newcommand*\margcs[1]{\marginnote{\hbadness=10000\RaggedLeft\scriptsize #1}}%
\hypersetup{pdfauthor={Josef Kleber},pdftitle={A style file for typesetting logic puzzles},pdfsubject={Documentation for LaTeX style \filename},pageanchor=true,hyperindex=true}%
\def\PrintIndex{\clearpage\Headline{Index}\@input@{\jobname.ind}%
                \global\let\PrintIndex\@empty}
                \renewenvironment{theindex}
               {\if@twocolumn
                  \@restonecolfalse
                \else
                  \@restonecoltrue
                \fi
                \columnseprule \z@
                \columnsep 35\p@
\def\see##1##2{\textit{See} ##1}%
\def\seealso##1##2{\textit{See also} ##1}%
\long\def\cmd##1{\cs{\expandafter\cmd@to@cs\string##1}}%
\def\@url##1{\url@break\ttt{##1}\endgroup}%
\def\ttt{\begingroup\@sanitize\ttfamily\@ttt}%
\def\@ttt##1{##1\endgroup}%
\mathchardef\save@secnumdepth\c@secnumdepth
\c@secnumdepth\m@ne
                \phantomsection%
                \twocolumn%[\section{\indexname}]%
                \refstepcounter{section}
                \addcontentsline{toc}{section}{\protect\numberline{\thesection}Index}%
\c@secnumdepth\save@secnumdepth
%                \thispagestyle{plain}
                \parindent\z@
                \parskip\z@ \@plus .3\p@\relax
                \let\item\@idxitem}
               {\if@restonecol\onecolumn\else\clearpage\fi}
\setlength\parindent{0pt}%
\makeatother
\newenvironment{mydescription}%
{%
  \begin{list}{}{\setlength\leftmargin{0pt}\setlength\labelwidth{-6pt}}
}%
{%
  \end{list}
}%
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
%\GetFileInfo{\jobname.sty}
%\DoNotIndex{\,,\addtocounter,\allowbreak,\arabic,\centering,\clip,\color,\colorlet,
%\csname,\definecolor,\draw,\endcsname,\enspace,\equal,\ExecuteOptionsX,\fill,\footnotesize,
%\foreach,\hbadness,\Huge,\huge,\i,\if,\ifthenelse,\j,\LARGE,\Large,\large,\marginnote,
%\medskip,\MessageBreak,\newif,\node,\normalsize,\PackageError,\parbox,\ProcessOptionsX,
%\RaggedRight,\RequirePackage,\scalebox,\scriptsize,\setkeys,\sffamily,\shade,\small,
%\stepcounter,\strut,\tiny,\usetikzlibrary,\value,\whiledo,\xdef,\define@choicekey,
%\define@key,\begingroup,\begin,\bgroup,\bfseries,\def,\egroup,\else,\end,\endgroup,
%\expandafter,\fi,\gdef,\hspace,\ifcase,\ifnum,\let,\newcommand,\newcounter,
%\newenvironment,\newlength,\noindent,\or,\par,\relax,\renewcommand,\setcounter,
%\space,\vspace}
%
% \bibliographystyle{plain}
% \ddsudokusetup{width=4.5cm,scale=0.85}
% \battleshipsetup{width=4.5cm,scale=0.77,sbindent=0.65cm,sbwidth=3.6cm}
% \bokkususetup{width=4.5cm,scale=0.64,fontsize=normalsize}
% \chaossudokusetup{width=4.5cm,scale=0.89}
% \hakyuusetup{width=4.5cm,scale=0.89}
% \hitorisetup{width=4.5cm,scale=0.85}
% \kakurosetup{width=4.5cm,scale=0.85}
% \kendokusetup{width=4.5cm,scale=0.89}
% \killersudokusetup{width=4.5cm,scale=0.89}
% \laserbeamsetup{width=4.5cm,scale=0.66,fontsize=normalsize}
% \minesweepersetup{width=4.5cm,scale=0.85}
% \schatzsuchesetup{width=4.5cm,scale=0.85}
% \skylinesetup{width=4.5cm,scale=0.66,fontsize=normalsize}
% \slitherlinksetup{width=4.5cm,scale=0.85}
% \lpsudokusetup{width=4.5cm,scale=0.49,fontsize=small}
% \tentsandtreessetup{width=4.5cm,scale=0.75}
% \tunnelsetup{width=4.5cm,scale=0.75}
% \sunandmoonsetup{width=4.5cm,scale=0.85}
% \starsandarrowssetup{width=4.5cm,scale=0.75}
% \starbattlesetup{width=4.5cm,scale=0.85}
% \bridgessetup{width=4.5cm,rows=8,columns=8,scale=0.55,color=orange!40}
% \resukosetup{rows=8,columns=8,width=4cm,fontsize=Huge,scale=.48}
% \numberlinksetup{width=4.5cm,scale=0.89}
% \killersudokusetup{width=4.5cm,scale=0.89}
% \magiclabyrinthsetup{width=4.5cm,scale=0.89}
% \masyusetup{width=4.5cm,scale=0.89,color=Teal}
% \magnetssetup{width=4.5cm,scale=0.55,bgcolor=Teal!50}
% \title{\filename}%
% \Subtitle{A style file for typesetting logic puzzles}%
% \author{Josef Kleber}
% \Fileversion{\fileversion}
% \date{\filedate}
% \Refline{\href{mailto:josef.kleber@gmx.de}{\texttt{josef.kleber@gmx.de}}\\\href{https://bitbucket.org/kleberj/logicpuzzle/}{\texttt{https://bitbucket.org/kleberj/logicpuzzle/}}}
% \newsavebox\logo
% \savebox\logo{%
% \begin{laserbeam}
%   \laserV{1}
%   \laserH{{}}
%   \mirrorH{{},2}
%    \mirrorV{{},{},{},{},{},2}
%    \framepuzzle[LP@c@mirror]
%    \placearrow{3}{1}{LeftUp}
%    \placearrow{6}{4}{RightUp}
%    \placecross{3}{3}
%  \end{laserbeam}
%  \hspace{1.5cm}
%  \begin{laserbeam}
%    \laserV{1}
%    \laserH{{}}
%    \mirrorH{{},2}
%    \mirrorV{{},{},{},{},{},2}
%    \framepuzzle[LP@c@mirror]
%    \placearrow{3}{1}{LeftUp}
%    \placearrow{6}{4}{RightUp}
%    \placecross{3}{3}
%    \placemirror{2}{2}{V}
%    \placemirror{4}{2}{H}
%    \placemirror{5}{5}{V}
%    \placemirror{3}{5}{H}
%    \begin{puzzlebackground}
%      \laser{\tikzpath{3}{1}{7,9,9,9,7,1,7,1,3,3,3,9,9}}
%    \end{puzzlebackground}
%  \end{laserbeam}
%}
% \maketitle
% \stepcounter{page}
% \tableofcontents
% \clearpage
% \setlength\parskip{6pt}%
%
%
%\StopEventually{^^A
% {
% \clearpage
% \raggedright
% \nocite{*}
% \bibliography{logicpuzzle}
% }
% \clearpage
%  \PrintChanges
%  \PrintIndex
%}
%
% \section{Roll out your own grid-based logic puzzle}
% \label{sec:rollout}
% As an example we take a look at the former \package{bokkusu.sty} package. First, we ignore the LPPL license stuff.
% \lstset{numbers=none,basicstyle=\ttfamily\footnotesize}%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\ProvidesPackage{bokkusu}[2013/03/25 bokkusu.sty v1.2 - Josef Kleber (C) 2013]%
\RequirePackage{logicpuzzle}%
\end{lstlisting}
% \iffalse
%</example>
% \fi
% We wrote a package \package{bokkusu.sty} with version number v1.2 and date 2013/03/25 and added a copyright remark. We need to load the code base package \package{logicpuzzle.sty}.
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\newcommand*\LP@BK@init@prefix{LP@BK}%
\newcommand*\LP@BK@init@package{bokkusu}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{rows}{5}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{columns}{5}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{scale}{1}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{counterstyle}{none}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{color}{black}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{bgcolor}{}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{width}{6.7cm}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{cvoffset}{-38pt}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{title}{}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{titleindent}{0.75cm}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{titlewidth}{5.85cm}%
\LP@define@choicekey@fontsize{\LP@BK@init@prefix}{\LP@BK@init@package}{Large}%
\ExecuteOptionsX{rows,columns,width,fontsize,scale,color,bgcolor,cvoffset,
                 counterstyle,title,titleindent,titlewidth}%
\ProcessOptionsX\relax%
\end{lstlisting}
% \iffalse
%</example>
% \fi
% We save the package prefix and name in a macro for easy change. Then we define the options for package \package{bokkusu.sty} and the environment \env{bokkusu}, which are executed afterwards to create the macros for the option values.
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\let\valueH\LP@bottomrow%
\let\valueV\LP@leftcolumn%
\let\sumH\LP@toprow%
\let\sumV\LP@rightcolumn%
\end{lstlisting}
% \iffalse
%</example>
% \fi
% We need numbers around the grid. Therefore, we define some aliases for the existing generic commands.
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\newcommand*\bokkususetup[1]%
{%
  \setkeys{bokkusu.sty}{#1}%
}%
\end{lstlisting}
% \iffalse
%</example>
% \fi
% We define \cmd\bokkususetup\ for resetting the global package options.
% \clearpage
% \noindent{}Finally, we define the \env{bokkusu} environment.
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\newenvironment{bokkusu}[1][]%
{%
  \setkeys{bokkusu}{#1}%
  \LP@set@package{bokkusu}%
  \LP@set@env@prefix{LP@BK}%
  \setcounter{LP@rows}{\LP@BK@rows}%
  \setcounter{LP@columns}{\LP@BK@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
\end{lstlisting}
% \iffalse
%</example>
% \fi
% We locally set the environment options and the prefix and name of the current puzzle environment. We need to reset the counters for \envoption{rows} and \envoption{columns}, as they might have been altered.
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
  \begin{minipage}[t]{\LP@BK@width}%
    \ifthenelse{\equal{\LP@BK@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@BK@titleindent}\parbox{\LP@BK@titlewidth}
      {\strut\LP@titleformat\LP@BK@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[scale=\LP@BK@scale]%
      \LP@drawbackground{1}{1}{\LP@BK@columns}{\LP@BK@rows}{\LP@BK@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@BK@columns}{\LP@BK@rows}{1cm}%
}%
\end{lstlisting}
% \iffalse
%</example>
% \fi
% We start a minipage with width \marg{width}. If the user defined a title, we typeset the title and add a vertical space. Then, we draw the puzzle with the help of \package{tikz.sty}. We start drawing the background and the grid.
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@BK@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
\end{lstlisting}
% \iffalse
%</example>
% \fi
% Finally, we just end the picture for the puzzle. We draw and step the counter. As last action, we need to close the \env{minipage} environment. That's it. Easy, isn't it? You just need to copy this skelton and change or add some code for your specific puzzle.
%
% \section{User documentation}
% \label{sec:code}
% \lstset{basicstyle=\ttfamily\normalsize}%
% \subsection{PGF Layers}
% \label{sec:layer}
% The \package{logicpuzzle.sty} package defines the PGF layers: \layer{LPdump}, \layer{LPbgcolor}, \layer{LPbackgroundtwo}, \layer{LPbackground}, \layer{LPforeground} and \layer{LPforegroundtwo}
%
% Without specifying a special layer, the standard \layer{main} layer is used. The \texttt{LPback\-ground} and \layer{LPforeground} layers can be accessed with the \env{puzzlebackground} and \env{puzzleforeground} environments.
% The \layer{LPbgcolor} is and should only be used for the background color of the grid.
%
% All layers can also be accessed with the generic PGF method:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{pgfonlayer}{layer}
  ...
\end{pgfonlayer}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \begin{tabularx}{\textwidth}{lX}
% Order: & \layer{LPdump} $\rightarrow$ \layer{LPbgcolor} $\rightarrow$ \layer{LPbackgroundtwo} $\rightarrow$ \layer{LPbackground} $\rightarrow$ \layer{main} $\rightarrow$ \layer{LPforeground} $\rightarrow$ \layer{LPforegroundtwo} \\
% \end{tabularx}
%
% So, if you are in the need to place something behind \layer{LPbackground} or in front of \layer{LPforeground}, you can use the \layer{LPbackgroundtwo} and \layer{LPforegroundtwo} layers. You can hide elements like help nodes behind the background color on the \layer{LPdump} layer.
%
% \subsection{Environments}
% \label{sec:env}
% \subsubsection{\texttt{Puzzle environments}}
% \DescribeEnv{logicpuzzle}
% The \env{logicpuzzle} environment is the generic environment for typesetting logic puzzles. With the optional argument of the environment, you can reset the options with local scope. Here, a blank grid is created.
% Furthermore, there are the other puzzle environments. They have their own set of options, that is also different option values and defaults! These can be changed with the \texttt{\textbackslash puzzlesetup} commands with global scope or in the optional argument of the environment with local scope.
%
% \paragraph{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{color}}{}{specifies the color for coloring the cells.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
% \subsubsection{\texttt{Supporting environments}}
% \label{sec:puzzlebackground}
% The \env{puzzlebackground} \DescribeEnv{puzzlebackground}environment allows you to place elements behind the \layer{main} layer on the \layer{LPbackground} layer. This is for example usefull for the \cmd\fillarea\ command.
%
% \label{sec:puzzleforeground}
% The \env{puzzleforeground} \DescribeEnv{puzzleforeground}environment allows you to place elements in front of the \layer{main} layer on the \layer{LPforeground} layer. This is for example usefull for the \cmd\framearea\ command.
%
% \subsection{Commands}
% \subsubsection{In the grid}
% \label{sec:setcell}
% \setlength\leftmargin{0pt}
% \setlength\leftskip{0pt}
% \begin{mydescription}
% \item[\cs{setcell}\marg{column}\marg{row}\marg{element}] \DescribeMacro{\setcell}\mbox{}\\sets an \marg{element} into cell \marg{column}\marg{row} as central node. It is aware of the current values of the surrounding environment options \envoption{rows}, \envoption{columns}, \envoption{scale} and \envoption{fontsize}. Furthermore, a check if \marg{element} is within the grid is applied.
% \label{sec:setcells}
% \item[\cs{setcells}\marg{csv list}\marg{element}] \DescribeMacro{\setcells}\mbox{}\\ sets \marg{element} into several cells by using the \texttt{column}/\texttt{row} format in \marg{csv list}. It works for numbers, letters and most graphical objects, with the exception of commands like \cmd\KKR, which is not a graphic itself, but drawing something into the grid.
% \label{sec:setbigcell}
% \item[\cs{setbigcell}\oarg{fontsize}\marg{column}\marg{row}\marg{element}] \DescribeMacro{\setbigcell}\mbox{}\\sets \marg{element} into a big (\texttt{$2\times2$}) cell \marg{column}\marg{row} as central node. The optional argument \oarg{fontsize} is set to 'Huge' by default.
% \label{sec:setrow}
% \item[\cs{setrow}\marg{row}\marg{csv list}] \DescribeMacro{\setrow}\mbox{}\\sets the contents of a \marg{row}. These may be numbers or letters.
% \label{sec:setcolorrow}
% \item[\cs{setcolorrow}\marg{row}\marg{csv list}] \DescribeMacro{\setcolorrow}\mbox{}\\sets the contents of a \marg{row}. Furthermore, the background of the cell is filled with color \texttt{LP@c@romannumber}. With the number 0, you can black out the grid cell.
% \label{sec:setcolumn}
% \item[\cs{setcolumn}\marg{column}\marg{csv list}] \DescribeMacro{\setcolumn}\mbox{}\\sets the contents of a \marg{column}. These may be numbers or letters.
% \label{sec:setcolorcolumn}
% \item[\cs{setcolorcolumn}\marg{column}\marg{csv list}] \DescribeMacro{\setcolorcolumn}\mbox{}\\sets the contents of a \marg{column}. Furthermore, the background of the cell is filled with color \texttt{LP@c@romannumber}.
% \label{sec:setrule}
% \item[\cs{setrule}\marg{column}\marg{row}\marg{rule}] \DescribeMacro{\setrule}\mbox{}\\sets a calculation rule \marg{rule} into the top left corner of cell \marg{column}\marg{row}. The rule is typeset in inline math mode. You might consider using the \cmd\times\ and \cmd\div\ commands.
% \label{sec:fillcell}
% \item[\cs{fillcell}\marg{column}\marg{row}] \DescribeMacro{\fillcell}\mbox{}\\fills cell \marg{column}\marg{row} with the color defined with environment option \envoption{color}\footnote{Therefore, you must define an option \envoption{color} in the style file you want to use fill commands}. It is aware of the current values of the surrounding envionment options \envoption{rows}, \envoption{columns}, \envoption{scale} and \envoption{color}. Furthermore, a check if the cell is within the grid is applied.
% \label{sec:fillrow}
% \item[\cs{fillrow}\marg{row}\marg{csv list}] \DescribeMacro{\fillrow}\mbox{}\\fills a \marg{row}. In \marg{csv list} '1' means 'fill' and '0' means 'don't fill'. Internally, \cmd\fillrow\ uses \cmd\fillcell.
% \label{sec:fillcolumn}
% \item[\cs{fillcolumn}\marg{column}\marg{csv list}] \DescribeMacro{\fillcolumn}\mbox{}\\fills a \marg{column}. In \marg{csv list} '1' means 'fill' and '0' means 'don't fill'. Internally, \cmd\fillcolumn\ uses \cmd\fillcell.
% \label{sec:filldiagonals}
% \item[\cs{filldiagonals}\oarg{color}] \DescribeMacro{\filldiagonals}\mbox{}\\fills the diagonals with the color specified with the optional argument \oarg{color} (default: yellow!20). Furthermore, it checks for a quadratic grid, otherwise an error message is issued.
% \label{sec:framearea}
% \item[\cs{framearea}\marg{color}\marg{TikZ path}] \DescribeMacro{\framearea}\mbox{}\\frames the area given by \marg{Ti\textit{k}Z path} with color \marg{color}. The reference for coordinates is the bottom left corner of the cell.
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\framearea{green}{(2,2)--(2,3)--(3,3)--(3,2)--(2,2)}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% This command will color the frame of the grid cell \texttt{(2,2)} green. You should consider using this command in the \env{puzzleforeground} environment.
% \label{sec:fillarea}
% \item[\cs{fillarea}\marg{color}\marg{TikZ path}] \DescribeMacro{\fillarea}\mbox{}\\fills the area given by \marg{Ti\textit{k}Z path} with color \marg{color}. The reference for coordinates is the bottom left corner of the cell. You should consider using this command in the \env{puzzlebackground} environment.
% \label{sec:colorarea}
% \item[\cs{colorarea}\marg{color}\marg{TikZ path}] \DescribeMacro{\colorarea}\mbox{}\\fills the area given by \marg{Ti\textit{k}Z path} with color \marg{color} -- just like \cmd\framearea\ without frame.
% \clearpage
% \label{sec:framepuzzle}
% \item[\cs{framepuzzle}\oarg{color}] \DescribeMacro{\framepuzzle}\mbox{}\\frames the grid (thicker line) with the color specified with the optional argument \oarg{color} (default: black).
% \label{sec:tikzpath}
% \item[\cs{tikzpath}\marg{column}\marg{row}\marg{csv list}] \DescribeMacro{\tikzzpath}\mbox{}\\does easily construct a Ti\textit{k}Z path. You just need to define a starting point \marg{column}\marg{row} (bottom left corner) and a \marg{csv list} with direction indicators relative to the current position.
%
% \begin{center}
% \begin{tabular}{rlrlrl}
% 7: & up left & 8: & up & 9: & up right \\
% 4: & left & 5: & no change & 6: & right \\
% 1: & down left & 2: & down & 3: & down right \\
% \end{tabular}
% \end{center}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\framearea{green}{\tikzpath{2}{2}{8,6,2,4}}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% This command will frame grid cell \texttt{(2,2)} green.
%
% \label{sec:xtikzpath}
% \item[\cs{xtikzpath}\marg{column}\marg{row}\marg{csv list}] \DescribeMacro{\xtikzpath}\mbox{}\\is an evolution of the \cmd\tikzpath\ command with slightly different input syntax. In the \marg{csv list} argument, it expects pairs in the form \texttt{direction/length}. Therefore, you can easily define paths from corner to corner.
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\framearea{green}{\xtikzpath{2}{2}{8/2,6/2,2/2,4/2}}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% This command will frame an area defined by the grid cells \texttt{(2,2)} and \texttt{(3,3)} green.
% \end{mydescription}
% \subsubsection{Presentation}
% \begin{mydescription}
% \label{sec:titleformat}
% \item[\cs{titleformat}\marg{format}] \DescribeMacro{\titleformat}\mbox{}\\defines the \marg{format} of the title. By default, the definition is as follows:
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\titleformat{\centering\Large\color{blue}}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \label{sec:puzzlecounter}
% \item[\cs{puzzlecounter}] \DescribeMacro{\puzzlecounter}\mbox{}\\provides the puzzle counter in textual form to use it in \cmd\definecounterstyle.
% \label{sec:setpuzzlecounter}
% \item[\cs{setpuzzlecounter}\marg{number}] \DescribeMacro{\setpuzzlecounter}\mbox{}\\resets the puzzle counter, for example before the solutions.
% \label{sec:definecounterstyle}
% \item[\cs{definecounterstyle}\marg{name}\marg{definition}] \DescribeMacro{\definecounterstyle}\mbox{}\\allows you to define your own styles. For example, the style \texttt{left} is defined as follows:
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\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}
}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% To typeset the counter into the margin we use the command \cmd\marginnote. We need to use the command \cmd\reversemarginpar\ to set the counter into the left margin. Of course, we must use this command in a group for local scope. Finally we use \cmd\puzzlecounter\ in a \cmd\tikz\ node with a vertical offset set with the option \envoption{cvoffset}.
% \label{sec:setgridlinestyle}
% \item[\cs{setgridlinestyle}\marg{style}] \DescribeMacro{\setgridlinestyle}\mbox{}\\sets the style of lines used in the grid. By default, the style is set to \texttt{solid}, whereas \env{slitherlink} uses \texttt{dashed}.
% \label{sec:setnormallinewidth}
% \item[\cs{setnormallinewidth}\marg{dimension}] \DescribeMacro{\setnormallinewidth}\mbox{}\\sets the width of the standard lines (default: \texttt{0.5pt})
% \label{sec:setthicklinewidth}
% \item[\cs{setthicklinewidth}\marg{dimension}] \DescribeMacro{\setthicklinewidth}\mbox{}\\sets the width of the 'thicker' lines (default: \texttt{1.5pt})
% \end{mydescription}
% \subsubsection{Puzzle specific commands}
% \label{sec:pscommands}
% \paragraph{2D-Sudoku}
% \label{sec:pscddsudoku}
% \begin{mydescription}
% \item[\cs{ddsudokucell}\marg{column}\marg{row}\marg{number}] \DescribeMacro{\ddsudokucell}\mbox{}\\
% sets \marg{number} into grid cell \marg{column}\marg{row}.
% \item[\cs{ddsudokusetup}\marg{options}] \DescribeMacro{\ddsudokusetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Battleship}
% \label{sec:pscbattleship}
% \begin{mydescription}
% \item[\cs{placeship}\marg{direction}\marg{column}\marg{row}\marg{length}] \DescribeMacro{\placeship}\mbox{}\\
% places complete ships in the grid. It expects the specification of the direction as horizontal (H) or vertical (V). Furthermore, it requires the starting coordinates and the length of the ship.
% \item[\cs{placesegment}\marg{column}\marg{row}\marg{ship segment}] \DescribeMacro{\placesegment}\mbox{}\\
% is used for the placement of ship segments in the grid. In the mandatory argument \marg{ship segment}, you can use the following commands:
% \begin{center}
% \begin{tabular}{lccl}
% \cs{Ship} & \scalebox{.5}{\Ship} & \scalebox{.5}{\ShipC} & \cs{ShipC} \\
% \cs{ShipL} & \scalebox{.5}{\ShipL} & \scalebox{.5}{\ShipR} & \cs{ShipR} \\
% \cs{ShipB} & \scalebox{.5}{\ShipB} & \scalebox{.5}{\ShipT} & \cs{ShipT} \\
% \end{tabular}
% \end{center}
% \item[\cs{ship}] \DescribeMacro{\ship}\mbox{}\\
% The command \cs{ship} was replaced by the \cs{placesegment} command. The command \cs{ship} is deprecated and should not be used longer. It may still be used, but it is not recommended.
% \item[\cs{placewater}\marg{column}\marg{row}] \DescribeMacro{\placewater}\mbox{}\\
% places water markers \mbox{( \raisebox{2pt}{\Water} )} in the grid.
% \item[\cs{placeisland}\marg{column}\marg{row}] \DescribeMacro{\placeisland}\mbox{}\\
% places islands ( \raisebox{-2pt}{\resizebox{!}{10pt}{\Island}} ) in the grid. The island outlines are created randomly: \raisebox{-2pt}{\resizebox{!}{10pt}{\Island}}, \raisebox{-2pt}{\resizebox{!}{10pt}{\Island}}, \raisebox{-2pt}{\resizebox{!}{10pt}{\Island}}, ...
% \item[\cs{shipH}\marg{csv list}] \DescribeMacro{\shipH}\mbox{}\\
% typesets the horizontal numbers above the grid. It expects a comma-separated list as an argument.
% \subparagraph{\texttt{shipV}}
% \item[\cs{shipV}\marg{csv list}] \DescribeMacro{\shipV}\mbox{}\\
% typesets the vertical numbers beside the grid. It also expects a comma separated list.
% \item[\cs{shipbox}\marg{csv list}] \DescribeMacro{\shipbox}\mbox{}\\
% defines the number and size of the ships, which are typeset under the grid.
% \item[\cs{battleshipsetup}\marg{options}] \DescribeMacro{\battleshipsetup}\mbox{}\\
% resets the options with global scope.
% \item[\cs{classicgame}\marg{csv list}] \DescribeMacro{\classicgame}\mbox{}\\
% typesets a game sheet for playing classic Battleship. It expects a comma separated list with the number and sizes of the ships.
% \end{mydescription}
% \paragraph{Bokkusu}
% \label{sec:pscbokkusu}
% \begin{mydescription}
% \item[\cs{valueH}\marg{csv list}] \DescribeMacro{\valueH}\mbox{}\\
% typesets the numbers left to the grid indicating the values of the cells. It expects a comma-separated list as an argument.
% \item[\cs{valueV}\marg{csv list}] \DescribeMacro{\valueV}\mbox{}\\
% typesets the numbers below the grid specifying the values of the cells. It also expects a comma separated list.
% \item[\cs{sumH}\marg{csv list}] \DescribeMacro{\sumH}\mbox{}\\
% typesets the numbers right to the grid indicating the sums of the values of the colored cells. It expects a comma-separated list.
% \item[\cs{sumV}\marg{csv list}] \DescribeMacro{\sumV}\mbox{}\\
% typesets the numbers above the grid specifying the sums of the values of the colored cells. It expects a comma separated list.
% \item[\cs{bokkususetup}\marg{options}] \DescribeMacro{\bokkususetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Bridges}
% \label{sec:pscbridges}
% \begin{mydescription}
% \item[\cs{bridgesrow}\marg{row}\marg{csv list}] \DescribeMacro{\bridgesrow}\mbox{}\\
% sets the contents of a bridges \marg{row}. These are the numbers indicating how many bridges originate from this specific island.
% \item[\cs{bridgescolumn}\marg{column}\marg{csv list}] \DescribeMacro{\bridgescolumn}\mbox{}\\
% sets the contents of a bridges \marg{column}.
% \item[\cs{bridge}\oarg{optional arguments}marg{Ti\textit{k}Z path}] \DescribeMacro{\bridge}\mbox{}\\
% draws the bridges between islands. With the optional argument \oarg{double} you can draw a double bridge. Furthermore, you can set the color of the bridge with the option \oarg{color}.
% \item[\cs{bridgessetup}\marg{options}] \DescribeMacro{\bridgessetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Chaos Sudoku}
% \label{sec:pscchaossudoku}
% \begin{mydescription}
% \item[\cs{chaossudokucell}\marg{column}\marg{row}\marg{number}] \DescribeMacro{\chaossudokucell}\mbox{}\\
% sets \marg{number} into grid cell \marg{column}\marg{row}.
% \item[\cs{chaossudokusetup}\marg{options}] \DescribeMacro{\chaossudokusetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Four Winds}
% \label{sec:pscfourwinds}
% \begin{mydescription}
% \item[\cs{fourwindscell}\marg{column}\marg{row}\marg{number}] \DescribeMacro{\fourwindscell}\mbox{}\\
% sets \marg{number} into grid cell \marg{column}\marg{row}. Furthermore, it draws lines specified in \marg{csv list} in the \texttt{direction/length} format.
% \item[\cs{fourwindssetup}\marg{options}] \DescribeMacro{\fourwindssetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Hakyuu}
% \label{sec:pschakyuu}
% \begin{mydescription}
% \item[\cs{hakyuucell}\marg{column}\marg{row}\marg{number}] \DescribeMacro{\hakyuucell}\mbox{}\\
% sets \marg{number} into grid cell \marg{column}\marg{row}.
% \item[\cs{hakyuusetup}\marg{options}] \DescribeMacro{\hakyuusetup}\mbox{}\\
% reset the options with global scope.
% \end{mydescription}
% \paragraph{Hitori}
% \label{sec:pschitori}
% \begin{mydescription}
% \item[\cs{hitorisetup}\marg{options}] \DescribeMacro{\hitorisetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Kakuro}
% \label{sec:psckakuro}
% \begin{mydescription}
% \item[\cs{kakurorow}\marg{row}\marg{csv list}] \DescribeMacro{\kakurorow}\mbox{}\\
% sets the contents of a kakuro \marg{row}. These may be numbers and the commands \cmd\KKR\ or \cmd\Black.
% \item[\cs{kakurocolumn}\marg{column}\marg{csv list}] \DescribeMacro{\kakurocolumn}\mbox{}\\
% sets the contents of a kakuro \marg{column}.
% \item[\cs{KKR}\marg{sumV}\marg{sumH}] \DescribeMacro{\KKR}\mbox{}\\
% sets the contents of a kakuro cell.
% \item[\cs{Black}] \DescribeMacro{\Black}\mbox{}\\
% blacks out a cell.
% \item[\cs{kakurosetup}\marg{options}] \DescribeMacro{\kakurosetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Kendoku}
% \label{sec:psckendoku}
% \begin{mydescription}
% \item[\cs{kendokucell}\marg{column}\marg{row}\marg{number}] \DescribeMacro{\kendokucell}\mbox{}\\
% sets \marg{number} into grid cell \marg{column}\marg{row}.
% \item[\cs{kendokusetup}\marg{options}] \DescribeMacro{\kendokusetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Killer Sudoku}
% \label{sec:psckillersudoku}
% \begin{mydescription}
% \item[\cs{killersudokucell}\marg{column}\marg{row}\marg{number}] \DescribeMacro{\killersudokucell}\mbox{}\\
% sets \marg{number} into grid cell \marg{column} \marg{row}.
% \subparagraph{\texttt{killersudokusetup}}
% \item[\cs{killersudokusetup}\marg{options}] \DescribeMacro{\killersudokusetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Laser Beam}
% \label{sec:psclaserbeam}
% \begin{mydescription}
% \item[\cs{laserH}\marg{csv list}] \DescribeMacro{\laserH}\mbox{}\\
% typesets the numbers above the grid indicating how many cells are traversed by the laser beam. It expects a comma-separated list as an argument.
% \item[\cs{laserV}\marg{csv list}] \DescribeMacro{\laserV}\mbox{}\\
% typesets the numbers left to the grid.
% \item[\cs{mirrorH}\marg{csv list}] \DescribeMacro{\mirrorH}\mbox{}\\
% typesets the numbers below the grid indicating how many mirrors are placed in the intersections of this column.
% \item[\cs{mirrorV}\marg{csv list}] \DescribeMacro{\mirrorV}\mbox{}\\
% typesets the numbers right to the grid.
% \subparagraph{\texttt{placearrow}}
% \item[\cs{placearrow}\marg{column}\marg{row}] \DescribeMacro{\placearrow}\mbox{}\\
% is used for the placement of arrows at the grid frame. The reference for coordinates is the bottom left corner of the cell. In the mandatory argument \marg{direction}, you can use the following indicators: LeftUp, LeftDown, RightUp, RightDown
% \item[\cs{placecross}\marg{column}\marg{row}] \DescribeMacro{\placecross}\mbox{}\\
% places a cross in the intersections of the grid.
% \item[\cs{placemirror}\marg{column}\marg{row}\marg{direction}] \DescribeMacro{\placemirror}\mbox{}\\
% places mirrors in the intersections of the grid. In the mandatory argument \marg{direction}, you can use the following indicators: H, V
% \subparagraph{\texttt{laser}}
% \item[\cs{laser}\oarg{color}\marg{Ti\textit{k}Z path}] \DescribeMacro{\laser}\mbox{}\\
% draws the laser beam given by \marg{Ti\textit{k}Z path} with color \oarg{color} (default: red). The reference for coordinates is the bottom left corner of the cell.
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\laser[green]{(1,2)--(2,3)--(1,4)}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% You should consider using this command in the \env{puzzlebackground} environment.
% \item[\cs{laserbeamsetup}\marg{options}] \DescribeMacro{\laserbeamsetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Magic Labyrinth}
% \label{sec:pscmagiclabyrinth}
% \begin{mydescription}
% \item[\cs{magiclabyrinthcell}\marg{column}\marg{row}\marg{number}] \DescribeMacro{\magiclabyrinthcell}\mbox{}\\
% sets a number into grid cell \marg{column} \marg{row}.
% \item[\cs{mlline}\marg{Ti\textit{k}Z path}] \DescribeMacro{\mlline}\mbox{}\\
% draws a line given by \marg{Ti\textit{k}Z path}.
% \item[\cs{magiclabyrinthsetup}\marg{options}] \DescribeMacro{\magiclabyrinthsetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Magnets}
% \label{sec:pscmagnets}
% \begin{mydescription}
% \item[\cs{plusH}\marg{csv list}] \DescribeMacro{\plusH}\mbox{}\\
% typesets the numbers above the grid indicating how many positive poles are in the respective column. It expects a comma-separated list as an argument.
% \item[\cs{minusH}\marg{csv list}] \DescribeMacro{\minusH}\mbox{}\\
% typesets the numbers above the grid indicating how many negative poles are in the respective column.
% \item[\cs{plusV}\marg{csv list}] \DescribeMacro{\plusV}\mbox{}\\
% typesets the numbers left to the grid indicating how many positive poles are in the respective row.
% \item[\cs{minusV}\marg{csv list}] \DescribeMacro{\minusV}\mbox{}\\
% typesets the numbers left to the grid indicating how many negative pole ares in the respective row.
% \item[\cs{magnetsH}\marg{csv list}] \DescribeMacro{\magnetsH}\mbox{}\\
% typesets non-magnetic  horizontal plates by using the \texttt{column}/\texttt{row} format in \marg{csv list}.
% \subparagraph{\texttt{magnetsV}}
% \item[\cs{magnetsV}\marg{csv list}] \DescribeMacro{\magnetsV}\mbox{}\\
% typesets non-magnetic vertical plates by using the \texttt{column}/\texttt{row} format in \marg{csv list}.
% \item[\cs{PMH}\marg{csv list}] \DescribeMacro{\PMH}\DescribeMacro{\MPH}\DescribeMacro{\PMV}\DescribeMacro{\MPV}\mbox{}\\
% draws horizontal magnetic plates with \fbox{$+$ $-$} arrangement. It expects the \texttt{column}/\texttt{row} format in \marg{csv list}. You can typeset the three other magnetic arrangements by using the \cmd\MPH, \cmd\PMV\ and \cmd\MPV\ commands.
% \item[\cs{magnetssetup}\marg{options}] \DescribeMacro{\magnetssetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Masyu}
% \label{sec:pscmasyu}
% \begin{mydescription}
% \item[\cs{masyucell}\marg{column}\marg{row}\marg{element}] \DescribeMacro{\masyucell}\mbox{}\\
% sets an element into grid cell \marg{column} \marg{row}.
% \item[\cs{MasyuW}] \DescribeMacro{\MasyuW}\mbox{}\\
% draws an empty (white) circle.
% \item[\cs{MasyuB}] \DescribeMacro{\MasyuB}\mbox{}\\
% draws a black circle. 
% \item[\cs{masyuline}\marg{Ti\textit{k}Z path}] \DescribeMacro{\masyuline}\mbox{}\\
% draws a line given by \marg{Ti\textit{k}Z path}.
% \item[\cs{masyusetup}\marg{options}] \DescribeMacro{\masyusetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Minesweeper}
% \label{sec:pscminesweeper}
% \begin{mydescription}
% \item[\cs{Mine}] \DescribeMacro{\Mine}\mbox{}\\
% draws a mine. It can be used in commands like \cmd\setcell\ or \cmd\setrow! 
% \item[\cs{minesweepersetup}\marg{options}] \DescribeMacro{\minesweepersetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Nonogram}
% \label{sec:pscnonogram}
% \begin{mydescription}
% \item[\cs{nonogramrow}\marg{row}\marg{csv list}] \DescribeMacro{\nonogramrow}\mbox{}\\
% sets the contents of row \marg{row}. In \marg{csv list} it expects the \texttt{column/length} format.
% \item[\cs{nonogramcolumn}\marg{column}\marg{csv list}] \DescribeMacro{\nonogramcolumn}\mbox{}\\
% sets the contents of column \marg{column}. In \marg{csv list} it expects the \texttt{row/length} format.
% \item[\cs{nonogramV}\marg{csv list}] \DescribeMacro{\nonogramV}\mbox{}\\
% sets the contents of the extra cells left to the grid. By definition, the first number is always typeset next to the grid!
% \item[\cs{nonogramH}\marg{csv list}] \DescribeMacro{\nonogramH}\mbox{}\\
% sets the contents of the extra cells on top of the grid.
% \item[\cs{puzzlestrut}] \DescribeMacro{\puzzlestrut}\mbox{}\\
% serves the height adjustment depending on option \texttt{extracells} when you want to typeset puzzle and solution (without extra cells) next to each other.
% \item[\cs{nonogramsetup}\marg{options}] \DescribeMacro{\nonogramsetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Number Link}
% \label{sec:pscnumberlink}
% \begin{mydescription}
% \item[\cs{numberlinkcell}\marg{column}\marg{row}\marg{element}] \DescribeMacro{\numberlinkcell}\mbox{}\\
% sets a number or letter into grid cell \marg{column}\marg{row}.
% \item[\cs{link}\marg{\marg{Ti\textit{k}Z path}}] \DescribeMacro{\link}\mbox{}\\
% draws a line given by \marg{Ti\textit{k}Z path}.
% \item[\cs{numberlinksetup}\marg{options}] \DescribeMacro{\numberlinksetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Resuko}
% \label{sec:pscresuko}
% \begin{mydescription}
% \item[\cs{resukocell}\marg{column}\marg{row}\marg{element}] \DescribeMacro{\resukocell}\mbox{}\\
% sets the \marg{element} into grid cell \marg{column}\marg{row}.
% \subparagraph{\texttt{Track tiles}}
% \DescribeMacro{\Straight}\DescribeMacro{\StraightH}\DescribeMacro{\StraightV}\DescribeMacro{\Cross}\DescribeMacro{\CrossH}\DescribeMacro{\CrossV}
%
% \DescribeMacro{\CurveTL}\DescribeMacro{\CurveTR}\DescribeMacro{\CurveBL}\DescribeMacro{\CurveBR}\DescribeMacro{\Graveltrap}
% You can use the following commands to draw different track tiles, e.g. with the \cmd\resukocell\ command:
%
% \begin{center}
% \begin{tabular}{rlrlrl}
% \raisebox{-7pt}{\Straight} & \cmd\Straight & \raisebox{-7pt}{\StraightH} & \cmd\StraightH & \raisebox{-7pt}{\StraightV} & \cmd\StraightV \\
% & & & & & \\
% \raisebox{-7pt}{\Cross} & \cmd\Cross & \raisebox{-7pt}{\CrossH} & \cmd\CrossH & \raisebox{-7pt}{\CrossV} & \cmd\CrossV \\
% & & & & & \\
% \raisebox{-7pt}{\CurveTL} & \cmd\CurveTL & \raisebox{-7pt}{\CurveTR} & \cmd\CurveTR & \raisebox{-7pt}{\CurveBL} & \cmd\CurveBL \\
% & & & & & \\
% \raisebox{-7pt}{\CurveBR} & \cmd\CurveBR & \raisebox{-7pt}{\Graveltrap} & \cmd\Graveltrap & \\
% \end{tabular}
% \end{center}
%
% \item[\cs{pitlane}\marg{column}\marg{row}\marg{direction}] \DescribeMacro{\pitlane}\mbox{}\\
% draws the pit lane in grid cell \{\marg{column}\}\{\marg{row}\} with \{\marg{direction}\} V or H.
% \item[\cs{parkinglot}\marg{column}\marg{row}] \DescribeMacro{\parkinglot}\mbox{}\\
% draws the parking lot in grid cell \marg{column}\marg{row}.
% \item[\cs{trackH}\marg{csv list}] \DescribeMacro{\trackH}\mbox{}\\
% typesets the track tiles below the grid indicating how many different tiles are in the respective column. It expects a comma-separated list as an argument with the format \texttt{straights/curves/intersections}.
% \item[\cs{trackV}\marg{csv list}] \DescribeMacro{\trackV}\mbox{}\\
% typesets the track tiles left to the grid.
% \item[\cs{track}\marg{Ti\textit{k}Z path}] \DescribeMacro{\track}\mbox{}\\
% draws the race track given by \marg{Ti\textit{k}Z path}. The design of the race track is based on \href{http://tex.stackexchange.com/users/3708/frederic}{Frédéric}'s answer to this \href{http://tex.stackexchange.com/questions/115923/crossing-paths-in-tikz-without-intersection}{question} on \TeX.sx. The design with auto-generated bridges will only work, if the path is not constructed with an intersection point. It's recommended to start the path on a standard straight and define the path from corner to corner with \cmd\xtikzpath.
% \item[\cs{resukosetup}\marg{options}] \DescribeMacro{\resukosetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Schatzsuche}
% \label{sec:pscschatzsuche}
% \begin{mydescription}
% \item[\cs{Diamond}] \DescribeMacro{\Diamond}\mbox{}\\
% draws a diamond. It can be used in commands like \cmd\setcell\ or \cmd\setrow! 
% \item[\cs{schatzsuchesetup}\marg{options}] \DescribeMacro{\schatzsuchesetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Skyline}
% \label{sec:pscskyline}
% \begin{mydescription}
% \item[\cs{skylineT}\marg{csv list}] \DescribeMacro{\skylineT}\mbox{}\\
% typesets the numbers above the grid indicating how many skycrapers are visible. It expects a comma-separated list as an argument.
% \item[\cs{skylineB}\marg{csv list}] \DescribeMacro{\skylineB}\mbox{}\\
% typesets the numbers below the grid.
% \item[\cs{skylineL}\marg{csv list}] \DescribeMacro{\skylineL}\mbox{}\\
% typesets the numbers left to the grid.
% \item[\cs{skylineR}\marg{csv list}] \DescribeMacro{\skylineR}\mbox{}\\
% typesets the numbers right to the grid.
% \item[\cs{skylinecell}\marg{column}\marg{row}\}\marg{height}] \DescribeMacro{\skylinecell}\mbox{}\\
% sets \marg{height} into grid cell \marg{column}\marg{row}.
% \item[\cs{skylinesetup}\marg{options}] \DescribeMacro{\skylinesetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Slitherlink}
% \label{sec:pscslitherlink}
% \begin{mydescription}
% \item[\cs{slitherlinkcell}\marg{column}\marg{row}\marg{number}] \DescribeMacro{\slitherlinkcell}\mbox{}\\
% sets \marg{number} into grid cell \marg{column}\marg{row}.
% \item[\cs{slitherlinksetup}\marg{options}] \DescribeMacro{\slitherlinksetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Star Battle}
% \label{sec:pscstarbattle}
% \begin{mydescription}
% \item[\cs{starbattlecell}\marg{column}\marg{row}\marg{element}] \DescribeMacro{\starbattlecell}\mbox{}\\
% sets \marg{element} into grid cell \marg{column}\marg{row}, e.g. the \cmd\Star\ command.
% \item[\cs{starbattlesetup}\marg{options}] \DescribeMacro{\starbattlesetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Stars and Arrows}
% \label{sec:pscstarsandarrows}
% \begin{mydescription}
% \item[\cs{starsH}\marg{csv list}] \DescribeMacro{\starsH}\mbox{}\\
% typesets the numbers above the grid indicating how many stars are in the respective column. It expects a comma-separated list as an argument.
% \item[\cs{starsV}\marg{csv list}] \DescribeMacro{\starsV}\mbox{}\\
% typesets the numbers left to the grid.
% \item[\cs{Star}] \DescribeMacro{\Star}\mbox{}\\
% draws a star. It can be used in commands like \cmd\setcell\ or \cmd\setrow!
% \subparagraph{Arrows}
% \DescribeMacro{\Right}\DescribeMacro{\RightUp}\DescribeMacro{\Up}\DescribeMacro{\LeftUp}
%
% \DescribeMacro{\Left}\DescribeMacro{\LeftDown}\DescribeMacro{\Down}\DescribeMacro{\RightDown}
% You can use the following commands to draw different arrows:
%
% \begin{center}
% \begin{tabular}{lrlrlrlr}
% \cmd\Right & \raisebox{3pt}{\Right} & \cmd\RightUp & \raisebox{-4pt}{\RightUp} & \cmd\Up & \raisebox{-7pt}{\Up} & \cmd\LeftUp & \raisebox{-4pt}{\LeftUp} \\
% \cmd\Left & \raisebox{3pt}{\Left} & \cmd\LeftDown & \raisebox{-4pt}{\LeftDown} & \cmd\Down & \raisebox{-7pt}{\Down} & \cmd\RightDown & \raisebox{-4pt}{\RightDown} \\
% \end{tabular}
% \end{center}
% \item[\cs{starsandarrowssetup}\marg{options}] \DescribeMacro{\starsandarrowssetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Sudoku}
% \label{sec:psclpsudoku}
% \begin{mydescription}
% \item[\cs{lpsudokucell}\marg{column}\marg{row}\marg{number}] \DescribeMacro{\lpsudokucell}\mbox{}\\
% sets \marg{number} into grid cell \marg{column}\marg{row}.
% \item[\cs{lpsudokusetup}\marg{options}] \DescribeMacro{\lpsudokusetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Sun and Moon}
% \label{sec:pscsunandmoon}
% \begin{mydescription}
% \item[\cs{Star}] \DescribeMacro{\Star}\mbox{}\\
% draws a star. It can be used in commands like \cmd\setcell\ or \cmd\setrow!
% \item[\cs{Cloud}] \DescribeMacro{\Cloud}\mbox{}\\
% draws a dark cloud.
% \subparagraph{Howl at the Moon}
% \DescribeMacro{\Moon}\DescribeMacro{\MoonT}\DescribeMacro{\MoonB}\DescribeMacro{\MoonR}\DescribeMacro{\MoonL}
%
% \DescribeMacro{\MoonTR}\DescribeMacro{\MoonTL}\DescribeMacro{\MoonBR}\DescribeMacro{\MoonBL}
% You can use the following commands to draw different iluminated moons:
%
% \begin{center}
% \begin{tabular}{lrlrlr}
% \cmd\Moon & \raisebox{-4pt}{\Moon} & \cmd\MoonT & \raisebox{-4pt}{\MoonT} & \cmd\MoonB & \raisebox{-4pt}{\MoonB} \\
% & & & & & \\
% \cmd\MoonR & \raisebox{-4pt}{\MoonR} & \cmd\MoonL & \raisebox{-4pt}{\MoonL} & \cmd\MoonTR & \raisebox{-4pt}{\MoonTR} \\
% & & & & & \\
% \cmd\MoonTL & \raisebox{-4pt}{\MoonTL} & \cmd\MoonBR & \raisebox{-4pt}{\MoonBR} & \cmd\MoonBL & \raisebox{-4pt}{\MoonBL} \\
% \end{tabular}
% \end{center}
% \item[\cs{sunandmoonssetup}\marg{options}] \DescribeMacro{\sunandmoonssetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Tents and Trees}
% \label{sec:psctentsandtrees}
% \begin{mydescription}
% \item[\cs{tentH}\marg{csv list}] \DescribeMacro{\tentH}\mbox{}\\
% typesets the numbers above the grid indicating how many tents are in the respective column. It expects a comma-separated list as an argument.
% \item[\cs{tentV}\marg{csv list}] \DescribeMacro{\tentV}\mbox{}\\
% typesets the numbers left to the grid.
% \item[\cs{Tree}] \DescribeMacro{\Tree}\mbox{}\\
% draws a tree. It can be used in commands like \cmd\setcell\ or \cmd\setrow! The design of the tree is based on \href{http://tex.stackexchange.com/users/3144/alain-matthes}{Alain Matthes}' answer to this \href{http://tex.stackexchange.com/questions/39149/how-can-we-draw-a-christmas-tree-with-decorations-using-tikz}{question} on \TeX.sx.
% \item[\cs{Tent}] \DescribeMacro{\Tent}\mbox{}\\
% draws a tent.
% \item[\cs{tentsandtreessetup}\marg{options}] \DescribeMacro{\tentsandtreessetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \paragraph{Tunnel}
% \label{sec:psctunnel}
% \begin{mydescription}
% \item[\cs{tunnelH}\marg{csv list}] \DescribeMacro{\tunnelH}\mbox{}\\
% typesets the numbers above the grid indicating how many tube segments are in the respective column. It expects a comma-separated list as an argument.
% \item[\cs{tunnelV}\marg{csv list}] \DescribeMacro{\tunnelV}\mbox{}\\
% typesets the numbers left to the grid.
% \item[\cs{portal}\marg{column}\}\{\marg{row}] \DescribeMacro{\portal}\mbox{}\\
% is used for the placement of tunnel portals in the grid.
% \item[\cs{tube}\marg{Ti\textit{k}Z path}] \DescribeMacro{\tube}\mbox{}\\
% draws the tunnel tube given by \marg{Ti\textit{k}Z path}. The reference for coordinates is the center of the cell. The design of the tube is based on \href{http://tex.stackexchange.com/users/16772/xoff}{Xoff}'s answer to this \href{http://tex.stackexchange.com/questions/109410/how-to-pimp-my-tube}{question} on \TeX.sx.
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\tube{(1.5,2.5)--(3.5,2.5)--(3.5,4.5)}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \item[\cs{tunnelsetup}\marg{options}] \DescribeMacro{\tunnelsetup}\mbox{}\\
% resets the options with global scope.
% \end{mydescription}
% \section{Examples}
% \subsection{2D-Sudoku}
% Fill every row, every column and each of the two diagonals -- if indicated -- with numbers from 1 to SIZE of the grid.
%
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{ddsudoku}
%     \framepuzzle
%     \filldiagonals[orange!50]
%     \ddsudokucell{1}{5}{1}
%     \ddsudokucell{1}{4}{3}
%     \ddsudokucell{2}{3}{4}
%     \ddsudokucell{4}{1}{3}
%     \ddsudokucell{4}{3}{2}
%     \ddsudokucell{5}{4}{4}
%   \end{ddsudoku}
%   \hspace{1.5cm}
%   \begin{ddsudoku}
%     \framepuzzle
%     \filldiagonals[orange!50]
%     \setrow{5}{1,3,4,5,2}
%     \setrow{4}{3,2,5,1,4}
%     \setrow{3}{5,4,3,2,1}
%     \setrow{2}{2,5,1,4,3}
%     \setrow{1}{4,1,2,3,5}
%   \end{ddsudoku}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{ddsudoku}
    \framepuzzle
    \filldiagonals[orange!50]
    \ddsudokucell{1}{5}{1}
    \ddsudokucell{1}{4}{3}
    \ddsudokucell{2}{3}{4}
    \ddsudokucell{4}{1}{3}
    \ddsudokucell{4}{3}{2}
    \ddsudokucell{5}{4}{4}
  \end{ddsudoku}
  \hspace{1.5cm}
  \begin{ddsudoku}
    \framepuzzle
    \filldiagonals[orange!50]
    \setrow{5}{1,3,4,5,2}
    \setrow{4}{3,2,5,1,4}
    \setrow{3}{5,4,3,2,1}
    \setrow{2}{2,5,1,4,3}
    \setrow{1}{4,1,2,3,5}
  \end{ddsudoku}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Battleship}
% Try to find the positions of the ships listed below the puzzle. The numbers on the side of the puzzle reveals how many ship segments can be found in the rows and columns. All remaining fields indicate 'water'. Consider the following rules: The ships are arranged horizontally and vertically. No ship touches another ship at any point, not even diagonally.
%
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
% \begin{battleship}
% \placesegment{4}{1}{\ShipR}
% \shipH{4,1,2,2,2}
% \shipV{3,1,4,0,3}
% \shipbox{3,3,2,2,1}
% \end{battleship}
% \hspace{1.5cm}
% \begin{battleship}
% \placeship{V}{1}{1}{3}
% \placeship{H}{1}{5}{2}
% \placeship{H}{3}{1}{2}
% \placeship{H}{3}{3}{3}
% \placeship{H}{5}{5}{1}
% \shipH{4,1,2,2,2}
% \shipV{3,1,4,0,3}
% \end{battleship}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{battleship}
    \placesegment{4}{1}{\ShipR}
    \shipH{4,1,2,2,2}
    \shipV{3,1,4,0,3}
    \shipbox{3,3,2,2,1}
  \end{battleship}
  \hspace{1.5cm}
  \begin{battleship}
    \placeship{V}{1}{1}{3}
    \placeship{H}{1}{5}{2}
    \placeship{H}{3}{1}{2}
    \placeship{H}{3}{3}{3}
    \placeship{H}{5}{5}{1}
    \shipH{4,1,2,2,2}
    \shipV{3,1,4,0,3}
  \end{battleship}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid.}
%   \optitem{shipcolor}{green}{sets the color of the ship segments.}
%   \optitem{\envoption{width}}{6cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0.75cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.15cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{sbindent}}{0.75cm}{defines the indent of the ship box below the grid.}
% \optitem{\envoption{sbwidth}}{5.15cm}{specifies the width of the minipage, in which the ships are typeset.}
%   \optitem{\envoption{sbshipscale}}{1}{scales the size of the ships in the ship box.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Bokkusu}
% Black out some of the grid cells. The numbers on the left and the bottom edge of the grid indicate the values of the cells for adding up. The numbers on the right and the top edge of the grid specify the sums of the values of the colored cells.
%
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{bokkusu}
%     \valueH{1,2,3,4,5}
%     \valueV{1,2,3,4,5}
%     \sumH{7,1,11,9,6}
%     \sumV{2,12,5,13,?}
%   \end{bokkusu}
%   \hspace{1.5cm}
%   \begin{bokkusu}
%     \valueH{1,2,3,4,5}
%     \valueV{1,2,3,4,5}
%     \sumH{7,1,11,9,6}
%     \sumV{2,12,5,13,?}
%     \fillrow{1}{0,1,0,0,0}
%     \fillrow{2}{0,0,1,1,1}
%     \fillrow{3}{1,0,0,1,0}
%     \fillrow{4}{1,0,1,1,1}
%     \fillrow{5}{0,0,1,0,0}
%   \end{bokkusu}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{bokkusu}
    \valueH{1,2,3,4,5}
    \valueV{1,2,3,4,5}
    \sumH{7,1,11,9,6}
    \sumV{2,12,5,13,?}
  \end{bokkusu}
  \hspace{1.5cm}
  \begin{bokkusu}
    \valueH{1,2,3,4,5}
    \valueV{1,2,3,4,5}
    \sumH{7,1,11,9,6}
    \sumV{2,12,5,13,?}
    \fillrow{5}{0,0,1,0,0}
    \fillrow{4}{1,0,1,1,1}
    \fillrow{3}{1,0,0,1,0}
    \fillrow{2}{0,0,1,1,1}
    \fillrow{1}{0,1,0,0,0}
  \end{bokkusu}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{6.7cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0.75cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.85cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{color}}{black}{specifies the color for coloring the cells.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-38pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Bridges}
% Connect all the islands (circles) located in the grid by bridges. The bridges may only be routed horizontally and vertically. Islands may be connected by a maximum of two bridges. The bridges must neither overlap nor cross. They may also not be built over islands. The numbers in the islands indicate how many bridges originate from this island. All islands must be fully connected.
%
% \subsubsection{Example}
% \colorlet{LP@c@bridge}{Teal}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{bridges}
%     \framepuzzle
%     \bridgesrow{8}{{},4,{},{},{},5,{},2}
%     \bridgesrow{7}{{},{},1}
%     \bridgesrow{5}{{},{},3,{},4}
%     \bridgesrow{4}{{},3,{},1,{},2}
%     \bridgesrow{3}{{},{},{},{},{},{},{}}
%     \bridgesrow{2}{{},2,{},{},5,{},{},2}
%   \end{bridges}
%   \hspace{1.5cm}
%   \begin{bridges}[grid=none]
%     \framepuzzle
%     \bridgesrow{8}{{},4,{},{},{},5,{},2}
%     \bridgesrow{7}{{},{},1}
%     \bridgesrow{5}{{},{},3,{},4}
%     \bridgesrow{4}{{},3,{},1,{},2}
%     \bridgesrow{3}{{},{},{},{},{},{},{}}
%     \bridgesrow{2}{{},2,{},{},5,{},{},2}
%     \bridge[double]{\tikzpath{2}{4}{8,8,8,8,6,6,6,6,2,2,2,2}}
%     \bridge[double]{\tikzpath{2}{2}{6,6,6,8,8,8,4,4}}
%     \bridge{\tikzpath{2}{4}{6,6}}
%     \bridge{\tikzpath{3}{5}{8,8}}
%     \bridge{\tikzpath{5}{2}{6,6,6,8,8,8,8,8,8,4,4}}
%   \end{bridges}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\colorlet{LP@c@bridge}{Teal}
\begin{center}
  \begin{bridges}
    \framepuzzle
    \bridgesrow{8}{{},4,{},{},{},5,{},2}
    \bridgesrow{7}{{},{},1}
    \bridgesrow{5}{{},{},3,{},4}
    \bridgesrow{4}{{},3,{},1,{},2}
    \bridgesrow{3}{{},{},{},{},{},{},{}}
    \bridgesrow{2}{{},2,{},{},5,{},{},2}
  \end{bridges}
  \hspace{1.5cm}
  \begin{bridges}[grid=none]
    \framepuzzle
    \bridgesrow{8}{{},4,{},{},{},5,{},2}
    \bridgesrow{7}{{},{},1}
    \bridgesrow{5}{{},{},3,{},4}
    \bridgesrow{4}{{},3,{},1,{},2}
    \bridgesrow{3}{{},{},{},{},{},{},{}}
    \bridgesrow{2}{{},2,{},{},5,{},{},2}
    \bridge[double]{\tikzpath{2}{4}{8,8,8,8,6,6,6,6,2,2,2,2}}
    \bridge[double]{\tikzpath{2}{2}{6,6,6,8,8,8,4,4}}
    \bridge{\tikzpath{2}{4}{6,6}}
    \bridge{\tikzpath{3}{5}{8,8}}
    \bridge{\tikzpath{5}{2}{6,6,6,8,8,8,8,8,8,4,4}}
  \end{bridges}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{6.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{6.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{color}}{green}{specifies the color for coloring the islands.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
%   \optitem{\envoption{grid}}{dashed}{sets the style of the grid. Possible values: \underline{\texttt{dashed}}, \texttt{none}, \texttt{solid}}
% \end{optionlist}
%
% \subsection{Chaos Sudoku}
% Fill the cells of an area with numbers from 1 to N of the N*N grid. Each number can appear only once - in each area, column, row or diagonal if indicated.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{chaossudoku}
%     \chaossudokucell{1}{1}{3}
%     \chaossudokucell{1}{5}{4}
%     \chaossudokucell{3}{2}{4}
%     \chaossudokucell{4}{2}{5}
%     \chaossudokucell{5}{5}{2}
%     \begin{puzzlebackground}
%       \fillarea{Wheat}{(1,1)--(1,2)--(2,2)--(2,3)--(4,3)--(4,1)--(1,1)}
%       \fillarea{HotPink!30}{(1,2)--(1,6)--(3,6)--(3,5)--(2,5)--(2,2)--(1,2)}
%       \fillarea{GreenYellow}{(2,3)--(2,5)--(3,5)--(3,4)--(5,4)--(5,2)--(4,2)--(4,3)--(2,3)}
%       \fillarea{LightBlue}{(3,4)--(3,6)--(6,6)--(6,5)--(5,5)--(5,4)--(3,4)}
%       \fillarea{LightYellow}{(4,1)--(4,2)--(5,2)--(5,5)--(6,5)--(6,1)--(4,1)}
%     \end{puzzlebackground} 
%   \end{chaossudoku}
%   \hspace{1.5cm}
%   \begin{chaossudoku}
%     \setrow{5}{4,3,5,1,2}
%     \setrow{4}{2,1,3,4,5}
%     \setrow{3}{5,4,2,3,1}
%     \setrow{2}{1,2,4,5,3}
%     \setrow{1}{3,5,1,2,4}
%     \begin{puzzlebackground}
%       \fillarea{Wheat}{\tikzpath{1}{1}{8,6,8,6,6,2,2,4,4,4}}
%       \fillarea{HotPink!30}{\tikzpath{1}{2}{8,8,8,8,6,6,2,4,2,2,2,4}}
%       \fillarea{GreenYellow}{\tikzpath{2}{3}{8,8,6,2,6,6,2,2,4,8,4,4}}
%       \fillarea{LightBlue}{\tikzpath{3}{4}{8,8,6,6,6,2,4,2,4,4}}
%       \fillarea{LightYellow}{\tikzpath{4}{1}{8,6,8,8,8,6,2,2,2,2,4,4}}
%     \end{puzzlebackground} 
%   \end{chaossudoku}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{chaossudoku}
    \chaossudokucell{1}{1}{3}
    \chaossudokucell{1}{5}{4}
    \chaossudokucell{3}{2}{4}
    \chaossudokucell{4}{2}{5}
    \chaossudokucell{5}{5}{2}
    \begin{puzzlebackground}
      \fillarea{Wheat}{(1,1)--(1,2)--(2,2)--(2,3)--(4,3)--(4,1)
                       --(1,1)}
      \fillarea{HotPink!30}{(1,2)--(1,6)--(3,6)--(3,5)--(2,5)
                            --(2,2)--(1,2)}
      \fillarea{GreenYellow}{(2,3)--(2,5)--(3,5)--(3,4)--(5,4)
                             --(5,2)--(4,2)--(4,3)--(2,3)}
      \fillarea{LightBlue}{(3,4)--(3,6)--(6,6)--(6,5)--(5,5)
                           --(5,4)--(3,4)}
      \fillarea{LightYellow}{(4,1)--(4,2)--(5,2)--(5,5)--(6,5)
                             --(6,1)--(4,1)}
    \end{puzzlebackground} 
  \end{chaossudoku}
  \hspace{1.5cm}
  \begin{chaossudoku}
    \setrow{5}{4,3,5,1,2}
    \setrow{4}{2,1,3,4,5}
    \setrow{3}{5,4,2,3,1}
    \setrow{2}{1,2,4,5,3}
    \setrow{1}{3,5,1,2,4}
    \begin{puzzlebackground}
      \fillarea{Wheat}{(1,1)--(1,2)--(2,2)--(2,3)--(4,3)--(4,1)
                       --(1,1)}
      \fillarea{HotPink!30}{(1,2)--(1,6)--(3,6)--(3,5)--(2,5)
                            --(2,2)--(1,2)}
      \fillarea{GreenYellow}{(2,3)--(2,5)--(3,5)--(3,4)--(5,4)
                             --(5,2)--(4,2)--(4,3)--(2,3)}
      \fillarea{LightBlue}{(3,4)--(3,6)--(6,6)--(6,5)--(5,5)
                           --(5,4)--(3,4)}
      \fillarea{LightYellow}{(4,1)--(4,2)--(5,2)--(5,5)--(6,5)
                             --(6,1)--(4,1)}
    \end{puzzlebackground} 
  \end{chaossudoku}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Four Winds}
% Fill all cells with light rays. These may not intersect. Cells with numbers represent the lighting system that lits horizontally and vertically. The number indicates how many cells are illuminated. Cells with numbers do not count. No cell must remain empty.
%
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
% \begin{fourwinds}
%   \framepuzzle
%   \fourwindscell{1}{2}{2}{}
%   \fourwindscell{1}{5}{2}{}
%   \fourwindscell{2}{4}{3}{}
%   \fourwindscell{3}{3}{3}{}
%   \fourwindscell{4}{1}{4}{}
%   \fourwindscell{5}{5}{5}{}
% \end{fourwinds}
% \hspace{1.5cm}
% \begin{fourwinds}
%   \framepuzzle
%   \fourwindscell{1}{2}{2}{2/1,6/1}
%   \fourwindscell{1}{5}{2}{2/2}
%   \fourwindscell{2}{4}{3}{8/1,6/2}
%   \fourwindscell{3}{3}{3}{4/1,6/1,2/1}
%   \fourwindscell{4}{1}{4}{4/2,6/1,8/1}
%   \fourwindscell{5}{5}{5}{4/2,2/3}
% \end{fourwinds}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{fourwinds}
  \framepuzzle
  \fourwindscell{1}{2}{2}{}
  \fourwindscell{1}{5}{2}{}
  \fourwindscell{2}{4}{3}{}
  \fourwindscell{3}{3}{3}{}
  \fourwindscell{4}{1}{4}{}
  \fourwindscell{5}{5}{5}{}
\end{fourwinds}
\hspace{1.5cm}
\begin{fourwinds}
  \framepuzzle
  \fourwindscell{1}{2}{2}{2/1,6/1}
  \fourwindscell{1}{5}{2}{2/2}
  \fourwindscell{2}{4}{3}{8/1,6/2}
  \fourwindscell{3}{3}{3}{4/1,6/1,2/1}
  \fourwindscell{4}{1}{4}{4/2,6/1,8/1}
  \fourwindscell{5}{5}{5}{4/2,2/3}
\end{fourwinds}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{color}}{blue}{sets the color of the lines.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Hakyuu}
% Fill the cells of an area with numbers from 1 to SIZE of the area. If there are two cells with the same number N in a row or a column, there must be at least N cells between those two cells.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{hakyuu}
%     \hakyuucell{1}{5}{2}
%     \hakyuucell{3}{5}{6}
%     \hakyuucell{4}{5}{5}
%     \hakyuucell{4}{4}{4}
%     \hakyuucell{1}{3}{3}
%     \hakyuucell{2}{2}{2}
%     \hakyuucell{5}{2}{5}
%     \hakyuucell{4}{1}{1}
%     \begin{puzzlebackground}
%       \fillarea{Wheat}{(1,1)--(1,4)--(2,4)--(2,1)--(1,1)}
%       \fillarea{HotPink!30}{(1,4)--(1,6)--(6,6)--(6,5)--(3,5)--(3,4)--(1,4)}
%       \fillarea{GreenYellow}{(2,4)--(3,4)--(3,5)--(5,5)--(5,4)--(4,4)--(4,3)--(2,3)--(2,4)}
%       \fillarea{LightBlue}{(5,5)--(6,5)--(6,3)--(4,3)--(4,4)--(5,4)--(5,5)}
%       \fillarea{LightSalmon!50}{(2,2)--(2,3)--(5,3)--(5,2)--(2,2)}
%       \fillarea{LightYellow}{(2,1)--(2,2)--(5,2)--(5,3)--(6,3)--(6,1)--(2,1)}
%     \end{puzzlebackground} 
%   \end{hakyuu}
%   \hspace{1.5cm}
%   \begin{hakyuu}
%     \setrow{5}{2,3,6,5,4}
%     \setrow{4}{1,7,3,4,2}
%     \setrow{3}{3,1,2,1,3}
%     \setrow{2}{1,2,1,3,5}
%     \setrow{1}{2,3,4,1,2}
%     \begin{puzzlebackground}
%       \fillarea{Wheat}{(1,1)--(1,4)--(2,4)--(2,1)--(1,1)}
%       \fillarea{HotPink!30}{(1,4)--(1,6)--(6,6)--(6,5)--(3,5)--(3,4)--(1,4)}
%       \fillarea{GreenYellow}{(2,4)--(3,4)--(3,5)--(5,5)--(5,4)--(4,4)--(4,3)--(2,3)--(2,4)}
%       \fillarea{LightBlue}{(5,5)--(6,5)--(6,3)--(4,3)--(4,4)--(5,4)--(5,5)}
%       \fillarea{LightSalmon!50}{(2,2)--(2,3)--(5,3)--(5,2)--(2,2)}
%       \fillarea{LightYellow}{(2,1)--(2,2)--(5,2)--(5,3)--(6,3)--(6,1)--(2,1)}
%     \end{puzzlebackground} 
%   \end{hakyuu}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{hakyuu}
    \hakyuucell{1}{5}{2}
    \hakyuucell{3}{5}{6}
    \hakyuucell{4}{5}{5}
    \hakyuucell{4}{4}{4}
    \hakyuucell{1}{3}{3}
    \hakyuucell{2}{2}{2}
    \hakyuucell{5}{2}{5}
    \hakyuucell{4}{1}{1}
    \begin{puzzlebackground}
      \fillarea{Wheat}{(1,1)--(1,4)--(2,4)--(2,1)--(1,1)}
      \fillarea{HotPink!30}{(1,4)--(1,6)--(6,6)--(6,5)--(3,5)
                            --(3,4)--(1,4)}
      \fillarea{GreenYellow}{(2,4)--(3,4)--(3,5)--(5,5)--(5,4)
                             --(4,4)--(4,3)--(2,3)--(2,4)}
      \fillarea{LightBlue}{(5,5)--(6,5)--(6,3)--(4,3)--(4,4)
                           --(5,4)--(5,5)}
      \fillarea{LightSalmon!50}{(2,2)--(2,3)--(5,3)--(5,2)
                                --(2,2)}
      \fillarea{LightYellow}{(2,1)--(2,2)--(5,2)--(5,3)--(6,3)
                             --(6,1)--(2,1)}
    \end{puzzlebackground} 
  \end{hakyuu}
  \hspace{1.5cm}
  \begin{hakyuu}
    \setrow{5}{2,3,6,5,4}
    \setrow{4}{1,7,3,4,2}
    \setrow{3}{3,1,2,1,3}
    \setrow{2}{1,2,1,3,5}
    \setrow{1}{2,3,4,1,2}
    \begin{puzzlebackground}
      \fillarea{Wheat}{(1,1)--(1,4)--(2,4)--(2,1)--(1,1)}
      \fillarea{HotPink!30}{(1,4)--(1,6)--(6,6)--(6,5)--(3,5)
                            --(3,4)--(1,4)}
      \fillarea{GreenYellow}{(2,4)--(3,4)--(3,5)--(5,5)--(5,4)
                             --(4,4)--(4,3)--(2,3)--(2,4)}
      \fillarea{LightBlue}{(5,5)--(6,5)--(6,3)--(4,3)--(4,4)
                           --(5,4)--(5,5)}
      \fillarea{LightSalmon!50}{(2,2)--(2,3)--(5,3)--(5,2)
                                --(2,2)}
      \fillarea{LightYellow}{(2,1)--(2,2)--(5,2)--(5,3)--(6,3)
                             --(6,1)--(2,1)}
    \end{puzzlebackground} 
  \end{hakyuu}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Hitori}
% Black out some cells according to these specifications: In each row and each column a number may only occur once or can be completely blackened. The blackened cells can touch neither horizontal nor vertical. All non blackened cells must remain connected. Each number has its own color, which otherwise has no meaning.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{hitori}
%     \framepuzzle
%     \setcolorrow{5}{2,4,2,1,1}
%     \setcolorrow{4}{1,3,2,4,1}
%     \setcolorrow{3}{1,3,3,3,2}
%     \setcolorrow{2}{4,2,1,3,3}
%     \setcolorrow{1}{4,1,2,2,3}
%   \end{hitori}
%   \hspace{1.5cm}
%   \begin{hitori}
%     \framepuzzle
%     \setcolorrow{5}{2,4,0,1,0}
%     \setcolorrow{4}{0,3,2,4,1}
%     \setcolorrow{3}{1,0,3,0,2}
%     \setcolorrow{2}{4,2,1,3,0}
%     \setcolorrow{1}{0,1,0,2,3}
%   \end{hitori}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{hitori}
    \framepuzzle
    \setcolorrow{5}{2,4,2,1,1}
    \setcolorrow{4}{1,3,2,4,1}
    \setcolorrow{3}{1,3,3,3,2}
    \setcolorrow{2}{4,2,1,3,3}
    \setcolorrow{1}{4,1,2,2,3}
  \end{hitori}
  \hspace{1.5cm}
  \begin{hitori}
    \framepuzzle
    \setcolorrow{5}{2,4,0,1,0}
    \setcolorrow{4}{0,3,2,4,1}
    \setcolorrow{3}{1,0,3,0,2}
    \setcolorrow{2}{4,2,1,3,0}
    \setcolorrow{1}{0,1,0,2,3}
  \end{hitori}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Kakuro}
% Enter numbers from 1 to 9 in any order into the blank cells. Here, the given horizontal and vertical sums should result. The zero does not occur. Within a summation, no number can be repeated.
% \subsubsection{Example}
% \definecolor{kakuro}{RGB}{155,206,167}
% \kakurosetup{color=kakuro}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{kakuro}
%     \framepuzzle
%     \kakurorow{5}{\Black,\KKR{23}{},\KKR{16}{},\KKR{10}{},\Black}
%     \kakurorow{4}{\KKR{}{14},9,1,4,\KKR{3}{}}
%     \kakurorow{3}{\KKR{}{16},6,5,3,2}
%     \kakurorow{2}{\KKR{}{14},8,3,2,1}
%     \kakurorow{1}{\Black,\KKR{}{8},7,1,\Black}
%   \end{kakuro}
%   \hspace{1.5cm}
%   \begin{kakuro}[solution]
%     \framepuzzle
%     \kakurorow{5}{\Black,\KKR{23}{},\KKR{16}{},\KKR{10}{},\Black}
%     \kakurorow{4}{\KKR{}{14},9,1,4,\KKR{3}{}}
%     \kakurorow{3}{\KKR{}{16},6,5,3,2}
%     \kakurorow{2}{\KKR{}{14},8,3,2,1}
%     \kakurorow{1}{\Black,\KKR{}{8},7,1,\Black}
%   \end{kakuro}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\definecolor{kakuro}{RGB}{155,206,167}
\kakurosetup{color=kakuro}
\begin{center}
  \begin{kakuro}
    \framepuzzle
    \kakurorow{5}{\Black,\KKR{23}{},\KKR{16}{},\KKR{10}{},\Black}
    \kakurorow{4}{\KKR{}{14},9,1,4,\KKR{3}{}}
    \kakurorow{3}{\KKR{}{16},6,5,3,2}
    \kakurorow{2}{\KKR{}{14},8,3,2,1}
    \kakurorow{1}{\Black,\KKR{}{8},7,1,\Black}
  \end{kakuro}
  \hspace{1.5cm}
  \begin{kakuro}[solution]
    \framepuzzle
    \kakurorow{5}{\Black,\KKR{23}{},\KKR{16}{},\KKR{10}{},\Black}
    \kakurorow{4}{\KKR{}{14},9,1,4,\KKR{3}{}}
    \kakurorow{3}{\KKR{}{16},6,5,3,2}
    \kakurorow{2}{\KKR{}{14},8,3,2,1}
    \kakurorow{1}{\Black,\KKR{}{8},7,1,\Black}
  \end{kakuro}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{color}}{green}{specifies the color of the kakuro cells.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
%   \optitem{\envoption{solution}}{false}{You can use the solution also for the puzzle, as the numbers in the cells are only typeset with option \envoption{solution}\texttt{=true}.}
% \end{optionlist}
%
% \subsection{Kendoku}
% Fill the cells with the numbers from 1 to SIZE of the puzzle. In the top left corner of a framed area, you will find the result of the specified arithmetic function, which is applied on the entered numbers. The numbers may occur only once in each row and column. The numbers of an area may not necessarily be different when they are in different rows or columns.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{kendoku}
%     \framearea{black}{\tikzpath{1}{1}{8,8,6,2,6,2,4,4}}
%     \framearea{black}{\tikzpath{1}{3}{8,6,2,4}}
%     \framearea{black}{\tikzpath{1}{4}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{2}{2}{8,8,6,6,2,4,2,4}}
%     \framearea{black}{\tikzpath{2}{4}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{3}{1}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{3}{4}{8,8,6,6,2,4,2,4}}
%     \framearea{black}{\tikzpath{4}{1}{8,6,6,2,4,4}}
%     \framearea{black}{\tikzpath{4}{2}{8,6,6,2,4,4}}
%     \framearea{black}{\tikzpath{4}{3}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{5}{3}{8,6,2,4}}
%     \framearea{black}{\tikzpath{5}{4}{8,6,2,4}}
%     \framearea{black}{\tikzpath{5}{5}{8,6,2,4}}
%     \setrule{1}{2}{8\times}
%     \setrule{1}{3}{5}
%     \setrule{1}{5}{4+}
%     \setrule{2}{3}{60\times}
%     \setrule{2}{5}{2\div}
%     \setrule{3}{2}{2-}
%     \setrule{3}{5}{75\times}
%     \setrule{4}{1}{8+}
%     \setrule{4}{2}{1-}
%     \setrule{4}{4}{2\times}
%     \setrule{5}{3}{1}
%     \setrule{5}{5}{2}
%   \end{kendoku}
%   \hspace{1.5cm}
%   \begin{kendoku}
%     \framearea{black}{\tikzpath{1}{1}{8,8,6,2,6,2,4,4}}
%     \framearea{black}{\tikzpath{1}{3}{8,6,2,4}}
%     \framearea{black}{\tikzpath{1}{4}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{2}{2}{8,8,6,6,2,4,2,4}}
%     \framearea{black}{\tikzpath{2}{4}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{3}{1}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{3}{4}{8,8,6,6,2,4,2,4}}
%     \framearea{black}{\tikzpath{4}{1}{8,6,6,2,4,4}}
%     \framearea{black}{\tikzpath{4}{2}{8,6,6,2,4,4}}
%     \framearea{black}{\tikzpath{4}{3}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{5}{3}{8,6,2,4}}
%     \framearea{black}{\tikzpath{5}{4}{8,6,2,4}}
%     \framearea{black}{\tikzpath{5}{5}{8,6,2,4}}
%     \setrule{1}{2}{8\times}
%     \setrule{1}{3}{5}
%     \setrule{1}{5}{4+}
%     \setrule{2}{3}{60\times}
%     \setrule{2}{5}{2\div}
%     \setrule{3}{2}{2-}
%     \setrule{3}{5}{75\times}
%     \setrule{4}{1}{8+}
%     \setrule{4}{2}{1-}
%     \setrule{4}{4}{2\times}
%     \setrule{5}{3}{1}
%     \setrule{5}{5}{2}
%     \setrow{5}{1,4,3,5,2}
%     \setrow{4}{3,2,5,1,4}
%     \setrow{3}{5,3,4,2,1}
%     \setrow{2}{2,5,1,4,3}
%     \setrow{1}{4,1,2,3,5}
%   \end{kendoku}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{kendoku}
    \framearea{black}{\tikzpath{1}{1}{8,8,6,2,6,2,4,4}}
    \framearea{black}{\tikzpath{1}{3}{8,6,2,4}}
    \framearea{black}{\tikzpath{1}{4}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{2}{2}{8,8,6,6,2,4,2,4}}
    \framearea{black}{\tikzpath{2}{4}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{3}{1}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{3}{4}{8,8,6,6,2,4,2,4}}
    \framearea{black}{\tikzpath{4}{1}{8,6,6,2,4,4}}
    \framearea{black}{\tikzpath{4}{2}{8,6,6,2,4,4}}
    \framearea{black}{\tikzpath{4}{3}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{5}{3}{8,6,2,4}}
    \framearea{black}{\tikzpath{5}{4}{8,6,2,4}}
    \framearea{black}{\tikzpath{5}{5}{8,6,2,4}}
    \setrule{1}{2}{8\times}
    \setrule{1}{3}{5}
    \setrule{1}{5}{4+}
    \setrule{2}{3}{60\times}
    \setrule{2}{5}{2\div}
    \setrule{3}{2}{2-}
    \setrule{3}{5}{75\times}
    \setrule{4}{1}{8+}
    \setrule{4}{2}{1-}
    \setrule{4}{4}{2\times}
    \setrule{5}{3}{1}
    \setrule{5}{5}{2}
  \end{kendoku}
  \hspace{1.5cm}
  \begin{kendoku}
    \framearea{black}{\tikzpath{1}{1}{8,8,6,2,6,2,4,4}}
    \framearea{black}{\tikzpath{1}{3}{8,6,2,4}}
    \framearea{black}{\tikzpath{1}{4}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{2}{2}{8,8,6,6,2,4,2,4}}
    \framearea{black}{\tikzpath{2}{4}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{3}{1}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{3}{4}{8,8,6,6,2,4,2,4}}
    \framearea{black}{\tikzpath{4}{1}{8,6,6,2,4,4}}
    \framearea{black}{\tikzpath{4}{2}{8,6,6,2,4,4}}
    \framearea{black}{\tikzpath{4}{3}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{5}{3}{8,6,2,4}}
    \framearea{black}{\tikzpath{5}{4}{8,6,2,4}}
    \framearea{black}{\tikzpath{5}{5}{8,6,2,4}}
    \setrule{1}{2}{8\times}
    \setrule{1}{3}{5}
    \setrule{1}{5}{4+}
    \setrule{2}{3}{60\times}
    \setrule{2}{5}{2\div}
    \setrule{3}{2}{2-}
    \setrule{3}{5}{75\times}
    \setrule{4}{1}{8+}
    \setrule{4}{2}{1-}
    \setrule{4}{4}{2\times}
    \setrule{5}{3}{1}
    \setrule{5}{5}{2}
    \setrow{5}{1,4,3,5,2}
    \setrow{4}{3,2,5,1,4}
    \setrow{3}{5,3,4,2,1}
    \setrow{2}{2,5,1,4,3}
    \setrow{1}{4,1,2,3,5}
  \end{kendoku}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Killer Sudoku}
% Fill the cells with the numbers from 1 to SIZE of the puzzle. The numbers may occur only once in each row, column and colored area if specified. In the top left corner of a framed area, you will find the sum of the entered numbers. The numbers of an area may not necessarily be different, when they are in different rows or columns. But they must be different, when additional colored areas are specified.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{killersudoku}[columns=4,rows=4,scale=1.11]
%     \framearea{black}{\tikzpath{1}{1}{8,8,6,6,2,4,2,4}}
%     \framearea{black}{\tikzpath{1}{3}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{2}{1}{8,6,6,6,2,4,4,4}}
%     \framearea{black}{\tikzpath{2}{3}{8,8,6,2,6,2,4,4}}
%     \framearea{black}{\tikzpath{3}{2}{8,6,8,6,2,2,4,4}}
%     \framearea{black}{\tikzpath{3}{4}{8,6,6,2,4,4}}
%     \begin{puzzlebackground}
%       \colorarea{orange!20}{\tikzpath{1}{1}{8,8,6,6,2,2,4,4}}
%       \colorarea{orange!20}{\tikzpath{3}{3}{8,8,6,6,2,2,4,4}}
%     \end{puzzlebackground}
%     \setrule{1}{2}{7}
%     \setrule{1}{4}{7}
%     \setrule{2}{1}{9}
%     \setrule{2}{4}{6}
%     \setrule{3}{4}{5}
%     \setrule{4}{3}{6}
%   \end{killersudoku}
%   \hspace{1.5cm}
%   \begin{killersudoku}[columns=4,rows=4,scale=1.11]
%     \framearea{black}{\tikzpath{1}{1}{8,8,6,6,2,4,2,4}}
%     \framearea{black}{\tikzpath{1}{3}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{2}{1}{8,6,6,6,2,4,4,4}}
%     \framearea{black}{\tikzpath{2}{3}{8,8,6,2,6,2,4,4}}
%     \framearea{black}{\tikzpath{3}{2}{8,6,8,6,2,2,4,4}}
%     \framearea{black}{\tikzpath{3}{4}{8,6,6,2,4,4}}
%     \begin{puzzlebackground}
%       \colorarea{orange!20}{\tikzpath{1}{1}{8,8,6,6,2,2,4,4}}
%       \colorarea{orange!20}{\tikzpath{3}{3}{8,8,6,6,2,2,4,4}}
%     \end{puzzlebackground}
%     \setrule{1}{2}{7}
%     \setrule{1}{4}{7}
%     \setrule{2}{1}{9}
%     \setrule{2}{4}{6}
%     \setrule{3}{4}{5}
%     \setrule{4}{3}{6}
%     \setrow{4}{3,2,4,1}
%     \setrow{3}{4,1,3,2}
%     \setrow{2}{2,4,1,3}
%     \setrow{1}{1,3,2,4}
%   \end{killersudoku}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{killersudoku}
    \framearea{black}{\tikzpath{1}{1}{8,8,6,6,2,4,2,4}}
    \framearea{black}{\tikzpath{1}{3}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{2}{1}{8,6,6,6,2,4,4,4}}
    \framearea{black}{\tikzpath{2}{3}{8,8,6,2,6,2,4,4}}
    \framearea{black}{\tikzpath{3}{2}{8,6,8,6,2,2,4,4}}
    \framearea{black}{\tikzpath{3}{4}{8,6,6,2,4,4}}
    \begin{puzzlebackground}
      \colorarea{orange!20}{\tikzpath{1}{1}{8,8,6,6,2,2,4,4}}
      \colorarea{orange!20}{\tikzpath{3}{3}{8,8,6,6,2,2,4,4}}
    \end{puzzlebackground}
    \setrule{1}{2}{7}
    \setrule{1}{4}{7}
    \setrule{2}{1}{9}
    \setrule{2}{4}{6}
    \setrule{3}{4}{5}
    \setrule{4}{3}{6}
  \end{killersudoku}
  \hspace{1.5cm}
  \begin{killersudoku}
    \framearea{black}{\tikzpath{1}{1}{8,8,6,6,2,4,2,4}}
    \framearea{black}{\tikzpath{1}{3}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{2}{1}{8,6,6,6,2,4,4,4}}
    \framearea{black}{\tikzpath{2}{3}{8,8,6,2,6,2,4,4}}
    \framearea{black}{\tikzpath{3}{2}{8,6,8,6,2,2,4,4}}
    \framearea{black}{\tikzpath{3}{4}{8,6,6,2,4,4}}
    \begin{puzzlebackground}
      \colorarea{orange!20}{\tikzpath{1}{1}{8,8,6,6,2,2,4,4}}
      \colorarea{orange!20}{\tikzpath{3}{3}{8,8,6,6,2,2,4,4}}
    \end{puzzlebackground}
    \setrule{1}{2}{7}
    \setrule{1}{4}{7}
    \setrule{2}{1}{9}
    \setrule{2}{4}{6}
    \setrule{3}{4}{5}
    \setrule{4}{3}{6}
    \setrow{4}{3,2,4,1}
    \setrow{3}{4,1,3,2}
    \setrow{2}{2,4,1,3}
    \setrow{1}{1,3,2,4}
  \end{killersudoku}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Laser Beam}
% Draw a laser beam in each grid according to the following guidelines. The beam has to enter or to leave the grid at the arrows. At each intersection, a mirror, on which the laser beam must reflect on one side, can be placed horizontally or vertically. The other side must not be touched by the beam. All locations where the laser crosses are given. The numbers to the left and above the grid indicate how many cells are traversed by the beam in the corresponding row or column. The numbers to the right and below reveal, how many mirrors are found in the intersection of the corresponding row or column.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{laserbeam}
%     \laserV{1}
%     \laserH{{}}
%     \mirrorH{{},2}
%     \mirrorV{{},{},{},{},{},2}
%     \framepuzzle[LP@c@mirror]
%     \placearrow{3}{1}{LeftUp}
%     \placearrow{6}{4}{RightUp}
%     \placecross{3}{3}
%   \end{laserbeam}
%   \hspace{1.5cm}
%   \begin{laserbeam}
%     \laserV{1}
%     \laserH{{}}
%     \mirrorH{{},2}
%     \mirrorV{{},{},{},{},{},2}
%     \framepuzzle[LP@c@mirror]
%     \placearrow{3}{1}{LeftUp}
%     \placearrow{6}{4}{RightUp}
%     \placecross{3}{3}
%     \placemirror{2}{2}{V}
%     \placemirror{4}{2}{H}
%     \placemirror{5}{5}{V}
%     \placemirror{3}{5}{H}
%     \begin{puzzlebackground}
%       \laser{\tikzpath{3}{1}{7,9,9,9,7,1,7,1,3,3,3,9,9}}
%     \end{puzzlebackground}
%   \end{laserbeam}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{laserbeam}
    \laserV{1}
    \laserH{{}}
    \mirrorH{{},2}
    \mirrorV{{},{},{},{},{},2}
    \framepuzzle[LP@c@mirror]
    \placearrow{3}{1}{LeftUp}
    \placearrow{6}{4}{RightUp}
    \placecross{3}{3}
  \end{laserbeam}
  \hspace{1cm}
  \begin{laserbeam}
    \laserV{1}
    \laserH{{}}
    \mirrorH{{},2}
    \mirrorV{{},{},{},{},{},2}
    \framepuzzle[LP@c@mirror]
    \placearrow{3}{1}{LeftUp}
    \placearrow{6}{4}{RightUp}
    \placecross{3}{3}
    \placemirror{2}{2}{V}
    \placemirror{4}{2}{H}
    \placemirror{5}{5}{V}
    \placemirror{3}{5}{H}
    \begin{puzzlebackground}
      \laser{\tikzpath{3}{1}{7,9,9,9,7,1,7,1,3,3,3,9,9}}
    \end{puzzlebackground}
  \end{laserbeam}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{6.5cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{6.5cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-38pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Magic Labyrinth}
% Enter the numbers 1 to N into the grid. Each number can appear only once in each column and row. Following the labyrinth from the outside inwards, then the given number sequence must be repeated continuously.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
% \begin{magiclabyrinth}
%   \mlline{\xtikzpath{1}{6}{6/5,2/5,4/5,8/4,6/4,2/3,4/3,8/2,6/2,2/1,4/1}}
%   \setcells{1/1,2/4,4/5}{3}
%   \magiclabyrinthcell{4}{2}{2}
%   \magiclabyrinthcell{5}{4}{1}
% \end{magiclabyrinth}
% \hspace{1.5cm}
% \begin{magiclabyrinth}
%   \mlline{\xtikzpath{1}{6}{6/5,2/5,4/5,8/4,6/4,2/3,4/3,8/2,6/2,2/1,4/1}}
%   \setrow{5}{{},1,2,3}
%   \setrow{4}{2,3,{},{},1}
%   \setrow{3}{{},{},3,1,2}
%   \setrow{2}{1,{},{},2,3}
%   \setrow{1}{3,2,1}
% \end{magiclabyrinth}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{magiclabyrinth}
  \mlline{\xtikzpath{1}{6}{6/5,2/5,4/5,8/4,6/4,2/3,4/3,8/2,6/2,
                           2/1,4/1}}
  \setcells{1/1,2/4,4/5}{3}
  \magiclabyrinthcell{4}{2}{2}
  \magiclabyrinthcell{5}{4}{1}
\end{magiclabyrinth}
\hspace{1.5cm}
\begin{magiclabyrinth}
  \mlline{\xtikzpath{1}{6}{6/5,2/5,4/5,8/4,6/4,2/3,4/3,8/2,6/2,
                           2/1,4/1}}
  \setrow{5}{{},1,2,3}
  \setrow{4}{2,3,{},{},1}
  \setrow{3}{{},{},3,1,2}
  \setrow{2}{1,{},{},2,3}
  \setrow{1}{3,2,1}
\end{magiclabyrinth}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Magnets}
% Draw magnetic and neutral plates into the grid. The magnetic plates have a positive and a negative pole, neutral plates do not. The same poles must not touch neither horizontal nor vertical. Neutral plates may touch. The numbers to the left and above the grid indicate how many plus or minus poles are present in the respective column or row.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
% \begin{magnets}
%   \minusH{2,1,2,2,1,2}
%   \minusV{2,1,3,1,2,1}
%   \plusH{2,1,2,2,2,1}
%   \plusV{1,2,1,3,2,1}
%   \magnetsH{2/1,2/4,2/5,2/6,3/2,3/3,4/1,4/4,5/5,5/6}
%   \magnetsV{1/1,1/3,1/5,2/2,4/5,5/2,6/1,6/3}
%   \MPH{2/6}
%   \PMH{5/5}
%   \MPV{6/3}
% \end{magnets}
% \hspace{1.5cm}
% \begin{magnets}
%   \minusH{2,1,2,2,1,2}
%   \minusV{2,1,3,1,2,1}
%   \plusH{2,1,2,2,2,1}
%   \plusV{1,2,1,3,2,1}
%   \MPH{2/6,3/2,4/1}
%   \PMH{2/5,5/5,4/4,3/3}
%   \MPV{1/1,1/3,6/3}
% \end{magnets}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\magnetssetup{bgcolor=Teal!50}
\begin{magnets}
  \minusH{2,1,2,2,1,2}
  \minusV{2,1,3,1,2,1}
  \plusH{2,1,2,2,2,1}
  \plusV{1,2,1,3,2,1}
  \magnetsH{2/1,2/4,2/5,2/6,3/2,3/3,4/1,4/4,5/5,5/6}
  \magnetsV{1/1,1/3,1/5,2/2,4/5,5/2,6/1,6/3}
  \MPH{2/6}
  \PMH{5/5}
  \MPV{6/3}
\end{magnets}
\hspace{1.5cm}
\begin{magnets}
  \minusH{2,1,2,2,1,2}
  \minusV{2,1,3,1,2,1}
  \plusH{2,1,2,2,2,1}
  \plusV{1,2,1,3,2,1}
  \MPH{2/6,3/2,4/1}
  \PMH{2/5,5/5,4/4,3/3}
  \MPV{1/1,1/3,6/3}
\end{magnets}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{6}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{6}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{8.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{8.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid for indicating the neutral areas.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Masyu}
% Draw a line into the grid. The line can only run horizontally and vertically and must pass through all the circles. In cells with a black circle it have to turn in a 90 degree angle and go straight on for at least another cell. The line must go straight through empty circles, but turn left or right in at least one of the neighboring cells. There is no need to go through all cells.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
% \begin{masyu}
%   \framepuzzle
%   \setcells{1/2,3/3,4/1,4/2,4/5,5/4}{\MasyuW}
%   \masyucell{1}{4}{\MasyuB}
% \end{masyu}
% \hspace{1.5cm}
% \begin{masyu}
%   \framepuzzle
%   \setcells{1/2,3/3,4/1,4/2,4/5,5/4}{\MasyuW}
%   \masyucell{1}{4}{\MasyuB}
%   \masyuline{\xtikzpath{1}{1}{8/3,6/2,8/1,6/2,2/2,4/3,2/1,6/3,2/1,4/4}}
% \end{masyu}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\masyusetup{color=Teal}
\begin{masyu}
  \framepuzzle
  \setcells{1/2,3/3,4/1,4/2,4/5,5/4}{\MasyuW}
  \masyucell{1}{4}{\MasyuB}
\end{masyu}
\hspace{1.5cm}
\begin{masyu}
  \framepuzzle
  \setcells{1/2,3/3,4/1,4/2,4/5,5/4}{\MasyuW}
  \masyucell{1}{4}{\MasyuB}
  \masyuline{\xtikzpath{1}{1}{8/3,6/2,8/1,6/2,2/2,4/3,2/1,6/3,
                              2/1,4/4}}
\end{masyu}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{color}}{green}{sets the color of the line.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Minesweeper}
% Draw a mine in some cells of the grid. The number in a cell indicates how many of the eight neighboring cells contain a mine. A numbered cell does not contain a mine.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{minesweeper}
%     \framepuzzle
%     \setrow{5}{{},1}
%     \setrow{4}{{},{},3,3}
%     \setrow{3}{3,{},4,2}
%     \setrow{2}{{},{},{},{},0}
%     \setrow{1}{{},2}
%   \end{minesweeper}
%   \hspace{1.5cm}
%   \begin{minesweeper}
%     \framepuzzle
%     \setrow{5}{{},1,{},\Mine,\Mine}
%     \setrow{4}{{},\Mine,3,3,\Mine}
%     \setrow{3}{3,\Mine,4,2}
%     \setrow{2}{{},\Mine,\Mine,{},0}
%     \setrow{1}{{},2}
%   \end{minesweeper}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{minesweeper}
    \framepuzzle
    \setrow{5}{{},1}
    \setrow{4}{{},{},3,3}
    \setrow{3}{3,{},4,2}
    \setrow{2}{{},{},{},{},0}
    \setrow{1}{{},2}
  \end{minesweeper}
  \hspace{1.5cm}
  \begin{minesweeper}
    \framepuzzle
    \setrow{5}{{},1,{},\Mine,\Mine}
    \setrow{4}{{},\Mine,3,3,\Mine}
    \setrow{3}{3,\Mine,4,2}
    \setrow{2}{{},\Mine,\Mine,{},0}
    \setrow{1}{{},2}
  \end{minesweeper}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Nonogram}
% Black out some cells of the grid. The black squares form stripes. The number, order, and length is defined by the number sequences on the top and left edge of the grid. Each number represents the length of the strip of black squares in the corresponding row or column. Two stripes are separated by at least one white square.
%
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{nonogram}[rows=10,columns=10,scale=0.35,width=4.8cm,fontsize=footnotesize,helplines=5,extracells=3]
%     \nonogramV{{5},{2,4},{2,6},{9},{1,7},{9},{2,1,2},{1,1},{1,4},{2}}
%     \nonogramH{{1},{4,1},{6,2},{7,2},{6,1},{8},{1,4,1},{2,4},{3,2},{4}}
%   \end{nonogram}
%   \hspace{1cm}
%   \begin{nonogram}[rows=10,columns=10,scale=0.35,width=3.8cm,solution=true,extracells=3]
%     \nonogramrow{10}{3/2}
%     \nonogramrow{9}{2/4,7/1}
%     \nonogramrow{8}{1/1,6/1}
%     \nonogramrow{7}{3/2,6/1,8/2}
%     \nonogramrow{6}{2/9}
%     \nonogramrow{5}{2/7,10/1}
%     \nonogramrow{4}{2/9}
%     \nonogramrow{3}{2/6,9/2}
%     \nonogramrow{2}{3/4,8/2}
%     \nonogramrow{1}{4/5}
%     \puzzlestrut
%   \end{nonogram}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{nonogram}[rows=10,columns=10,scale=0.35,width=4.8cm,
                   fontsize=footnotesize,helplines=5,
                   extracells=3]
    \nonogramV{{5},{2,4},{2,6},{9},{1,7},{9},{2,1,2},{1,1},
               {1,4},{2}}
    \nonogramH{{1},{4,1},{6,2},{7,2},{6,1},{8},{1,4,1},{2,4},
               {3,2},{4}}
  \end{nonogram}
  \hspace{1cm}
  \begin{nonogram}[rows=10,columns=10,scale=0.35,width=3.8cm,
                   solution=true,extracells=3]
    \nonogramrow{10}{3/2}
    \nonogramrow{9}{2/4,7/1}
    \nonogramrow{8}{1/1,6/1}
    \nonogramrow{7}{3/2,6/1,8/2}
    \nonogramrow{6}{2/9}
    \nonogramrow{5}{2/7,10/1}
    \nonogramrow{4}{2/9}
    \nonogramrow{3}{2/6,9/2}
    \nonogramrow{2}{3/4,8/2}
    \nonogramrow{1}{4/5}
    \puzzlestrut
  \end{nonogram}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{color}}{black}{sets the color of the lines.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
%   \optitem{\envoption{extracells}}{5}{sets the number of extra cells for the grid.}
%   \optitem{\envoption{helplines}}{5}{sets the space between thicker help lines. You can switch off help lines with \texttt{0}!}
%   \optitem{\envoption{solution}}{false}{will switch off extra cells if set to \texttt{true}.}
% \end{optionlist}
%
% \subsection{Number Link}
% Link all the same numbers or letters in each case by a line. The lines can run horizontally, vertically and in 90 degree angles. Each cell must be traversed by exactly one line. The lines must not intersect.
%
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
% \begin{numberlink}
%   \framepuzzle
%   \numberlinkcell{2}{1}{B}
%   \numberlinkcell{5}{1}{C}
%   \numberlinkcell{2}{2}{C}
%   \numberlinkcell{4}{2}{D}
%   \numberlinkcell{3}{3}{A}
%   \numberlinkcell{4}{3}{E}
%   \numberlinkcell{1}{4}{B}
%   \numberlinkcell{1}{5}{A}
%   \numberlinkcell{3}{5}{E}
%   \numberlinkcell{4}{5}{D}
% \end{numberlink}
% \hspace{1.5cm}
% \begin{numberlink}
%   \framepuzzle
%   \numberlinkcell{2}{1}{B}
%   \numberlinkcell{5}{1}{C}
%   \numberlinkcell{2}{2}{C}
%   \numberlinkcell{4}{2}{D}
%   \numberlinkcell{3}{3}{A}
%   \numberlinkcell{4}{3}{E}
%   \numberlinkcell{1}{4}{B}
%   \numberlinkcell{1}{5}{A}
%   \numberlinkcell{3}{5}{E}
%   \numberlinkcell{4}{5}{D}
%   \link{\tikzpath{4}{3}{8,4,8}}
%   \link{\tikzpath{2}{1}{4,8,8,8}}
%   \link{\tikzpath{2}{2}{6,2,6,6}}
%   \link{\tikzpath{1}{5}{6,2,2,6}}
%   \link{\tikzpath{4}{2}{6,8,8,8,4}}
% \end{numberlink}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{numberlink}
  \framepuzzle
  \numberlinkcell{2}{1}{B}
  \numberlinkcell{5}{1}{C}
  \numberlinkcell{2}{2}{C}
  \numberlinkcell{4}{2}{D}
  \numberlinkcell{3}{3}{A}
  \numberlinkcell{4}{3}{E}
  \numberlinkcell{1}{4}{B}
  \numberlinkcell{1}{5}{A}
  \numberlinkcell{3}{5}{E}
  \numberlinkcell{4}{5}{D}
\end{numberlink}
\hspace{1.5cm}
\begin{numberlink}
  \framepuzzle
  \numberlinkcell{2}{1}{B}
  \numberlinkcell{5}{1}{C}
  \numberlinkcell{2}{2}{C}
  \numberlinkcell{4}{2}{D}
  \numberlinkcell{3}{3}{A}
  \numberlinkcell{4}{3}{E}
  \numberlinkcell{1}{4}{B}
  \numberlinkcell{1}{5}{A}
  \numberlinkcell{3}{5}{E}
  \numberlinkcell{4}{5}{D}
  \link{\tikzpath{4}{3}{8,4,8}}
  \link{\tikzpath{2}{1}{4,8,8,8}}
  \link{\tikzpath{2}{2}{6,2,6,6}}
  \link{\tikzpath{1}{5}{6,2,2,6}}
  \link{\tikzpath{4}{2}{6,8,8,8,4}}
\end{numberlink}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{color}}{red}{sets the color of the lines.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Resuko}
% Complete the given elements in the grid to two race tracks (a race track and a much shorter test track) with pitlane and parking lot. The elements below and to the left of the grid indicate how many straights, curves and intersections are located in the respective columns and rows. The pit lane is always located next to four straights of the circuit on a free area of 1x4 cells. At the end, the parking lot is located on the only free area of 2x2 cells. Both can not be built on a gravel trap.
%
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
% \begin{resuko}[width=5.2cm]
%   \resukocell{1}{7}{\Graveltrap}
%   \resukocell{4}{7}{\Graveltrap}
%   \resukocell{7}{3}{\Graveltrap}
%   \resukocell{6}{2}{\Cross}
%   \resukocell{8}{4}{\StraightV}
%   \resukocell{6}{7}{\StraightH}
%   \resukocell{3}{5}{\CurveBR}
%   \resukocell{5}{5}{\CurveTR}
%   \trackH{1/4/0,4/0/0,3/2/0,2/2/0,3/2/0,3/2/1,2/2/2,2/4/0}
%   \trackV{4/2/0,5/2/1,2/0/0,2/4/0,2/4/1,4/2/0,1/2/1,0/2/0}
%   \framepuzzle
% \end{resuko}
% \hspace{1.5cm}
% \begin{resuko}
%   \resukocell{1}{7}{\Graveltrap}
%   \resukocell{4}{7}{\Graveltrap}
%   \resukocell{7}{3}{\Graveltrap}
%   \parkinglot{2}{7}
%   \pitlane{2}{3}{H}
%   \track{\tikzpath{2}{4}{6,8,6,8,4,4,4,2,2,6}}
%   \track{\xtikzpath{2}{1}{6/4,8/3,6/1,8/4,6/1,2/1,4/3,2/2,6/3,2/3,4/7,2/1,6/1}}
%   \framepuzzle
% \end{resuko}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\resukosetup{rows=8,columns=8,width=5.8cm,fontsize=Huge,
             scale=.708}
\begin{resuko}[width=7.4cm]
  \resukocell{1}{7}{\Graveltrap}
  \resukocell{4}{7}{\Graveltrap}
  \resukocell{7}{3}{\Graveltrap}
  \resukocell{6}{2}{\Cross}
  \resukocell{8}{4}{\StraightV}
  \resukocell{6}{7}{\StraightH}
  \resukocell{3}{5}{\CurveBR}
  \resukocell{5}{5}{\CurveTR}
  \trackH{1/4/0,4/0/0,3/2/0,2/2/0,3/2/0,3/2/1,2/2/2,2/4/0}
  \trackV{4/2/0,5/2/1,2/0/0,2/4/0,2/4/1,4/2/0,1/2/1,0/2/0}
  \framepuzzle
\end{resuko}
\hspace{1.5cm}
\begin{resuko}
  \resukocell{1}{7}{\Graveltrap}
  \resukocell{4}{7}{\Graveltrap}
  \resukocell{7}{3}{\Graveltrap}
  \parkinglot{2}{7}
  \pitlane{2}{3}{H}
  \track{\tikzpath{2}{4}{6,8,6,8,4,4,4,2,2,6}}
  \track{\xtikzpath{2}{1}{6/4,8/3,6/1,8/4,6/1,2/1,4/3,2/2,6/3,
                          2/3,4/7,2/1,6/1}}
  \framepuzzle
\end{resuko}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{color}}{blue}{sets the color of the pitlane and parking lot.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Schatzsuche}
% It's a variant of Minesweeper, just with diamonds instead of mines. Draw a diamond in some cells of the grid. The number in a cell indicates how many of the eight neighboring cells contain a diamond. A numbered cell does not contain a diamond.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{schatzsuche}
%     \framepuzzle
%     \setrow{5}{{},1}
%     \setrow{4}{{},{},3,3}
%     \setrow{3}{3,{},4,2}
%     \setrow{2}{{},{},{},{},0}
%     \setrow{1}{{},2}
%   \end{schatzsuche}
%   \hspace{1.5cm}
%   \begin{schatzsuche}
%     \framepuzzle
%     \setrow{5}{{},1,{},\Diamond,\Diamond}
%     \setrow{4}{{},\Diamond,3,3,\Diamond}
%     \setrow{3}{3,\Diamond,4,2}
%     \setrow{2}{{},\Diamond,\Diamond,{},0}
%     \setrow{1}{{},2}
%   \end{schatzsuche}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{schatzsuche}
    \framepuzzle
    \setrow{5}{{},1}
    \setrow{4}{{},{},3,3}
    \setrow{3}{3,{},4,2}
    \setrow{2}{{},{},{},{},0}
    \setrow{1}{{},2}
  \end{schatzsuche}
  \hspace{1.5cm}
  \begin{schatzsuche}
    \framepuzzle
    \setrow{5}{{},1,{},\Diamond,\Diamond}
    \setrow{4}{{},\Diamond,3,3,\Diamond}
    \setrow{3}{3,\Diamond,4,2}
    \setrow{2}{{},\Diamond,\Diamond,{},0}
    \setrow{1}{{},2}
  \end{schatzsuche}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Skyline}
% There are skyscrapers located in each cell. Try to find out the height of the skyscraper in the respective cell. There are heights of 1 to MAX in every row, every column, and in each of the two diagonals if indicated. Some cells may be empty (parks). The numbers around the grid indicate how many buildings you can see from this position when you look at the skyscraper lineup. Bear in mind that only those skyscrapers are visible which are higher than the ones in front.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{skyline}
%     \skylineB{3,{},3,1,{}}
%     \skylineL{{},4,3,{},{}}
%     \skylineT{{},{},2,{},3}
%     \skylineR{{},1,3,{},{}}
%     \skylinecell{1}{3}{2}
%     \skylinecell{4}{2}{3}
%   \end{skyline}
%   \hspace{1cm}
%   \begin{skyline}
%     \skylineB{3,{},3,1,{}}
%     \skylineL{{},4,3,{},{}}
%     \skylineT{{},{},2,{},3}
%     \skylineR{{},1,3,{},{}}
%     \setrow{5}{5,4,3,1,2}
%     \setrow{4}{4,5,1,2,3}
%     \setrow{3}{2,3,5,4,1}
%     \setrow{2}{1,2,4,3,5}
%     \setrow{1}{3,1,2,5,4}
%   \end{skyline}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{skyline}
    \skylineB{3,{},3,1,{}}
    \skylineL{{},4,3,{},{}}
    \skylineT{{},{},2,{},3}
    \skylineR{{},1,3,{},{}}
    \skylinecell{1}{3}{2}
    \skylinecell{4}{2}{3}
  \end{skyline}
  \hspace{1cm}
  \begin{skyline}
    \skylineB{3,{},3,1,{}}
    \skylineL{{},4,3,{},{}}
    \skylineT{{},{},2,{},3}
    \skylineR{{},1,3,{},{}}
    \setrow{5}{5,4,3,1,2}
    \setrow{4}{4,5,1,2,3}
    \setrow{3}{2,3,5,4,1}
    \setrow{2}{1,2,4,3,5}
    \setrow{1}{3,1,2,5,4}
  \end{skyline}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \paragraph{Variants}
% \subparagraph{Skyline Sudoku}
%
% \begin{center}
%   \begin{skyline}[sudoku,scale=.4]
%     \skylineB{4,5,2,5,2,1,2,4,3}
%     \skylineL{4,2,2,2,1,3,3,3,2}
%     \skylineT{4,1,3,2,3,5,3,2,3}
%     \skylineR{3,3,1,3,4,2,3,2,4}
%     \setrow{9}{{},{},{},8,{},{},{},7}
%     \setrow{8}{{},{},4,{},{},6,{},{},8}
%     \setrow{7}{{},2,{},7,{},{},{},{},1}
%     \setrow{6}{{},{},{},{},8,2}
%     \setrow{5}{{},{},2,{},4,{},7}
%     \setrow{4}{{},{},{},3,{},{},4}
%     \setrow{3}{{},{},{},{},1}
%     \setrow{2}{{},3,{},{},{},{},1,2}
%     \setrow{1}{{},{},5}
%   \end{skyline}
%   \hspace{1cm}
%   \begin{skyline}[sudoku,scale=.4]
%     \skylineB{4,5,2,5,2,1,2,4,3}
%     \skylineL{4,2,2,2,1,3,3,3,2}
%     \skylineT{4,1,3,2,3,5,3,2,3}
%     \skylineR{3,3,1,3,4,2,3,2,4}
%     \setrow{9}{3,9,6,8,5,1,2,7,4}
%     \setrow{8}{1,7,4,9,2,6,3,5,8}
%     \setrow{7}{5,2,8,7,3,4,9,6,1}
%     \setrow{6}{7,4,3,1,8,2,6,9,5}
%     \setrow{5}{9,8,2,6,4,5,7,1,3}
%     \setrow{4}{6,5,1,3,9,7,4,8,2}
%     \setrow{3}{8,6,7,2,1,3,5,4,9}
%     \setrow{2}{4,3,9,5,6,8,1,2,7}
%     \setrow{1}{2,1,5,4,7,9,8,3,6}
%   \end{skyline}
% \end{center}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{skyline}[sudoku,scale=.4]
    \skylineB{4,5,2,5,2,1,2,4,3}
    \skylineL{4,2,2,2,1,3,3,3,2}
    \skylineT{4,1,3,2,3,5,3,2,3}
    \skylineR{3,3,1,3,4,2,3,2,4}
    \setrow{9}{{},{},{},8,{},{},{},7}
    \setrow{8}{{},{},4,{},{},6,{},{},8}
    \setrow{7}{{},2,{},7,{},{},{},{},1}
    \setrow{6}{{},{},{},{},8,2}
    \setrow{5}{{},{},2,{},4,{},7}
    \setrow{4}{{},{},{},3,{},{},4}
    \setrow{3}{{},{},{},{},1}
    \setrow{2}{{},3,{},{},{},{},1,2}
    \setrow{1}{{},{},5}
  \end{skyline}
  \hspace{1cm}
  \begin{skyline}[sudoku,scale=.4]
    \skylineB{4,5,2,5,2,1,2,4,3}
    \skylineL{4,2,2,2,1,3,3,3,2}
    \skylineT{4,1,3,2,3,5,3,2,3}
    \skylineR{3,3,1,3,4,2,3,2,4}
    \setrow{9}{3,9,6,8,5,1,2,7,4}
    \setrow{8}{1,7,4,9,2,6,3,5,8}
    \setrow{7}{5,2,8,7,3,4,9,6,1}
    \setrow{6}{7,4,3,1,8,2,6,9,5}
    \setrow{5}{9,8,2,6,4,5,7,1,3}
    \setrow{4}{6,5,1,3,9,7,4,8,2}
    \setrow{3}{8,6,7,2,1,3,5,4,9}
    \setrow{2}{4,3,9,5,6,8,1,2,7}
    \setrow{1}{2,1,5,4,7,9,8,3,6}
  \end{skyline}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subparagraph{Skyline Sudoku (N*N)}
%
% \begin{center}
%   \begin{skyline}[rows=6,columns=6,scale=.58]
%     \skylineB{4,2,1,3,3,2}
%     \skylineL{3,3,4,3,2,1}
%     \skylineT{1,2,3,3,2,4}
%     \skylineR{4,1,2,2,2,3}
%     \skylinecell{2}{4}{1}
%     \skylinecell{4}{1}{4}
%     \skylinecell{5}{2}{3}
%     \begin{puzzlebackground}
%       \fillarea{Wheat}{(1,1)--(1,3)--(4,3)--(4,1)--(1,1)}
%       \fillarea{HotPink!30}{(1,3)--(1,7)--(4,7)--(4,6)--(2,6)
%                             --(2,3)--(1,3)}
%       \fillarea{GreenYellow}{(2,3)--(2,6)--(4,6)--(4,3)--(2,3)}
%       \fillarea{LightBlue}{(4,1)--(7,1)--(7,5)--(6,5)--(6,2)
%                            --(4,2)--(4,1)}
%       \fillarea{LightSalmon!50}{(4,7)--(4,4)--(5,4)--(5,6)--(6,6)
%                                 --(6,5)--(7,5)--(7,7)--(4,7)}
%       \fillarea{LightYellow}{(4,2)--(4,4)--(5,4)--(5,6)--(6,6)
%                              --(6,2)--(4,2)}
%     \end{puzzlebackground} 
%   \end{skyline}
%   \hspace{1cm}
%   \begin{skyline}[rows=6,columns=6,scale=.58]
%     \skylineB{4,2,1,3,3,2}
%     \skylineL{3,3,4,3,2,1}
%     \skylineT{1,2,3,3,2,4}
%     \skylineR{4,1,2,2,2,3}
%     \setrow{6}{6,3,4,1,5,2}
%     \setrow{5}{5,6,2,3,1,4}
%     \setrow{4}{2,1,3,6,4,5}
%     \setrow{3}{1,4,5,2,6,3}
%     \setrow{2}{4,2,1,5,3,6}
%     \setrow{1}{3,5,6,4,2,1}
%     \begin{puzzlebackground}
%       \fillarea{Wheat}{(1,1)--(1,3)--(4,3)--(4,1)--(1,1)}
%       \fillarea{HotPink!30}{(1,3)--(1,7)--(4,7)--(4,6)--(2,6)
%                             --(2,3)--(1,3)}
%       \fillarea{GreenYellow}{(2,3)--(2,6)--(4,6)--(4,3)--(2,3)}
%       \fillarea{LightBlue}{(4,1)--(7,1)--(7,5)--(6,5)--(6,2)
%                            --(4,2)--(4,1)}
%       \fillarea{LightSalmon!50}{(4,7)--(4,4)--(5,4)--(5,6)--(6,6)
%                                 --(6,5)--(7,5)--(7,7)--(4,7)}
%       \fillarea{LightYellow}{(4,2)--(4,4)--(5,4)--(5,6)--(6,6)
%                              --(6,2)--(4,2)}
%     \end{puzzlebackground} 
%   \end{skyline}
% \end{center}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{skyline}[rows=6,columns=6,scale=.58]
    \skylineB{4,2,1,3,3,2}
    \skylineL{3,3,4,3,2,1}
    \skylineT{1,2,3,3,2,4}
    \skylineR{4,1,2,2,2,3}
    \skylinecell{2}{4}{1}
    \skylinecell{4}{1}{4}
    \skylinecell{5}{2}{3}
    \begin{puzzlebackground}
      \fillarea{Wheat}{(1,1)--(1,3)--(4,3)--(4,1)--(1,1)}
      \fillarea{HotPink!30}{(1,3)--(1,7)--(4,7)--(4,6)--(2,6)
                            --(2,3)--(1,3)}
      \fillarea{GreenYellow}{(2,3)--(2,6)--(4,6)--(4,3)--(2,3)}
      \fillarea{LightBlue}{(4,1)--(7,1)--(7,5)--(6,5)--(6,2)
                           --(4,2)--(4,1)}
      \fillarea{LightSalmon!50}{(4,7)--(4,4)--(5,4)--(5,6)--(6,6)
                                --(6,5)--(7,5)--(7,7)--(4,7)}
      \fillarea{LightYellow}{(4,2)--(4,4)--(5,4)--(5,6)--(6,6)
                             --(6,2)--(4,2)}
    \end{puzzlebackground} 
  \end{skyline}
  \hspace{1cm}
  \begin{skyline}[rows=6,columns=6,scale=.58]
    \skylineB{4,2,1,3,3,2}
    \skylineL{3,3,4,3,2,1}
    \skylineT{1,2,3,3,2,4}
    \skylineR{4,1,2,2,2,3}
    \setrow{6}{6,3,4,1,5,2}
    \setrow{5}{5,6,2,3,1,4}
    \setrow{4}{2,1,3,6,4,5}
    \setrow{3}{1,4,5,2,6,3}
    \setrow{2}{4,2,1,5,3,6}
    \setrow{1}{3,5,6,4,2,1}
    \begin{puzzlebackground}
      \fillarea{Wheat}{(1,1)--(1,3)--(4,3)--(4,1)--(1,1)}
      \fillarea{HotPink!30}{(1,3)--(1,7)--(4,7)--(4,6)--(2,6)
                            --(2,3)--(1,3)}
      \fillarea{GreenYellow}{(2,3)--(2,6)--(4,6)--(4,3)--(2,3)}
      \fillarea{LightBlue}{(4,1)--(7,1)--(7,5)--(6,5)--(6,2)
                           --(4,2)--(4,1)}
      \fillarea{LightSalmon!50}{(4,7)--(4,4)--(5,4)--(5,6)--(6,6)
                                --(6,5)--(7,5)--(7,7)--(4,7)}
      \fillarea{LightYellow}{(4,2)--(4,4)--(5,4)--(5,6)--(6,6)
                             --(6,2)--(4,2)}
    \end{puzzlebackground} 
  \end{skyline}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{sudoku}}{false}{sets \envoption{rows} and \envoption{columns} to 9, in case of \texttt{true} is specified. Additionally the classic Sudoku grid is drawn.}
%   \optitem{\envoption{width}}{6.7cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0.75cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.85cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-38pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Slitherlink}
% Draw a closed line into the grid. This line must be on the existing dashed lines, but do not have to go through all grid points. If numbers are present in the grid cells, they indicate how many sides of the cell are touched by the line. The line must not touch or cross itself.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{slitherlink}
%     \setbigcell{1}{1}{4}
%     \slitherlinkcell{1}{3}{3}
%     \slitherlinkcell{3}{1}{3}
%     \slitherlinkcell{3}{3}{0}
%     \slitherlinkcell{3}{4}{3}
%     \slitherlinkcell{4}{4}{2}
%     \slitherlinkcell{5}{1}{0}
%     \slitherlinkcell{5}{2}{2}
%   \end{slitherlink}
%   \hspace{1.5cm}
%   \begin{slitherlink}
%     \setbigcell{1}{1}{4}
%     \slitherlinkcell{1}{3}{3}
%     \slitherlinkcell{3}{1}{3}
%     \slitherlinkcell{3}{3}{0}
%     \slitherlinkcell{3}{4}{3}
%     \slitherlinkcell{4}{4}{2}
%     \slitherlinkcell{5}{1}{0}
%     \slitherlinkcell{5}{2}{2}
%     \framearea{black}{\tikzpath{3}{1}{8,8,4,4,8,6,6,8,6,2,6,6,2,4,2,4,2,4}}
%   \end{slitherlink}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{slitherlink}
    \setbigcell{1}{1}{4}
    \slitherlinkcell{1}{3}{3}
    \slitherlinkcell{3}{1}{3}
    \slitherlinkcell{3}{3}{0}
    \slitherlinkcell{3}{4}{3}
    \slitherlinkcell{4}{4}{2}
    \slitherlinkcell{5}{1}{0}
    \slitherlinkcell{5}{2}{2}
  \end{slitherlink}
  \hspace{1.5cm}
  \begin{slitherlink}
    \setbigcell{1}{1}{4}
    \slitherlinkcell{1}{3}{3}
    \slitherlinkcell{3}{1}{3}
    \slitherlinkcell{3}{3}{0}
    \slitherlinkcell{3}{4}{3}
    \slitherlinkcell{4}{4}{2}
    \slitherlinkcell{5}{1}{0}
    \slitherlinkcell{5}{2}{2}
    \framearea{black}{\tikzpath{3}{1}{8,8,4,4,8,6,6,8,6,2,
                                      6,6,2,4,2,4,2,4}}
  \end{slitherlink}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.2cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.2cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Star Battle}
% Enter exactly one star in each row, each column and each area of the grid. Cells with stars must not touch each other orthogonally or diagonally.
%
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{starbattle}
%     \framepuzzle
%     \framearea{black}{\tikzpath{1}{1}{8,6,8,6,6,2,6,6,2,4,4,4,4,4}}
%     \framearea{black}{\tikzpath{1}{2}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{1}{4}{8,8,6,6,2,6,2,2,4,4,8,4}}
%     \framearea{black}{\tikzpath{4}{2}{8,8,8,4,8,6,6,6,2,4,2,2,6,2,4,4}}
%     \framearea{black}{\tikzpath{5}{3}{8,8,6,2,2,4}}
%   \end{starbattle}
%   \hspace{1.5cm}
%   \begin{starbattle}
%     \framepuzzle
%     \framearea{black}{\tikzpath{1}{1}{8,6,8,6,6,2,6,6,2,4,4,4,4,4}}
%     \framearea{black}{\tikzpath{1}{2}{8,8,6,2,2,4}}
%     \framearea{black}{\tikzpath{1}{4}{8,8,6,6,2,6,2,2,4,4,8,4}}
%     \framearea{black}{\tikzpath{4}{2}{8,8,8,4,8,6,6,6,2,4,2,2,6,2,4,4}}
%     \framearea{black}{\tikzpath{5}{3}{8,8,6,2,2,4}}
%     \starbattlecell{1}{2}{\Star}
%     \starbattlecell{2}{4}{\Star}
%     \starbattlecell{3}{1}{\Star}
%     \starbattlecell{4}{5}{\Star}
%     \starbattlecell{5}{3}{\Star}
%   \end{starbattle}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{starbattle}
    \framepuzzle
    \framearea{black}{\tikzpath{1}{1}{8,6,8,6,6,2,6,6,2,4,4,4,
                                      4,4}}
    \framearea{black}{\tikzpath{1}{2}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{1}{4}{8,8,6,6,2,6,2,2,4,4,8,4}}
    \framearea{black}{\tikzpath{4}{2}{8,8,8,4,8,6,6,6,2,4,2,2,6,
                                      2,4,4}}
    \framearea{black}{\tikzpath{5}{3}{8,8,6,2,2,4}}
  \end{starbattle}
  \hspace{1.5cm}
  \begin{starbattle}
    \framepuzzle
    \framearea{black}{\tikzpath{1}{1}{8,6,8,6,6,2,6,6,2,4,4,4,
                                      4,4}}
    \framearea{black}{\tikzpath{1}{2}{8,8,6,2,2,4}}
    \framearea{black}{\tikzpath{1}{4}{8,8,6,6,2,6,2,2,4,4,8,4}}
    \framearea{black}{\tikzpath{4}{2}{8,8,8,4,8,6,6,6,2,4,2,2,6,
                                      2,4,4}}
    \framearea{black}{\tikzpath{5}{3}{8,8,6,2,2,4}}
    \starbattlecell{1}{2}{\Star}
    \starbattlecell{2}{4}{\Star}
    \starbattlecell{3}{1}{\Star}
    \starbattlecell{4}{5}{\Star}
    \starbattlecell{5}{3}{\Star}
  \end{starbattle}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Stars and Arrows}
% Enter a star in some empty cells of the grid. Each arrow points to at least one star and every star is referenced by at least one arrow. Arrows point to a whole row, column or diagonal, also through other stars and arrows. The numbers on the left and top of the grid indicate how many stars are located in the row or column.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{starsandarrows}
%     \framepuzzle
%     \starsH{1,2,3,2,0}
%     \starsV{1,0,3,2,2}
%     \setrow{5}{\RightDown,{},\LeftDown}
%     \setrow{4}{{},\Right,{},{},\LeftUp}
%     \setrow{2}{{},\Up,{},{},{}}
%     \setrow{1}{\RightUp,{},{},\LeftUp,\Left}
%   \end{starsandarrows}
%   \hspace{1.5cm}
%   \begin{starsandarrows}
%     \framepuzzle
%     \starsH{1,2,3,2,0}
%     \starsV{1,0,3,2,2}
%     \setrow{5}{\RightDown,\Star,\LeftDown,\Star}
%     \setrow{4}{{},\Right,\Star,\Star,\LeftUp}
%     \setrow{3}{\Star,\Star,\Star}
%     \setrow{2}{{},\Up,{},{},{}}
%     \setrow{1}{\RightUp,{},\Star,\LeftUp,\Left}
%   \end{starsandarrows}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{starsandarrows}
    \framepuzzle
    \starsH{1,2,3,2,0}
    \starsV{1,0,3,2,2}
    \setrow{5}{\RightDown,{},\LeftDown}
    \setrow{4}{{},\Right,{},{},\LeftUp}
    \setrow{2}{{},\Up,{},{},{}}
    \setrow{1}{\RightUp,{},{},\LeftUp,\Left}
  \end{starsandarrows}
  \hspace{1.5cm}
  \begin{starsandarrows}
    \framepuzzle
    \starsH{1,2,3,2,0}
    \starsV{1,0,3,2,2}
    \setrow{5}{\RightDown,\Star,\LeftDown,\Star}
    \setrow{4}{{},\Right,\Star,\Star,\LeftUp}
    \setrow{3}{\Star,\Star,\Star}
    \setrow{2}{{},\Up,{},{},{}}
    \setrow{1}{\RightUp,{},\Star,\LeftUp,\Left}
  \end{starsandarrows}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.9cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.9cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Sudoku}
% Well, it's Sudoku -- nothing to explain! Fill each row and column with numbers from 1 to 9.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{lpsudoku}
%   \setrow{9}{{},2,6,{},{},{},{},{},{}}
%   \setrow{8}{{},{},{},{},{},{},1,7,{}}
%   \setrow{7}{{},{},3,1,{},6,{},{},{}}
%   \setrow{6}{{},6,{},{},5,{},8,{},3}
%   \setrow{5}{{},{},9,2,6,1,7,{},{}}
%   \setrow{4}{5,{},4,{},8,{},{},6,{}}
%   \setrow{3}{{},{},{},8,{},4,3,{},{}}
%   \setrow{2}{{},4,8,{},{},{},{},{},{}}
%   \setrow{1}{{},{},{},{},{},{},9,4,{}}
% \end{lpsudoku}
%   \hspace{1.5cm}
%   \begin{lpsudoku}
%   \setrow{9}{1,2,6,5,7,8,4,3,9}
%   \setrow{8}{4,8,5,9,3,2,1,7,6}
%   \setrow{7}{7,9,3,1,4,6,5,8,2}
%   \setrow{6}{2,6,1,4,5,7,8,9,3}
%   \setrow{5}{8,3,9,2,6,1,7,5,4}
%   \setrow{4}{5,7,4,3,8,9,2,6,1}
%   \setrow{3}{6,5,2,8,9,4,3,1,7}
%   \setrow{2}{9,4,8,7,1,3,6,2,5}
%   \setrow{1}{3,1,7,6,2,5,9,4,8}
% \end{lpsudoku}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{lpsudoku}
    \setrow{9}{{},2,6,{},{},{},{},{},{}}
    \setrow{8}{{},{},{},{},{},{},1,7,{}}
    \setrow{7}{{},{},3,1,{},6,{},{},{}}
    \setrow{6}{{},6,{},{},5,{},8,{},3}
    \setrow{5}{{},{},9,2,6,1,7,{},{}}
    \setrow{4}{5,{},4,{},8,{},{},6,{}}
    \setrow{3}{{},{},{},8,{},4,3,{},{}}
    \setrow{2}{{},4,8,{},{},{},{},{},{}}
    \setrow{1}{{},{},{},{},{},{},9,4,{}}
    \end{lpsudoku}
    \hspace{1.5cm}
    \begin{lpsudoku}
    \setrow{9}{1,2,6,5,7,8,4,3,9}
    \setrow{8}{4,8,5,9,3,2,1,7,6}
    \setrow{7}{7,9,3,1,4,6,5,8,2}
    \setrow{6}{2,6,1,4,5,7,8,9,3}
    \setrow{5}{8,3,9,2,6,1,7,5,4}
    \setrow{4}{5,7,4,3,8,9,2,6,1}
    \setrow{3}{6,5,2,8,9,4,3,1,7}
    \setrow{2}{9,4,8,7,1,3,6,2,5}
    \setrow{1}{3,1,7,6,2,5,9,4,8}
  \end{lpsudoku}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{width}}{9.1cm}{sets the width of the minipage, in which the grid is typeset. 9 cells of width 1cm plus a litle extra for lines.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage. To get a width of 5cm you need to scale by $\nicefrac{5}{9}$}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{9.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsubsection{Supporting \texttt{bash} scripts}
% \paragraph{createlpsudoku}
% The \texttt{createlpsudoku} \cite{bib:wiki:createlpsudoku} \texttt{bash} script can transform Sudoku format files into \env{lpsudoku} environments. It can process files in the so called one line 81 format\footnote{processing of several sudokus in 81 format (one in each line) is possible} (option -e (default)) and in simple sudoku format (option -s)
%
% \medskip
% Usage: \texttt{createlpsudoku [options] [-o output] -i input}
%
% \medskip
% It expects an input file with the option \texttt{-i}. You can specify an output file with the option \texttt{-o}. Otherwise it writes to \texttt{stdout}. Furthermore, the following options are possible: 
%
% \medskip
% \begin{tabular}{ll}
% -w & write Windows line endings (CR/LF) to file \\
% -v & prints version number \\
% -h & prints help \\
% \end{tabular}
%
% \paragraph{lpsmag}
%
% With the \texttt{lpsmag} \cite{bib:wiki:lpsmag} \texttt{bash} script you can half automatically produce a Sudoku magazine using the \env{lpsudoku} environment and the \texttt{createlpsudoku} bash script.
%
% \medskip
% Usage: \texttt{lpsmag configfile}
%
% \medskip
% The script needs an installed \href{http://ostermiller.org/qqwing/}{QQwing} \cite{bib:web:qqwing} and a config file for defining the magazine's contents: 
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
page p1 easy
page p2 easy
startpuzzles
typesetpage p1
typesetpage p2
startsolutions
typesetsolpage p1 p2 last
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% This config file will be sourced into the \texttt{lpsmag bash} script and contains calls of \texttt{lpsmag} functions. Make sure, that the config file has UNIX line endings (LF). For a detailed documentation I refer to the following \href{http://logicpuzzle.square7.de/lpsmag}{wiki} \cite{bib:wiki:lpsmag} entry.
%
% After running \texttt{lpsmag} you will find a \texttt{lpsmag.tex} in your working directory. Just run \texttt{pdflatex lpsmag.tex} twice and you finally get for example this \href{https://bitbucket.org/kleberj/logicpuzzle/downloads/lpsmag.pdf}{\texttt{lpsmag.pdf}}. 
%
% \subsection{Sun and Moon}
% Enter exactly one star and one dark cloud in each row and each column of the grid, so that the planets are illuminated as specified. The stars shine horizontally or vertically arbitrarily far, but not through a planet or a dark cloud.
%
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{sunandmoon}
%     \framepuzzle
%     \setrow{5}{{},{},{},{},\Moon}
%     \setrow{4}{{},{},\MoonTL}
%     \setrow{3}{\Moon}
%     \setrow{2}{{},\MoonR}
%     \setrow{1}{{},{},{},\MoonT}
%   \end{sunandmoon}
%   \hspace{1.5cm}
%   \begin{sunandmoon}
%     \framepuzzle
%     \setrow{5}{{},{},\Star,\Cloud,\Moon}
%     \setrow{4}{{},\Star,\MoonTL,{},\Cloud}
%     \setrow{3}{\Moon,\Cloud,{},{},\Star}
%     \setrow{2}{\Cloud,\MoonR,{},\Star}
%     \setrow{1}{\Star,{},\Cloud,\MoonT}
%   \end{sunandmoon}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{sunandmoon}
    \framepuzzle
    \setrow{5}{{},{},{},{},\Moon}
    \setrow{4}{{},{},\MoonTL}
    \setrow{3}{\Moon}
    \setrow{2}{{},\MoonR}
    \setrow{1}{{},{},{},\MoonT}
  \end{sunandmoon}
  \hspace{1.5cm}
  \begin{sunandmoon}
    \framepuzzle
    \setrow{5}{{},{},\Star,\Cloud,\Moon}
    \setrow{4}{{},\Star,\MoonTL,{},\Cloud}
    \setrow{3}{\Moon,\Cloud,{},{},\Star}
    \setrow{2}{\Cloud,\MoonR,{},\Star}
    \setrow{1}{\Star,{},\Cloud,\MoonT}
  \end{sunandmoon}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.1cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.1cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Tents and Trees}
% Draw tents in the grid. Next to each tree, a tent must be entered in a horizontally or vertically adjacent cell, which is associated with this tree. The numbers next to the grid indicate the quantity of tents in each row or column. No tent can stand directly next to another one, not even diagonally.
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{tentsandtrees}
%     \framepuzzle
%     \tentH{1,2,1,1,2}
%     \tentV{2,0,2,0,3}
%     \setrow{4}{\Tree,{},\Tree,\Tree,\Tree}
%     \setrow{2}{{},\Tree}
%     \setrow{1}{\Tree,{},{},\Tree}
%   \end{tentsandtrees}
%   \hspace{1.5cm}
%   \begin{tentsandtrees}
%     \framepuzzle
%     \tentH{1,2,1,1,2}
%     \tentV{2,0,2,0,3}
%     \setrow{5}{\Tent,{},\Tent,{},\Tent,}
%     \setrow{4}{\Tree,{},\Tree,\Tree,\Tree}
%     \setrow{3}{{},\Tent,{},\Tent}
%     \setrow{2}{{},\Tree}
%     \setrow{1}{\Tree,\Tent,{},\Tree,\Tent}
%   \end{tentsandtrees}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{tentsandtrees}
    \framepuzzle
    \tentH{1,2,1,1,2}
    \tentV{2,0,2,0,3}
    \setrow{4}{\Tree,{},\Tree,\Tree,\Tree}
    \setrow{2}{{},\Tree}
    \setrow{1}{\Tree,{},{},\Tree}
  \end{tentsandtrees}
  \hspace{1.5cm}
  \begin{tentsandtrees}
    \framepuzzle
    \tentH{1,2,1,1,2}
    \tentV{2,0,2,0,3}
    \setrow{5}{\Tent,{},\Tent,{},\Tent,}
    \setrow{4}{\Tree,{},\Tree,\Tree,\Tree}
    \setrow{3}{{},\Tent,{},\Tent}
    \setrow{2}{{},\Tree}
    \setrow{1}{\Tree,\Tent,{},\Tree,\Tent}
  \end{tentsandtrees}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.9cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.9cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
%
% \subsection{Tunnel}
% Determine the course of the tube. Draw the only possible connection. from the beginning to the end. The numbers indicate how many tube segments (including portals) are present in the corresponding rows and columns. The tube is one cell wide, and does not cross or touch itself!
% \subsubsection{Example}
% \begin{figure}[htbp]
% \begin{center}
%   \begin{tunnel}
%     \framepuzzle
%     \tunnelH{4,3,3,3,4}
%     \tunnelV{5,1,5,1,5}
%     \portal{1}{1}
%     \portal{5}{5}
%   \end{tunnel}
%   \hspace{1.5cm}
%   \begin{tunnel}
%     \framepuzzle
%     \tunnelH{4,3,3,3,4}
%     \tunnelV{5,1,5,1,5}
%     \portal{1}{1}
%     \portal{5}{5}
%     \tube{\tikzpath{1}{1}{6,6,6,6,8,8,4,4,4,4,8,8,6,6,6,6}}
%   \end{tunnel}
% \end{center}
% \end{figure}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{center}
  \begin{tunnel}
    \framepuzzle
    \tunnelH{4,3,3,3,4}
    \tunnelV{5,1,5,1,5}
    \portal{1}{1}
    \portal{5}{5}
  \end{tunnel}
  \hspace{1.5cm}
  \begin{tunnel}
    \framepuzzle
    \tunnelH{4,3,3,3,4}
    \tunnelV{5,1,5,1,5}
    \portal{1}{1}
    \portal{5}{5}
    \tube{\tikzpath{1}{1}{6,6,6,6,8,8,4,4,4,4,8,8,6,6,6,6}}
  \end{tunnel}
\end{center}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{Options}
% \begin{optionlist}
%   \optitem{\envoption{rows}}{5}{defines the number of rows in the grid.}
%   \optitem{\envoption{columns}}{5}{specifies the number of columns in the grid}
%   \optitem{\envoption{width}}{5.9cm}{sets the width of the minipage, in which the grid is typeset.}
%   \optitem{\envoption{scale}}{1}{scales the size of the grid in the minipage.}
%   \optitem{\envoption{fontsize}}{Large}{specifies the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge}}
%   \optitem{\envoption{title}}{}{sets the title of a puzzle.}
%   \optitem{\envoption{titleindent}}{0cm}{defines the indent of the title.}
%   \optitem{\envoption{titlewidth}}{5.9cm}{specifies the width of the box the title is set in.}
%   \optitem{\envoption{bgcolor}}{}{sets the background color of the grid.}
%   \optitem{\envoption{counterstyle}}{none}{defines the counter style. Predefined styles: none, left, right}
%   \optitem{\envoption{cvoffset}}{-23pt}{sets the vertical offset of the counters in the margin.}
% \end{optionlist}
% You\IfFileExists{qrcode.png}{\marginnote{\href{https://bitbucket.org/kleberj/logicpuzzle/}{\includegraphics[height=2cm]{qrcode.png}}}[-37pt]}{} can download application examples and their solutions from the \href{https://bitbucket.org/kleberj/logicpuzzle/}{project page}. The puzzles are originally licensed under \href{http://creativecommons.org/licenses/by-nc-sa/3.0/}{\ccbyncsa}.
% \section{Implemenation}
%
% \changes{v1.0}{2013/02/09}{first version of battleship.sty on CTAN}
% \changes{v1.2}{2013/02/17}{moved code base for logic puzzles into logicpuzzle.sty}
% \changes{v1.3}{2013/03/05}{added support for \texttt{bokkusu} puzzle}
% \changes{v1.4}{2013/03/05}{added support for \texttt{skyline} puzzle}
% \changes{v1.5}{2013/03/05}{added support for \texttt{hakyuu} puzzle}
% \changes{v1.5}{2013/03/13}{added support for \texttt{skyline} and \texttt{chaossudoku} puzzles}
% \changes{v1.6}{2013/03/18}{added support for \texttt{lpsudoku} puzzle}
% \changes{v1.7}{2013/03/28}{added support for \texttt{ddsudoku} puzzle}
% \changes{v1.7}{2013/04/03}{added support for \texttt{hitori} puzzle}
% \changes{v1.8}{2013/04/09}{added support for \texttt{killersudoku} and \texttt{kendokut} puzzles}
% \changes{v1.9}{2013/04/15}{added support for \texttt{slitherlink} puzzle}
% \changes{v1.9}{2013/04/17}{added support for \texttt{laserbeam} puzzle}
% \changes{v2.0}{2013/04/22}{added support for \texttt{minesweeper} puzzle}
% \changes{v2.0}{2013/04/23}{added support for \texttt{tunnel} puzzle}
% \changes{v2.0}{2013/04/30}{moved code from packages to \texttt{logicpuzzle.sty}}
% \changes{v2.1}{2013/05/04}{added support for \texttt{tentsandtrees} puzzle}
% \changes{v2.1}{2013/05/05}{added support for \texttt{kakuro} puzzle}
% \changes{v2.1}{2013/05/06}{added support for \texttt{schatzsuche} puzzle}
% \changes{v2.2}{2013/05/14}{added support for \texttt{sunandmoon} and \texttt{starsandarrows} puzzles}
% \changes{v2.2}{2013/05/15}{added support for \texttt{starbattle} puzzle}
% \changes{v2.2}{2013/05/16}{added support for \texttt{bridges} puzzle}
% \changes{v2.3}{2013/05/27}{added support for \texttt{resuko} puzzle}
% \changes{v2.3}{2013/05/28}{added support for \texttt{fourwinds} puzzle}
% \changes{v2.3}{2013/05/29}{added support for \texttt{numberlink} puzzle}
% \changes{v2.4}{2013/06/03}{added support for \texttt{magiclabyrinth} snd \texttt{masyu} puzzles}
% \changes{v2.4}{2013/06/04}{added support for \texttt{magnets} puzzle}
% \changes{v2.5}{2014/06/13}{added \texttt{LPpreset} Ti\textit{k}Z style to all puzzle environments}
% \changes{v2.5}{2014/06/14}{added support for \texttt{nonogram} puzzle. Feature request by: Theresa Spannbauer}
%
% \subsection{\texttt{logicpuzzle.sty}}
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{logicpuzzle}[2014/06/15 v2.5 logicpuzzle.sty%
                 - Josef Kleber (C) 2013-2014]%
%    \end{macrocode}
% \subsubsection{Package initialization}
% First, we load the packages needed by \package{logicpuzzle.sty} and the Ti\textit{k}Z libraries we need.
%    \begin{macrocode}
\RequirePackage{xkeyval}%
\RequirePackage{ifthen}%
\RequirePackage{ragged2e}%
\RequirePackage{marginnote}%
\RequirePackage{tikz}%
\usetikzlibrary{decorations.pathmorphing,decorations.pathreplacing,%
                calc,shapes.geometric}%
%    \end{macrocode}
% We define a set of PGF layers for placing material on them and their order.
%    \begin{macrocode}
\pgfdeclarelayer{LPdump}%
\pgfdeclarelayer{LPbgcolor}%
\pgfdeclarelayer{LPbackgroundtwo}%
\pgfdeclarelayer{LPbackground}%
\pgfdeclarelayer{LPforeground}%
\pgfdeclarelayer{LPforegroundtwo}%
\pgfsetlayers{LPdump,LPbgcolor,LPbackgroundtwo,LPbackground,main,%
              LPforeground,LPforegroundtwo}%
%
%    \end{macrocode}
% We also need some counters and lengths
% \changes{v2.2}{2013/05/07}{reduced counters to \texttt{LP@rows} and \texttt{LP@columns} instead of \texttt{LP@XX@...}}
%    \begin{macrocode}
\newcounter{LP@rows}%
\newcounter{LP@columns}%
\newcounter{LP@counter@unique}%
\newcounter{LP@counti}%
\newcounter{LP@countii}%
\newcounter{LP@countiii}%
\newcounter{LP@whiledo@i}%
\newcounter{LP@whiledo@ii}%
\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}%
%
\newlength\LP@length%
%    \end{macrocode}
% We define generic macros for puzzle options and add some defaults. Furthermore we define some macros, we will use all over the package.
%    \begin{macrocode}
\gdef\LP@rows{}%
\gdef\LP@columns{}%
\gdef\LP@scale{1}%
\gdef\LP@color{black}%
\gdef\LP@bgcolor{}%
\gdef\LP@fontsize\Large%
\gdef\LP@cvoffset{0pt}%
%
\newcommand*\LP@counterstyle{none}%
\newcommand*\LP@titleformat{}%
\gdef\LP@env@prefix{}%
\gdef\LP@package{}%
\def\LP@normallines{0.5pt}%
\def\LP@thicklines{1.5pt}%
\def\LP@grid@linestyle{}%
\def\LP@draw@opacity{1}%
\def\LP@rel@tikzpath{}%
\def\LP@tracks@scale{.3}%
\def\LP@fw@linestyle{-|}%
\newcommand*\LP@Pfive{.5}%
%    \end{macrocode}
% \subsubsection{Defining options}
% \begin{macro}{\LP@define@key}
% We define a generic command for the definition of puzzle options
% with both global (for the |\puzzlesetup| commands) and local scope for the optional argument of the puzzles!
%
% \cs{LP@define@key}\marg{puzzle prefix}\marg{puzzle}\marg{option}\marg{default}
%    \begin{macrocode}
\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}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@define@choicekey@fontsize}
% We do the same for the more complicated |choicekey| for the |fontsize| option.
%
% \cs{LP@define@choicekey@fontsize}\marg{puzzle prefix}\marg{puzzle}\marg{default}
%    \begin{macrocode}
\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%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Defining colors}
% \begin{macro}{\LP@definecolor}
% We define a command for defining (rgb) colors. For other color models, use
% |xcolor|'s |\definecolor| command.
%
% \cs{LP@definecolor}\marg{name}\marg{rgb color}
%    \begin{macrocode}
\newcommand*\LP@definecolor[2]%
{%
  \definecolor{#1}{rgb}{#2}%
}%
%    \end{macrocode}
%  Predefined colors:
%    \begin{macrocode}
\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}%
\LP@definecolor{LP@c@griddots}{.25,.51,.33}%
\LP@definecolor{LP@c@cross}{.25,.51,.33}%
\LP@definecolor{LP@c@mirror}{.8,.8,.8}%
\LP@definecolor{LP@c@tunnel}{.7,.7,.7}%
\LP@definecolor{LP@c@tunnel@i}{.8,.8,.8}%
\LP@definecolor{LP@c@tunnel@ii}{.5,.5,.5}%
\LP@definecolor{LP@c@bridge}{1,0,0}%
\colorlet{LP@c@track}{black!80}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Drawing grids}
% \begin{macro}{\LP@drawgrid}
% We define a command for drawing the standard grid used by all puzzles. In general,
% this should be a grid with a step of 1cm and thin lines with size
% (1,1) to ($|columns|+1$,$|rows|+1$). You can influence the grid by redefining
% the |\LP@grid@linestyle| (default: |solid| -- maybe you want |dashed|) and |\LP@draw@opacity|
% (0 (transparent) -- 1 (opaque)). They should be changed only within groups, like puzzle environment definitions.
%
% \cs{LP@drawgrid}\marg{xmin}\marg{ymin}\marg{xmax}\marg{ymax}\marg{step}
%    \begin{macrocode}
\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,line width=\LP@normallines,\LP@grid@linestyle,%
        draw opacity=\LP@draw@opacity]%
        (#1,#2) grid (\value{LP@counti},\value{LP@countii});%
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Drawing the puzzle background}
% \begin{macro}{\LP@drawbackground}
% For drawing the puzzle background, we simply draw a rectangle with the size
% of the puzzle on the \layer{LPbgcolor} layer and fill it with \marg{bgcolor}.
%
% \cs{LP@drawbackground}\marg{xmin}\marg{ymin}\marg{xmax}\marg{ymax}\marg{bgcolor}
%    \begin{macrocode}
\newcommand*\LP@drawbackground[5]%
{%
%    \end{macrocode}
% Of course, we only draw a background, if \marg{bgcolor} is not empty!
%    \begin{macrocode}
  \ifthenelse{\equal{#5}{}}%
  {}% no bgcolor
  {%
    \setcounter{LP@counti}{#3}% max column
    \setcounter{LP@countii}{#4}% max row
    \stepcounter{LP@counti}%
    \stepcounter{LP@countii}%
    \begin{pgfonlayer}{LPbgcolor}%
      \fill[color=#5] (#1,#2) rectangle%
                      (\value{LP@counti},\value{LP@countii});%
    \end{pgfonlayer}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{In the grid}
% \changes{v1.1}{2013/02/11}{implemented \cmd\BS@ingrid\ checks if coordinate is in the grid $\rightarrow$ PackageError}
% \begin{macro}{\LP@ingrid}
% With this macro, we can check if the specified |column| and |row| is within
% the puzzle borders. Otherwise we issue en error message. This macro can be used
% by higher level commands, which try to place something in the grid.
%
% \cs{LP@ingrid}\marg{column}\marg{row}\marg{max column}\marg{max row}\marg{package}
%    \begin{macrocode}
\newcommand*\LP@ingrid[5]%
{%
%    \end{macrocode}
% First, we define some counters to store the arguments.
%    \begin{macrocode}
  \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
%    \end{macrocode}
% Then, we can check, if the specified |coordinate| is within the borders of the puzzle.
%    \begin{macrocode}
  \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%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setrule}
% For the \env{kendoku} and \env{killersudoku} environments, we need a command to
% place a calculation rule in the top left corner of the specified cell.
%
% \cs{setrule}\marg{column}\marg{row}\marg{rule}
%    \begin{macrocode}
\newcommand*\setrule[3]%
{%
%    \end{macrocode}
% First, we copy the |scale| and |bgcolor| values from the current environment.
%    \begin{macrocode}
  \LP@set@LP@scale{\LP@env@prefix}%
  \LP@set@LP@bgcolor{\LP@env@prefix}%
%    \end{macrocode}
% If no |bgcolor| is specified, we use |white| for drawing our helper rectangle.
% We also step our unique node counter, we need for referencing nodes between different layers.
%    \begin{macrocode}
  \ifthenelse{\equal{\LP@bgcolor}{}}%
  {\gdef\LP@sr@bgcolor{white}}%
  {\gdef\LP@sr@bgcolor{\LP@bgcolor}}%
  \stepcounter{LP@counter@unique}%
%    \end{macrocode}
% First, we draw a (invisible) helper rectangle on the \layer{LPdump} layer (behind the
% \layer{LPbgcolor} layer) in the node |A_\theLP@counter@unique|
%    \begin{macrocode}
  \begin{pgfonlayer}{LPdump}%
    \node [shape=rectangle,inner sep=0pt] (A_\theLP@counter@unique)%
    at (#1\LP@Pfive,#2\LP@Pfive)%
       {\tikz\draw[scale=\LP@scale,color=\LP@sr@bgcolor]%
                  (0.08,0.1) rectangle (0.92,0.9);};%
  \end{pgfonlayer}%
%    \end{macrocode}
% Then, we can place a visible node on the \layer{main} layer in the top left corner
% of the invisible helper rectangle with the rule (size: $|\tiny|\times|scale|$).
%    \begin{macrocode}
  \node [shape=rectangle,inner sep=0pt,anchor=north west,%
         scale=\LP@scale,font=\tiny] at%
        (A_\theLP@counter@unique.north west) {$#3$};%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@G@setcellcontent}
% Here, we define a generic macro for placing material into nodes
% placed in the bottom left corner of the grid cell. You can use
% the options |vcenter| and |hcenter| in the optional argument \oarg{options}
% of the macro to center the content horizontally and/or vertically.
%
% \cs{LP@G@setcellcontent}\oarg{options}\marg{column}\marg{row}\marg{content}
%    \begin{macrocode}
\define@key{LP@G@setcellcontent}{vcenter}[\LP@Pfive]%
{%
  \def\LP@scc@v{\LP@Pfive}%
}%
\define@key{LP@G@setcellcontent}{hcenter}[\LP@Pfive]%
{%
  \def\LP@scc@h{\LP@Pfive}%
}%
%
\newcommand*\LP@G@setcellcontent[4][]%
{%
  \def\LP@scc@h{}%
  \def\LP@scc@v{}%
  \setkeys{LP@G@setcellcontent}{#1}%
  \node at (#2\LP@scc@h,#3\LP@scc@v){#4};%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@setcellcontent}
% For compatibility, we still provide the old |\LP@setcellcontentXY| macros.
%    \begin{macrocode}
\newcommand*\LP@setcellcontent[3]%
{%
  \LP@G@setcellcontent[hcenter,vcenter]{#1}{#2}{#3}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@setcellcontentC}
%    \begin{macrocode}
\newcommand*\LP@setcellcontentC[3]%
{%
  \LP@G@setcellcontent{#1}{#2}{#3}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@setcellcontentVE}
%    \begin{macrocode}
\newcommand*\LP@setcellcontentVE[3]%
{%
  \LP@G@setcellcontent[vcenter]{#1}{#2}{#3}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@setcellcontentHE}
%    \begin{macrocode}
\newcommand*\LP@setcellcontentHE[3]%
{%
  \LP@G@setcellcontent[hcenter]{#1}{#2}{#3}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@setrowcontents}
% \changes{v1.3}{2013/02/26}{Bugfix: mix up column and row}
% We want also be able to set the contents of a complete row.
%
% \cs{LP@setrowcontents}\marg{csv list}\marg{column}\marg{row}
%    \begin{macrocode}
\newcommand*\LP@setrowcontents[3]%
{%
%    \end{macrocode}
% We copy |fontsize| from the current environment, if we want to typeset numbers or letters.
%    \begin{macrocode}
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \setcounter{LP@counti}{#2}%
  \setcounter{LP@countii}{#3}%
%    \end{macrocode}
% We loop through the list and create a centered node in cell (|column|,|row|). Finally, we step the |column| counter.
%    \begin{macrocode}
  \foreach \LP@element in {#1}%
  {%
    \LP@G@setcellcontent[vcenter,hcenter]%
      {\arabic{LP@counti}}{\arabic{LP@countii}}%
      {\LP@fontsize\LP@element}%
    \stepcounter{LP@counti}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@setcolumncontents}
% \changes{v1.3}{2013/02/26}{Bugfix: mix up column and row}
% Of course, we want to do the same for columns.
%
% \cs{LP@setcolumncontens}\marg{csv list}\marg{column}\marg{row}
%    \begin{macrocode}
\newcommand*\LP@setcolumncontents[3]%
{%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \setcounter{LP@counti}{#2}%
  \setcounter{LP@countii}{#3}%
  \foreach \LP@element in {#1}%
  {%
    \LP@G@setcellcontent[vcenter,hcenter]%
      {\arabic{LP@counti}}{\arabic{LP@countii}}%
      {\LP@fontsize\LP@element}%
    \stepcounter{LP@countii}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@setrowcontents@edge}
% For environments like \env{laserbeam}, we need to typeset |row| contents on the left
% border of the cell, instead of centered. Therfore, we only use |vcenter|.
%
% \cs{LP@setrowcontents@edge}\marg{csv list}\marg{column}\marg{row}
%    \begin{macrocode}
\newcommand*\LP@setrowcontents@edge[3]%
{%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \setcounter{LP@counti}{#2}%
  \setcounter{LP@countii}{#3}%
  \foreach \LP@element in {#1}%
  {%
    \LP@G@setcellcontent[vcenter]%
      {\arabic{LP@counti}}{\arabic{LP@countii}}%
      {\LP@fontsize\LP@element}%
    \stepcounter{LP@counti}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@setcolumncontents@edge}
% Furthermore, we need the ability to typeset a column on the bottom border of a
% cell (|hcenter|).
%
% \cs{LP@setcolumncontents@edge}\marg{csv list}\marg{column}\marg{row}
%    \begin{macrocode}
\newcommand*\LP@setcolumncontents@edge[3]%
{%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \setcounter{LP@counti}{#2}%
  \setcounter{LP@countii}{#3}%
  \foreach \LP@element in {#1}%
  {%
    \LP@G@setcellcontent[hcenter]%
      {\arabic{LP@counti}}{\arabic{LP@countii}}%
      {\LP@fontsize\LP@element}%
    \stepcounter{LP@countii}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setrow}
% \changes{v1.4}{2013/03/05}{added \cmd\setrow}
% The user command for typesetting row contents.
%
% \cs{setrow}\marg{row}\marg{csv list}
%    \begin{macrocode}
\newcommand*\setrow[2]%
{%
%    \end{macrocode}
% First, we copy |scale|, which might be necessary for graphical objects, like \cs{Mine}.
% Then, we hand over the arguments to the generic macro for typesetting |row| contents and start with |column| 1.
%    \begin{macrocode}
  \LP@set@LP@scale{\LP@env@prefix}%
  \LP@setrowcontents{#2}{1}{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setcolumn}
% \changes{v1.4}{2013/03/05}{added \cmd\setcolumn}
% Again, we do the same for columns.
%
% \cs{setcolumn}\marg{column}\marg{csv list}
%    \begin{macrocode}
\newcommand*\setcolumn[2]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \LP@setcolumncontents{#2}{#1}{1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setcell}
% \changes{v1.4}{2013/03/06}{added \cmd\setcell}
% We need to set numbers, letters or a graphical object into a central node
% in grid cell (|column|,|row|)
%
% \cs{setcell}\marg{column}\marg{row}\marg{element}
%    \begin{macrocode}
\newcommand*\setcell[3]%
{%
%    \end{macrocode}
% First, we copy |scale|, |fontsize|, |rows| and |columns| from the current environment.
%    \begin{macrocode}
  \LP@set@LP@scale{\LP@env@prefix}%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \LP@set@LP@rows{\LP@env@prefix}%
  \LP@set@LP@columns{\LP@env@prefix}%
%    \end{macrocode}
% Then, we test if (\marg{column},\marg{row}) is within the borders of the puzzle.
% Finally, we typeset \marg{element} into a central node.
%    \begin{macrocode}
  \LP@ingrid{#1}{#2}{\LP@columns}{\LP@rows}{\LP@package}%
  \LP@G@setcellcontent[hcenter,vcenter]{#1}{#2}{\LP@fontsize#3}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setcells}
% \changes{v2.4}{2013/06/03}{added \cmd\setcells}
% We also want to typeset the same element into several grid cells.
% Therefore, we use a \marg{csv list} with the format: \marg{|column/row|, ...}
%
% \cs{setcells}\marg{csv list}\marg{element}
%    \begin{macrocode}
\newcommand*\setcells[2]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \LP@set@LP@rows{\LP@env@prefix}%
  \LP@set@LP@columns{\LP@env@prefix}%
  \foreach \LP@sc@column/\LP@sc@row in {#1}%
  {%
    \LP@ingrid{\LP@sc@column}{\LP@sc@row}%
      {\LP@columns}{\LP@rows}{\LP@package}%
    \LP@G@setcellcontent[hcenter,vcenter]%
      {\LP@sc@column}{\LP@sc@row}{\LP@fontsize#2}%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setbigcell}
% For the \env{slitherlink} environment, we need to typeset a huge ($2\times 2$) grid cell.
%
% \cs{setbigcell}\oarg{fontsize}\marg{column}\marg{row}\marg{element}
%    \begin{macrocode}
\newcommand*\setbigcell[4][Huge]%
{%
%    \end{macrocode}
% First, we copy |scale| and |bgcolor|. If |bgcolor| is not specified, we assume |bgcolor| is || white!
%    \begin{macrocode}
  \LP@set@LP@scale{\LP@env@prefix}%
  \LP@set@LP@bgcolor{\LP@env@prefix}%
  \ifthenelse{\equal{\LP@bgcolor}{}}%
  {\gdef\LP@sbc@bgcolor{white}}%
  {\gdef\LP@sbc@bgcolor{\LP@bgcolor}}%
%    \end{macrocode}
% The center of ($2\times 2$) cell is the bottom left corner of ($|column|+1,|row|+1$)
%    \begin{macrocode}
  \setcounter{LP@counti}{#2}%
  \setcounter{LP@countii}{#3}%
  \stepcounter{LP@counti}%
  \stepcounter{LP@countii}%
%    \end{macrocode}
% First, we 'clear' ($2\times 2$) area with |bgcolor| and respect the grid line style.
%    \begin{macrocode}
  \draw[line width=\LP@normallines,fill=\LP@sbc@bgcolor,%
        \LP@grid@linestyle]%
       (#2,#3) rectangle ++(2,2);%
%    \end{macrocode}
% As the grid dots were drawn on the \layer{LPforeground} layer, we have to
% 'overpaint' the center dot on the \layer{LPforegroundtwo} layer with |bgcolor|.
% Finally, we can typeset \marg{element}.
%    \begin{macrocode}
  \begin{pgfonlayer}{LPforegroundtwo}%
    \fill[color=\LP@sbc@bgcolor]%
      (\arabic{LP@counti},\arabic{LP@countii})%
      circle [radius=3.5pt*\LP@scale];%
    \node at (\arabic{LP@counti},\arabic{LP@countii})%
      {\csname#1\endcsname#4};%
  \end{pgfonlayer}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setcolorrow}
% For the \env{hitori} environment, we need to typeset row contents
% with numbers associated to background colors.
%
% \cs{setcolorrow}\marg{row}\marg{csv list}
%    \begin{macrocode}
\newcommand*\setcolorrow[2]%
{%
%    \end{macrocode}
% We start at |column| 1 and loop through \marg{csv list}
%    \begin{macrocode}
  \setcounter{LP@counti}{1}%
  \setcounter{LP@countii}{#1}%
  \foreach \LP@element in {#2}%
  {%
%    \end{macrocode}
% If the list element is 0, we fill the cell |black| on the \layer{LPbackground} layer.
%    \begin{macrocode}
    \ifthenelse{\equal{\LP@element}{0}}%
    {%
      \gdef\LP@HT@color{black}%
      \begin{puzzlebackground}%
        \fillcell{\arabic{LP@counti}}{\arabic{LP@countii}}%
      \end{puzzlebackground}%
    }%
    {%
%    \end{macrocode}
% Otherwise, we fill the cell with predefined color |LP@c@romannumber| on the
% \layer{LPbackground} layer and typeset the list element into the grid cell.
%    \begin{macrocode}
      \expandafter\gdef\expandafter\LP@HT@color%
        {LP@c@\romannumeral\LP@element}%
      \begin{puzzlebackground}%
        \fillcell{\arabic{LP@counti}}{\arabic{LP@countii}}%
      \end{puzzlebackground}%
      \setcell{\arabic{LP@counti}}{\arabic{LP@countii}}{\LP@element}%
    }%
    \stepcounter{LP@counti}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setcolorcolumn}
% Again, the same for columns.
%    \begin{macrocode}
\newcommand*\setcolorcolumn[2]%
{%
  \setcounter{LP@counti}{#1}%
  \setcounter{LP@countii}{1}%
  \foreach \LP@element in {#2}%
  {%
    \ifthenelse{\equal{\LP@element}{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\LP@element}%
      \begin{puzzlebackground}%
        \fillcell{\arabic{LP@counti}}{\arabic{LP@countii}}%
      \end{puzzlebackground}%
      \setcell{\arabic{LP@counti}}{\arabic{LP@countii}}{\LP@element}%
    }%
    \stepcounter{LP@countii}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\fillcell}
% \changes{v1.3}{2013/02/26}{added \cmd\LP@ingrid\ to \cmd\fillcell}
% Sometimes, we need to 'blacken' a grid cell.
%
% \cs{fillcell}\marg{column}\marg{row}
%    \begin{macrocode}
\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}%
%    \end{macrocode}
% After a border check, we typeset a black block (\cs{LP@Block}) into the grid cell.
%    \begin{macrocode}
  \LP@ingrid{#1}{#2}{\LP@columns}{\LP@rows}{\LP@package}%
  \LP@G@setcellcontent[hcenter,vcenter]{#1}{#2}{\LP@Block}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\fillrow}
% We also want to allow the filling of (parts of a) row.
%
% \cs{fillrow}\marg{row}\marg{csv list}
%    \begin{macrocode}
\newcommand*\fillrow[2]%
{%
  \setcounter{LP@counti}{1}%
  \setcounter{LP@countii}{#1}%
  \foreach \LP@element in {#2}%
  {%
%    \end{macrocode}
% We loop through the list and if |element| is 1, we fill this grid cell.
%    \begin{macrocode}
    \ifthenelse{\equal{\LP@element}{1}}%
    {\fillcell{\arabic{LP@counti}}{\arabic{LP@countii}}}%
    {}%
    \stepcounter{LP@counti}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\fillcolumn}
% Again the same, for columns!
%
% \cs{fillcolumn}\marg{column}\marg{csv list}
%    \begin{macrocode}
%
\newcommand*\fillcolumn[2]%
{%
  \setcounter{LP@counti}{#1}%
  \setcounter{LP@countii}{1}%
  \foreach \LP@element in {#2}%
  {%
    \ifthenelse{\equal{\LP@element}{1}}%
    {\fillcell{\arabic{LP@counti}}{\arabic{LP@countii}}}%
    {}%
    \stepcounter{LP@countii}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\framearea}
% \changes{v1.4}{2013/03/06}{added \cmd\framearea}
% Sometimes, we need to frame a specified area.
%
% \cs{framearea}\marg{color}\marg{TikZ path}
%    \begin{macrocode}
\newcommand*\framearea[2]%
{%
  \draw[line width=\LP@thicklines,color=#1] #2;%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\fillarea}
% \changes{v1.4}{2013/03/06}{added \cmd\fillarea}
% Sometimes, we even want to fill the area.
%
% \cs{fillarea}\marg{color}\marg{TikZ path}
%    \begin{macrocode}
\newcommand*\fillarea[2]%
{%
  \draw[line width=\LP@thicklines,fill=#1] #2;%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\colorarea}
% \changes{v1.8}{2013/04/09}{added \cmd\colorarea\ (\cmd\framearea\ without frame)}
% In some cases it might be better just to fill the area without drawing a frame.
%
% \cs{colorarea}\marg{color}\marg{TikZ path}
%    \begin{macrocode}
\newcommand*\colorarea[2]%
{%
  \fill[color=#1] #2 ;%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tikzpath}
% Using a \marg{Tikz path} can be cumbersome. \cs{tikzpath} construct a path starting at the
% bottom left corner of grid cell (|column|,|row|). If want to start in the center of the cell,
% redefine \cs{LP@rel@tikzpath} to |.5| inside a group! Inside \marg{csv list of relative moves},
% you can specify relative movements from one grid cell to the next based on num pad
% (4 $\rightarrow$ one cell right, 2 $\rightarrow$ one cell down and 9 $\rightarrow$
% one cell right up).
%
% \cs{tikzpath}\marg{column}\marg{row}\marg{csv list of relative movement}
%    \begin{macrocode}
\newcommand*\tikzpath[3]%
{%
%    \end{macrocode}
% starting point
%    \begin{macrocode}
  (#1\LP@rel@tikzpath,#2\LP@rel@tikzpath)%
%    \end{macrocode}
% We loop through the list and add a relative path segment based on the direction indicator.
%    \begin{macrocode}
  \foreach \LP@direction in {#3}%
  {%
    \ifnum\LP@direction=1%
    --++(-1,-1)%
    \fi%
    \ifnum\LP@direction=2%
    --++(0,-1)%
    \fi%
    \ifnum\LP@direction=3%
    --++(1,-1)%
    \fi%
    \ifnum\LP@direction=4%
    --++(-1,0)%
    \fi%
    \ifnum\LP@direction=6%
    --++(1,0)%
    \fi%
    \ifnum\LP@direction=7%
    --++(-1,1)%
    \fi%
    \ifnum\LP@direction=8%
    --++(0,1)%
    \fi%
    \ifnum\LP@direction=9%
    --++(1,1)%
    \fi%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\xtikzpath}
% \cs{xtikzpath} is based on \cs{tikzpath} with a slightly different format in
% \marg{csv list of relative movements}. It allows pairs of |direction/length|, e.g.
% (6/2) means two cells right.
%
% \cs{xtikzpath}\marg{column}\marg{row}\marg{csv list of relative movements}
%    \begin{macrocode}
\newcommand*\xtikzpath[3]%
{%
  (#1\LP@rel@tikzpath,#2\LP@rel@tikzpath)%
  \foreach \LP@dir/\LP@plength in {#3}%
  {%
    \ifnum\LP@dir=1%
    --++(-\LP@plength,-\LP@plength)%
    \fi%
    \ifnum\LP@dir=2%
    --++(0,-\LP@plength)%
    \fi%
    \ifnum\LP@dir=3%
    --++(\LP@plength,-\LP@plength)%
    \fi%
    \ifnum\LP@dir=4%
    --++(-\LP@plength,0)%
    \fi%
    \ifnum\LP@dir=6%
    --++(\LP@plength,0)%
    \fi%
    \ifnum\LP@dir=7%
    --++(-\LP@plength,\LP@plength)%
    \fi%
    \ifnum\LP@dir=8%
    --++(0,\LP@plength)%
    \fi%
    \ifnum\LP@dir=9%
    --++(\LP@plength,\LP@plength)%
    \fi%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\filldiagonals}
% For some puzzles we need colored diagonals indicating that also the diagonals are relevant,
% not just rows and columns.
%
% \cs{filldiagonals}\oarg{color}
%    \begin{macrocode}
\newcommand*\filldiagonals[1][yellow!20]%
{%
%    \end{macrocode}
% We copy and get |scale|, |$rows+1$| and |$columns+1$|,
%    \begin{macrocode}
  \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}%
%    \end{macrocode}
% We only color the diagonals, if the puzzle is quadratic. Otherwise, coloring diagonals
% doen't make sense and we issue an error.
%    \begin{macrocode}
  \ifnum\value{LP@counti}=\value{LP@countii}%
%    \end{macrocode}
% We color the diagonals on the \layer{LPbackground} layer and redefine \cs{LP@color}
% (for \cs{LP@Block}) inside a group with local scope.
%    \begin{macrocode}
    \begin{puzzlebackground}%
      \def\LP@color{#1}%
%    \end{macrocode}
% We use two counters running from (|1 .. rows|) and (|rows .. 1|) and color the cells
% on the diagonals in a loop.
%    \begin{macrocode}
      \setcounter{LP@whiledo@i}{1}%
      \setcounter{LP@whiledo@ii}{\LP@rows}%
      \whiledo{\value{LP@whiledo@i}<\value{LP@counti}}%
      {%
        \LP@G@setcellcontent[hcenter,vcenter]%
          {\arabic{LP@whiledo@i}}{\arabic{LP@whiledo@i}}{\LP@Block}%
        \LP@G@setcellcontent[hcenter,vcenter]%
          {\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%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\framepuzzle}
% \changes{v2.3}{2013/05/28}{Bugfix: \cmd\framepuzzle\ only worked correctly for quadratic puzzles}
% We might want to frame the puzzle with a thicker line.
%
% \cs{framepuzzle}\oarg{color}
%    \begin{macrocode}
\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}%
%    \end{macrocode}
% We copied |rows| and |columns| to get the top right corner of the puzzle.
% Now, we can draw the thicker lines.
%    \begin{macrocode}
  \draw[line width=\LP@thicklines,color=#1]%
    (1,1)--(1,\arabic{LP@countii});%
  \draw[line width=\LP@thicklines,color=#1]%
    (1,\arabic{LP@countii})--%
    (\arabic{LP@counti},\arabic{LP@countii});%
  \draw[line width=\LP@thicklines,color=#1]%
    (\arabic{LP@counti},\arabic{LP@countii})--%
    (\arabic{LP@counti},1);%
  \draw[line width=\LP@thicklines,color=#1]%
    (\arabic{LP@counti},1)--(1,1);%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{puzzlebackground}
% \changes{v1.4}{2013/03/06}{added \env{puzzlebackground}}
% Sometimes, we want to move material to the \layer{LPbackground} layer.
%    \begin{macrocode}
\newenvironment{puzzlebackground}%
{%
  \begin{pgfonlayer}{LPbackground}%
}%
{%
  \end{pgfonlayer}%
}%
%    \end{macrocode}
% \end{environment}
% \begin{environment}{puzzleforeground}
% \changes{v1.4}{2013/03/06}{added \env{puzzleforeground}}
% Sometimes, we want to move material to the \layer{LPforeground} layer.
%    \begin{macrocode}
\newenvironment{puzzleforeground}%
{%
  \begin{pgfonlayer}{LPforeground}%
}%
{%
  \end{pgfonlayer}%
}%
%    \end{macrocode}
% \end{environment}
% \subsubsection{Around the grid}
%
% For most puzzles, we need to put numbers below, above, to the right or to the left of the puzzle.
% \begin{macro}{\LP@bottomrow}
% Put numbers below the puzzle.
%
% \cs{LP@bottomrow}\marg{csv list}
%    \begin{macrocode}
\newcommand*\LP@bottomrow[1]%
{%
  \LP@setrowcontents{#1}{1}{0}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@bottomrow@edge}
% Put numbers below the puzzle, but on the edge.
%
% \cs{LP@bottomrow@edge}\marg{csv list}
%    \begin{macrocode}
\newcommand*\LP@bottomrow@edge[1]%
{%
  \LP@setrowcontents@edge{#1}{1}{0}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@leftcolumn}
% Put numbers left to the puzzle.
%
% \cs{LP@leftcolumn}\marg{csv list}
%    \begin{macrocode}
\newcommand*\LP@leftcolumn[1]%
{%
  \LP@setcolumncontents{#1}{0}{1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@toprow}
% Put number on top of the puzzle.
%
% \cs{LP@toprow}\marg{csv list}
%    \begin{macrocode}
\newcommand*\LP@toprow[1]%
{%
  \LP@setrowcontents{#1}{1}{\theLP@rows}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@rightcolumn}
% Put numbers right to the puzzle.
%
% \cs{LP@rightcolumn}\marg{csv list}
%    \begin{macrocode}
\newcommand*\LP@rightcolumn[1]%
{%
  \LP@setcolumncontents{#1}{\theLP@columns}{1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@rightcolumn@edge}
% Put numbers right next to the puzzle, but on the edge.
%
% \cs{LP@rightcolumn@rdge}\marg{csv list}
%    \begin{macrocode}
\newcommand*\LP@rightcolumn@edge[1]%
{%
  \LP@setcolumncontents@edge{#1}{\theLP@columns}{1}%
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Presentation}
% \begin{macro}{\titleformat}
% You can redefine the format of the puzzle at any time.
%    \begin{macrocode}
\newcommand*\titleformat[1]%
{%
  \renewcommand*\LP@titleformat{#1}%
}%
%    \end{macrocode}
% \end{macro}
% We define thew default title format:
%    \begin{macrocode}
\titleformat{\centering\Large\color{blue}}%
%    \end{macrocode}
% \begin{macro}{\puzzlecounter}
% User command to get the current puzzle counter.
%    \begin{macrocode}
\newcommand*\puzzlecounter{\theLP@puzzlecounter}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setpuzzlecounter}
% User command to reset the puzzle counter, e.g. before the solution section.
%    \begin{macrocode}
\newcommand*\setpuzzlecounter[1]%
{%
  \setcounter{LP@puzzlecounter}{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@drawcounter}
% Maybe we want to draw puzzle counter, or not (|counterstyle=none|).
%
% \cs{LP@drawcounter}\marg{counterstyle}
%    \begin{macrocode}
\newcommand*\LP@drawcounter[1]%
{%
%    \end{macrocode}
% We copy |cvoffset| and execute the macro we defined for the respective |counterstyle|.
%    \begin{macrocode}
  \LP@set@LP@cvoffset{\LP@env@prefix}%
  \csname LP@cs@#1\endcsname%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\definecounterstyle}
% Maybe a user want to define his/her own counter style.
%
% \cs{definecounterstyle}\marg{counterstyle}\marg{definition}
%    \begin{macrocode}
\newcommand*{\definecounterstyle}[2]%
{%
%    \end{macrocode}
% We define a |counterstyle| macro and store its definition.
%    \begin{macrocode}
  \expandafter\gdef\csname LP@cs@#1\endcsname{#2}%
}%
%    \end{macrocode}
% \end{macro}
% We define three predefined |counterstyle|s |none|, |left| and |right|.
%    \begin{macrocode}
\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]%
}%
%    \end{macrocode}
% \subsubsection{Misc macros}
% \begin{macro}{\LP@Block}
% We define a Ti{\itshape k}Z picture with the size of a grid cell ($1cm\times 1cm$)
% and fill it with |color|.
%    \begin{macrocode}
\newcommand*\LP@Block{%
  \tikz[scale=\LP@scale]%
    \draw[line width=\LP@normallines,fill=\LP@color]%
      (0,0) rectangle (1,1);}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@Line}
% A generic command for drawing lines with options |double|, |color| and |linewidth|.
%
% \cs{LP@Line}\oarg{options}\marg{TikZ path}
%    \begin{macrocode}
\define@key{LP@Line}{double}[double]%
{%
  \def\LP@Line@double{double}%
}%
%
\define@key{LP@Line}{color}[LP@c@bridge]%
{%
  \def\LP@Line@linecolor{#1}%
}%
%
\define@key{LP@Line}{linewidth}[1mm]%
{%
  \def\LP@Line@linewidth{#1}%
}%
%
\newcommand*\LP@Line[2][]%
{%
  \def\LP@Line@double{}%
  \def\LP@Line@linecolor{LP@c@bridge}%
  \def\LP@Line@linewidth{1mm}%
  \setkeys{LP@Line}{#1}%
%    \end{macrocode}
% By default we draw a single 1mm wide line with color |LP@c@bridge|.%
% But we can change thar with \oarg{options}.
%    \begin{macrocode}
  \LP@set@LP@scale{\LP@env@prefix}%
%    \end{macrocode}
% Then we can draw a single or double line based on the defined options or defaults.
%    \begin{macrocode}
  \begin{pgfonlayer}{LPbackgroundtwo}%
    \ifthenelse{\equal{\LP@Line@double}{double}}%
    {\draw[double,double distance=\LP@Line@linewidth*\LP@scale,%
           color=\LP@Line@linecolor,%
           line width=\LP@Line@linewidth*\LP@scale] #2;}%
    {\draw[color=\LP@Line@linecolor,%
           line width=\LP@Line@linewidth*\LP@scale] #2;}%
  \end{pgfonlayer}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@set@LP@scale}
%    \begin{macrocode}
\newcommand*\LP@set@LP@scale[1]%
{%
  \expandafter\xdef\expandafter\LP@scale{\csname #1@scale\endcsname}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@set@LP@color}
%    \begin{macrocode}
\newcommand*\LP@set@LP@color[1]%
{%
  \expandafter\xdef\expandafter\LP@color{\csname #1@color\endcsname}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@set@LP@rows}
%    \begin{macrocode}
\newcommand*\LP@set@LP@rows[1]%
{%
  \expandafter\xdef\expandafter\LP@rows{\csname #1@rows\endcsname}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@set@LP@columns}
%    \begin{macrocode}
\newcommand*\LP@set@LP@columns[1]%
{%
  \expandafter\xdef\expandafter\LP@columns{\csname #1@columns\endcsname}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@set@LP@cvoffset}
%    \begin{macrocode}
\newcommand*\LP@set@LP@cvoffset[1]%
{%
  \expandafter\xdef\expandafter\LP@cvoffset{\csname #1@cvoffset\endcsname}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@set@LP@bgcolor}
%    \begin{macrocode}
\newcommand*\LP@set@LP@bgcolor[1]%
{%
  \expandafter\xdef\expandafter\LP@bgcolor{\csname #1@bgcolor\endcsname}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@set@LP@extracells}
%    \begin{macrocode}
\newcommand*\LP@set@LP@extracells[1]%
{%
  \expandafter\xdef\expandafter\LP@extracells{\csname #1@extracells\endcsname}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@set@LP@fontsize}
%    \begin{macrocode}
\newcommand*\LP@set@LP@fontsize[1]%
{%
%   can't expand \Large
  \expandafter\gdef\expandafter\LP@fontsize{\csname #1@fontsize\endcsname}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@set@env@prefix}
%    \begin{macrocode}
\newcommand*\LP@set@env@prefix[1]%
{%
  \gdef\LP@env@prefix{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@set@package}
%    \begin{macrocode}
\newcommand*\LP@set@package[1]%
{%
  \gdef\LP@package{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setgridlinestyle}
%    \begin{macrocode}
\newcommand*\setgridlinestyle[1]%
{%
  \def\LP@grid@linestyle{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setnormallinewidth}
%    \begin{macrocode}
\newcommand*\setnormallinewidth[1]%
{%
  \def\LP@normallines{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setthicklinewidth}
%    \begin{macrocode}
\newcommand*\setthicklinewidth[1]%
{%
  \def\LP@thicklines{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\puzzlestrut}
%    \begin{macrocode}
\newcommand*\puzzlestrut%
{%
  \LP@set@LP@rows{\LP@env@prefix}%
  \ifthenelse{\equal{\LP@package}{nonogram}}%
  {%
    \LP@set@LP@extracells{\LP@env@prefix}%
    \setcounter{LP@counti}{\LP@rows}% max row
    \stepcounter{LP@counti}%
    \addtocounter{LP@counti}{\LP@NG@extracells}%
    \draw[line width=\LP@thicklines, transparent]%
      (1,1) -- (1,\arabic{LP@counti});%
  }{}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setTikZpreset}
%    \begin{macrocode}
\newcommand*\setTikZpreset[1]%
{%
  \tikzset{%
    LPpreset/.style={#1}%
  }%
}%
%
\setTikZpreset{line cap=rect,line join=round}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{logicpuzzle}
%    \begin{macrocode}
\newcommand*\LP@LP@init@prefix{LP@LP}%
\newcommand*\LP@LP@init@package{logicpuzzle}%
%
\LP@define@key{\LP@LP@init@prefix}{\LP@LP@init@package}%
{rows}{5}%
\LP@define@key{\LP@LP@init@prefix}{\LP@LP@init@package}%
{columns}{5}%
\LP@define@key{\LP@LP@init@prefix}{\LP@LP@init@package}%
{scale}{1}%
\LP@define@key{\LP@LP@init@prefix}{\LP@LP@init@package}%
{counterstyle}{none}%
\LP@define@key{\LP@LP@init@prefix}{\LP@LP@init@package}%
{color}{}%
\LP@define@key{\LP@LP@init@prefix}{\LP@LP@init@package}%
{bgcolor}{}%
\LP@define@key{\LP@LP@init@prefix}{\LP@LP@init@package}%
{width}{5.1cm}%
\LP@define@key{\LP@LP@init@prefix}{\LP@LP@init@package}%
{cvoffset}{-23pt}%
\LP@define@key{\LP@LP@init@prefix}{\LP@LP@init@package}%
{title}{}%
\LP@define@key{\LP@LP@init@prefix}{\LP@LP@init@package}%
{titleindent}{0cm}%
\LP@define@key{\LP@LP@init@prefix}{\LP@LP@init@package}%
{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@LP@init@prefix}%
{\LP@LP@init@package}{Large}%
%
\ExecuteOptionsX{rows,columns,width,fontsize,scale,bgcolor%
,cvoffset,counterstyle,title,titleindent,titlewidth}%
%
\ProcessOptionsX\relax%
%
\let\logicpuzzlecell\setcell%
%
\newcommand*\logicpuzzlesetup[1]%
{%
  \setkeys{logicpuzzle.sty}{#1}%
}%
%
\newenvironment{logicpuzzle}[1][]%
{%
  \setkeys{logicpuzzle}{#1}%
  \LP@set@package{logicpuzzle}%
  \LP@set@env@prefix{LP@LP}%
  \setcounter{LP@rows}{\LP@LP@rows}%
  \setcounter{LP@columns}{\LP@LP@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@LP@width}%
    \ifthenelse{\equal{\LP@LP@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@LP@titleindent}%
    \parbox{\LP@LP@titlewidth}{\strut\LP@titleformat\LP@LP@title}%
    \vspace{3mm}\par}%
    \begin{tikzpicture}[scale=\LP@LP@scale]%
      \LP@drawbackground{1}{1}{\LP@LP@columns}{\LP@LP@rows}%
      {\LP@LP@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@LP@columns}{\LP@LP@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@LP@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%
\RequirePackage{lpenv}%
%    \end{macrocode}
% \end{environment}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \subsection{lpenv.sty}
% Here's just a flat copy of \package{lpenv.sty}! The code for the puzzles are more or less simple copy \& paste.
% Take a look at section 1 for a detailed explanation of code needed for a puzzle environment.
%    \begin{macrocode}
%<*lpenv>
%    \end{macrocode}
%    \begin{macrocode}
%
% battleship environment and options
%
\newcommand*\LP@BS@init@prefix{LP@BS}%
\newcommand*\LP@BS@init@package{battleship}%
%
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{rows}{5}%
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{columns}{5}%
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{shipcolor}{green}%
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{scale}{1}%
%    \end{macrocode}
% \changes{v1.2}{2013/02/18}{added option \texttt{counterstyle}}
%    \begin{macrocode}
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{counterstyle}{none}%
%    \end{macrocode}
% \changes{v1.2}{2013/02/17}{added option \texttt{bgcolor}}
%    \begin{macrocode}
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{bgcolor}{}%
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{width}{6cm}%
%    \end{macrocode}
% \changes{v1.3}{2013/02/27}{added option cvoffset}
%    \begin{macrocode}
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{cvoffset}{-23pt}%
%    \end{macrocode}
% \changes{v1.2}{2013/02/18}{added option \texttt{title}}
%    \begin{macrocode}
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{title}{}%
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{titleindent}{0.75cm}%
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{titlewidth}{5.15cm}%
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{sbindent}{0.75cm}%
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{sbwidth}{5.15cm}%
\LP@define@key{\LP@BS@init@prefix}{\LP@BS@init@package}{sbshipscale}{1}%
\LP@define@choicekey@fontsize{\LP@BS@init@prefix}{\LP@BS@init@package}{{Large}}%
%
\gdef\LP@BS@shipbox{}%
\tikzstyle{island} = [fill=yellow!30,draw, decorate, decoration={random steps,segment length=2.7pt,amplitude=1.7pt}]%
%
\newcommand*\Ship{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor] (0,0) circle (1);}%
\newcommand*\ShipC{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor] (0,0)--(0,2)--(2,2)--(2,0)--cycle;}%
\newcommand*\ShipT{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](2,1)--(2,0)--(0,0)--(0,1) arc (180:0:1);}%
\newcommand*\ShipB{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](2,1)--(2,2)--(0,2)--(0,1) arc (180:360:1);}%
\newcommand*\ShipL{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}%
\newcommand*\ShipR{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}%
\newcommand*\Island{\tikz[scale=\LP@BS@scale]\draw[scale=.36,island] (0,0) rectangle (2,2);}%
\newcommand*\Water{\tikz[scale=\LP@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=\LP@BS@shipcolor] (0,0) circle (1);}%
\newcommand*\@ShipC{\tikz\draw[scale=.144,fill=\LP@BS@shipcolor] (0,0)--(0,2)--(2,2)--(2,0)--cycle;}%
\newcommand*\@ShipT{\tikz\draw[scale=.144,fill=\LP@BS@shipcolor](2,1)--(2,0)--(0,0)--(0,1) arc (180:0:1);}%
\newcommand*\@ShipB{\tikz\draw[scale=.144,fill=\LP@BS@shipcolor](2,1)--(2,2)--(0,2)--(0,1) arc (180:360:1);}%
\newcommand*\@ShipL{\tikz\draw[scale=.144,fill=\LP@BS@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}%
\newcommand*\@ShipR{\tikz\draw[scale=.144,fill=\LP@BS@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}%
%
\newcommand*\LP@BS@printship[1]%
{%
  \ifthenelse{\equal{#1}{1}}{\scalebox{\LP@BS@sbshipscale}{\@Ship}\space\allowbreak}{}%
  \ifthenelse{\equal{#1}{2}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipR}\space\allowbreak}{}%
  \ifthenelse{\equal{#1}{3}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
  \ifthenelse{\equal{#1}{4}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
  \ifthenelse{\equal{#1}{5}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
  \ifthenelse{\equal{#1}{6}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
  \ifthenelse{\equal{#1}{7}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
  \ifthenelse{\equal{#1}{8}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
  \ifthenelse{\equal{#1}{9}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
  \ifthenelse{\equal{#1}{10}}{\scalebox{\LP@BS@sbshipscale}{\@ShipL\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipC\,\@ShipR}\space\allowbreak}{}%
}%
%
\newcommand*\LP@BS@printshipbox[1]%
{%
%   no {#1}! to avoid expansion
  \foreach \LP@element in #1%
  {%
    \LP@BS@printship{\LP@element}%
  }%
}%
%
\newcommand*\shipH[1]%
{%
  \LP@setrowcontents{#1}{1}{\value{LP@rows}}%
}%
%
\newcommand*\shipV[1]%
{%
  \LP@setcolumncontents{#1}{0}{1}%
}%
%    \end{macrocode}
% \changes{v1.1}{2013/02/12}{renamed \cmd\ship\ $\rightarrow$ \cmd\placesegment}
%    \begin{macrocode}
\newcommand*\placesegment[3]%
{%
  \LP@ingrid{#1}{#2}{\LP@BS@columns}{\LP@BS@rows}{battleship}%
  \LP@G@setcellcontent[hcenter,vcenter]{#1}{#2}{#3}%
}%
%
\let\ship\placesegment%
%    \end{macrocode}
% \changes{v1.1}{2013/02/12}{added \cmd\placeisland}
%    \begin{macrocode}
\newcommand*\placeisland[2]%
{%
  \LP@ingrid{#1}{#2}{\LP@BS@columns}{\LP@BS@rows}{battleship}%
  \LP@G@setcellcontent[hcenter,vcenter]{#1}{#2}{\Island}%
}%
%    \end{macrocode}
% \changes{v1.1}{2013/02/12}{added \cmd\placewater}
%    \begin{macrocode}
\newcommand*\placewater[2]%
{%
  \LP@ingrid{#1}{#2}{\LP@BS@columns}{\LP@BS@rows}{battleship}%
  \LP@G@setcellcontent[hcenter,vcenter]{#1}{#2}{\Water}%
}%
%
\newcommand*\shipbox[2][]%
{%
  \setkeys{shipbox}{#1}%
  \gdef\LP@BS@shipbox{#2}%
}%
%    \end{macrocode}
% \changes{v1.1}{2013/02/11}{implemented \cmd\placeship; placement of a complete ship}
%    \begin{macrocode}
\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@i}{\value{LP@counti}}%
    \addtocounter{LP@whiledo@i}{-2}% length of middle ship
    \ifthenelse{\equal{#1}{V}}%
    {%
      \placesegment{#2}{#3}{\ShipB}%
      \setcounter{LP@countii}{#3}%
      \whiledo{\value{LP@whiledo@i}>0}%
      {%
        \addtocounter{LP@whiledo@i}{-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@i}>0}%
        {%
          \addtocounter{LP@whiledo@i}{-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%
}%
%
%    \end{macrocode}
% \changes{v1.1}{2013/02/10}{added \cmd\battleshipsetup\ for resetting global options}
%    \begin{macrocode}
\newcommand*\battleshipsetup[1]%
{%
  \setkeys{battleship.sty}{#1}%
}%
%
%    \end{macrocode}
% \changes{v1.2}{2013/02/19}{added \cmd\classicgame\ for drawing game sheets for classic Battleship}
%    \begin{macrocode}
\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}%
}%
%    \end{macrocode}
% \begin{environment}{battleship}
%    \begin{macrocode}
\newenvironment{battleship}[1][]%
{%
  \setkeys{battleship}{#1}%
  \LP@set@package{battleship}%
  \LP@set@env@prefix{LP@BS}%
  \shipbox{}% clear shipbox
  \setcounter{LP@rows}{\LP@BS@rows}%
  \setcounter{LP@columns}{\LP@BS@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@BS@width}%
    \ifthenelse{\equal{\LP@BS@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@BS@titleindent}\parbox{\LP@BS@titlewidth}{\strut\LP@titleformat\LP@BS@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@BS@scale]%
      \LP@drawbackground{1}{1}{\LP@BS@columns}{\LP@BS@rows}{\LP@BS@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@BS@columns}{\LP@BS@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@BS@counterstyle}%
    \par\hbadness=10000\medskip\noindent\hspace{\LP@BS@sbindent}\begin{minipage}{\LP@BS@sbwidth}{\hbadness=10000\RaggedRight\LP@BS@printshipbox{\LP@BS@shipbox}}\end{minipage}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
% \changes{v1.3}{2013/02/28}{added support for bokkusu puzzle}
%    \begin{macrocode}
%
% bokkusu environment and options
%
\newcommand*\LP@BK@init@prefix{LP@BK}%
\newcommand*\LP@BK@init@package{bokkusu}%
%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{rows}{5}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{columns}{5}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{scale}{1}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{counterstyle}{none}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{color}{black}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{bgcolor}{}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{width}{6.7cm}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{cvoffset}{-38pt}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{title}{}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{titleindent}{0.75cm}%
\LP@define@key{\LP@BK@init@prefix}{\LP@BK@init@package}{titlewidth}{5.85cm}%
\LP@define@choicekey@fontsize{\LP@BK@init@prefix}{\LP@BK@init@package}{Large}%
%
\let\valueH\LP@bottomrow%
\let\valueV\LP@leftcolumn%
\let\sumH\LP@toprow%
\let\sumV\LP@rightcolumn%
%
\newcommand*\bokkususetup[1]%
{%
  \setkeys{bokkusu.sty}{#1}%
}%
%    \end{macrocode}
% \begin{environment}{bokkusu}
%    \begin{macrocode}
\newenvironment{bokkusu}[1][]%
{%
  \setkeys{bokkusu}{#1}%
  \LP@set@package{bokkusu}%
  \LP@set@env@prefix{LP@BK}%
  \setcounter{LP@rows}{\LP@BK@rows}%
  \setcounter{LP@columns}{\LP@BK@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@BK@width}%
    \ifthenelse{\equal{\LP@BK@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@BK@titleindent}\parbox{\LP@BK@titlewidth}{\strut\LP@titleformat\LP@BK@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@BK@scale]%
      \LP@drawbackground{1}{1}{\LP@BK@columns}{\LP@BK@rows}{\LP@BK@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@BK@columns}{\LP@BK@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@BK@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% bridges environment and options
%
\newcommand*\LP@BG@init@prefix{LP@BG}%
\newcommand*\LP@BG@init@package{bridges}%
%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{rows}{5}%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{columns}{5}%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{scale}{1}%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{counterstyle}{none}%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{grid}{dashed}%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{bgcolor}{}%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{color}{green}%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{width}{6.1cm}%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{title}{}%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@BG@init@prefix}{\LP@BG@init@package}{titlewidth}{6.1cm}%
\LP@define@choicekey@fontsize{\LP@BG@init@prefix}{\LP@BG@init@package}{Large}%
%
\let\bridgescell\setcell%
%
\newcommand*\bridgessetup[1]%
{%
  \setkeys{bridges.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\bridgesrow}
% For the \env{bridges} environment, we need a special row command for drawing
% the islands with the numbers of bridges.
%
% \cs{bridgesrow}\marg{row}\marg{csv list}
%    \begin{macrocode}
\newcommand*\bridgesrow[2]%
{%
  \setcounter{LP@counti}{1}%
  \setcounter{LP@countii}{#1}%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \LP@set@LP@color{\LP@env@prefix}%
  \foreach \LP@element in {#2}%
  {%
%    \end{macrocode}
% We loop through the list anf if |element| is not empty, we draw an island
% (circle filled with |bgcolor|) and typeset the number of bridges into to center of the circle.
%    \begin{macrocode}
    \ifthenelse{\equal{\LP@element}{}}%
    {}%
    {%
      \draw[fill=\LP@color] (\arabic{LP@counti},\arabic{LP@countii})%
        circle (0.5cm);%
      \node[scale=\LP@scale,font=\LP@fontsize] at%
        (\arabic{LP@counti},\arabic{LP@countii}){\LP@element};%
    }%
    \stepcounter{LP@counti}%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\bridgescolumn}
% And again, for columns!
%    \begin{macrocode}
\newcommand*\bridgescolumn[2]%
{%
  \setcounter{LP@counti}{#1}%
  \setcounter{LP@countii}{1}%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \LP@set@LP@color{\LP@env@prefix}%
  \foreach \LP@element in {#2}%
  {%
    \ifthenelse{\equal{\LP@element}{}}%
    {}%
    {%
      \draw[fill=\LP@color] (\arabic{LP@counti},\arabic{LP@countii})%
        circle (0.5cm);%
      \node[scale=\LP@scale,font=\LP@fontsize]%
        at (\arabic{LP@counti},\arabic{LP@countii})%
        {\LP@element};%
    }%
    \stepcounter{LP@countii}%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\bridge}
% For the \env{bridges} environment, we need to draw bridges.
% Keep in mind that you can influence the appearance of the brigde with the options
% |double|, |color| and |linewidth|.
%
% \cs{bridge}\oarg{options}\marg{Tikz path}
%    \begin{macrocode}
\newcommand*\bridge[2][]%
{%
  \LP@Line[#1]{#2}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{bridges}
%    \begin{macrocode}
\newenvironment{bridges}[1][]%
{%
  \setkeys{bridges}{#1}%
  \LP@set@package{bridges}%
  \LP@set@env@prefix{LP@BG}%
  \setcounter{LP@rows}{\LP@BG@rows}%
  \setcounter{LP@columns}{\LP@BG@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@BG@width}%
    \ifthenelse{\equal{\LP@BG@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@BG@titleindent}\parbox{\LP@BG@titlewidth}{\strut\LP@titleformat\LP@BG@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@BG@scale]%
      \LP@drawbackground{1}{1}{\LP@BG@columns}{\LP@BG@rows}{\LP@BG@bgcolor}%
      \ifthenelse{\equal{\LP@BG@grid}{none}}%
      {}%
      {%
        \ifthenelse{\equal{\LP@BG@grid}{dashed}}%
        {%
          \setgridlinestyle{dashed}%
          \LP@drawgrid{1}{1}{\LP@BG@columns}{\LP@BG@rows}{1cm}%
        }%
        {%
          \LP@drawgrid{1}{1}{\LP@BG@columns}{\LP@BG@rows}{1cm}%
        }%
      }%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@BG@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% chaossudoku environment and options
%
\newcommand*\LP@CS@init@prefix{LP@CS}%
\newcommand*\LP@CS@init@package{chaossudoku}%
%
\LP@define@key{\LP@CS@init@prefix}{\LP@CS@init@package}{rows}{5}%
\LP@define@key{\LP@CS@init@prefix}{\LP@CS@init@package}{columns}{5}%
\LP@define@key{\LP@CS@init@prefix}{\LP@CS@init@package}{scale}{1}%
\LP@define@key{\LP@CS@init@prefix}{\LP@CS@init@package}{counterstyle}{none}%
\LP@define@key{\LP@CS@init@prefix}{\LP@CS@init@package}{bgcolor}{}%
\LP@define@key{\LP@CS@init@prefix}{\LP@CS@init@package}{width}{5.1cm}%
\LP@define@key{\LP@CS@init@prefix}{\LP@CS@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@CS@init@prefix}{\LP@CS@init@package}{title}{}%
\LP@define@key{\LP@CS@init@prefix}{\LP@CS@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@CS@init@prefix}{\LP@CS@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@CS@init@prefix}{\LP@CS@init@package}{Large}%
%
\let\chaossudokucell\setcell%
%
\newcommand*\chaossudokusetup[1]%
{%
  \setkeys{chaossudoku.sty}{#1}%
}%
%    \end{macrocode}
% \begin{environment}{chaossudoku}
%    \begin{macrocode}
\newenvironment{chaossudoku}[1][]%
{%
  \setkeys{chaossudoku}{#1}%
  \LP@set@package{chaossudoku}%
  \LP@set@env@prefix{LP@CS}%
  \setcounter{LP@rows}{\LP@CS@rows}%
  \setcounter{LP@columns}{\LP@CS@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@CS@width}%
    \ifthenelse{\equal{\LP@CS@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@CS@titleindent}\parbox{\LP@CS@titlewidth}{\strut\LP@titleformat\LP@CS@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@CS@scale]%
      \LP@drawbackground{1}{1}{\LP@CS@columns}{\LP@CS@rows}{\LP@CS@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@CS@columns}{\LP@CS@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@CS@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% ddsudoku environment and options
%
\newcommand*\LP@DDS@init@prefix{LP@DDS}%
\newcommand*\LP@DDS@init@package{ddsudoku}%
%
\LP@define@key{\LP@DDS@init@prefix}{\LP@DDS@init@package}{rows}{5}%
\LP@define@key{\LP@DDS@init@prefix}{\LP@DDS@init@package}{columns}{5}%
\LP@define@key{\LP@DDS@init@prefix}{\LP@DDS@init@package}{scale}{1}%
\LP@define@key{\LP@DDS@init@prefix}{\LP@DDS@init@package}{counterstyle}{none}%
\LP@define@key{\LP@DDS@init@prefix}{\LP@DDS@init@package}{bgcolor}{}%
\LP@define@key{\LP@DDS@init@prefix}{\LP@DDS@init@package}{width}{5.1cm}%
\LP@define@key{\LP@DDS@init@prefix}{\LP@DDS@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@DDS@init@prefix}{\LP@DDS@init@package}{title}{}%
\LP@define@key{\LP@DDS@init@prefix}{\LP@DDS@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@DDS@init@prefix}{\LP@DDS@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@DDS@init@prefix}{\LP@DDS@init@package}{Large}%
%
\let\ddsudokucell\setcell%
%
\newcommand*\ddsudokusetup[1]%
{%
  \setkeys{ddsudoku.sty}{#1}%
}%
%    \end{macrocode}
% \begin{environment}{ddsudoku}
%    \begin{macrocode}
\newenvironment{ddsudoku}[1][]%
{%
  \setkeys{ddsudoku}{#1}%
  \LP@set@package{ddsudoku}%
  \LP@set@env@prefix{LP@DDS}%
  \setcounter{LP@rows}{\LP@DDS@rows}%
  \setcounter{LP@columns}{\LP@DDS@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@DDS@width}%
    \ifthenelse{\equal{\LP@DDS@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@DDS@titleindent}\parbox{\LP@DDS@titlewidth}{\strut\LP@titleformat\LP@DDS@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@DDS@scale]%
      \LP@drawbackground{1}{1}{\LP@DDS@columns}{\LP@DDS@rows}{\LP@DDS@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@DDS@columns}{\LP@DDS@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@DDS@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% fourwinds environment and options
%
\newcommand*\LP@FW@init@prefix{LP@FW}%
\newcommand*\LP@FW@init@package{fourwinds}%
%
\LP@define@key{\LP@FW@init@prefix}{\LP@FW@init@package}{rows}{5}%
\LP@define@key{\LP@FW@init@prefix}{\LP@FW@init@package}{columns}{5}%
\LP@define@key{\LP@FW@init@prefix}{\LP@FW@init@package}{scale}{1}%
\LP@define@key{\LP@FW@init@prefix}{\LP@FW@init@package}{counterstyle}{none}%
\LP@define@key{\LP@FW@init@prefix}{\LP@FW@init@package}{bgcolor}{}%
\LP@define@key{\LP@FW@init@prefix}{\LP@FW@init@package}{color}{blue}%
\LP@define@key{\LP@FW@init@prefix}{\LP@FW@init@package}{width}{5.1cm}%
\LP@define@key{\LP@FW@init@prefix}{\LP@FW@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@FW@init@prefix}{\LP@FW@init@package}{title}{}%
\LP@define@key{\LP@FW@init@prefix}{\LP@FW@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@FW@init@prefix}{\LP@FW@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@FW@init@prefix}{\LP@FW@init@package}{Large}%
%
\newcommand*\fourwindscell[4]%
{%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \LP@set@LP@color{\LP@env@prefix}%
  \LP@set@LP@bgcolor{\LP@env@prefix}%
  \LP@set@LP@scale{\LP@env@prefix}%
  \ifthenelse{\equal{\LP@bgcolor}{}}%
  {\gdef\LP@c@bg@fw{white}}%
  {\gdef\LP@c@bg@fw{\LP@bgcolor}}%
  \foreach \LP@fw@dir/\LP@fw@length in {#4}%
  {%
    \begin{pgfonlayer}{LPbackgroundtwo}%
      \def\LP@rel@tikzpath{.5}%
      \draw[\LP@fw@linestyle,color=\LP@color,line width=.1cm*\LP@scale,shorten >=-3mm*\LP@scale]%
        \xtikzpath{#1}{#2}{\LP@fw@dir/\LP@fw@length};%
    \end{pgfonlayer}%
  };%
  \begin{puzzlebackground}%
    \node[fill=\LP@c@bg@fw,font=\LP@fontsize] at (#1.5,#2.5) {#3};%
  \end{puzzlebackground}%
}%
%
\newcommand*\fourwindssetup[1]%
{%
  \setkeys{fourwinds.sty}{#1}%
}%
%    \end{macrocode}
% \begin{environment}{fourwinds}
%    \begin{macrocode}
\newenvironment{fourwinds}[1][]%
{%
  \setkeys{fourwinds}{#1}%
  \LP@set@package{fourwinds}%
  \LP@set@env@prefix{LP@FW}%
  \setcounter{LP@rows}{\LP@FW@rows}%
  \setcounter{LP@columns}{\LP@FW@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@FW@width}%
    \ifthenelse{\equal{\LP@FW@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@FW@titleindent}\parbox{\LP@FW@titlewidth}{\strut\LP@titleformat\LP@FW@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@FW@scale]%
      \LP@drawbackground{1}{1}{\LP@FW@columns}{\LP@FW@rows}{\LP@FW@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@FW@columns}{\LP@FW@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@FW@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% hakyuu environment and options
%
\newcommand*\LP@HY@init@prefix{LP@HY}%
\newcommand*\LP@HY@init@package{hakyuu}%
%
\LP@define@key{\LP@HY@init@prefix}{\LP@HY@init@package}{rows}{5}%
\LP@define@key{\LP@HY@init@prefix}{\LP@HY@init@package}{columns}{5}%
\LP@define@key{\LP@HY@init@prefix}{\LP@HY@init@package}{scale}{1}%
\LP@define@key{\LP@HY@init@prefix}{\LP@HY@init@package}{counterstyle}{none}%
\LP@define@key{\LP@HY@init@prefix}{\LP@HY@init@package}{bgcolor}{}%
\LP@define@key{\LP@HY@init@prefix}{\LP@HY@init@package}{width}{5.1cm}%
\LP@define@key{\LP@HY@init@prefix}{\LP@HY@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@HY@init@prefix}{\LP@HY@init@package}{title}{}%
\LP@define@key{\LP@HY@init@prefix}{\LP@HY@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@HY@init@prefix}{\LP@HY@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@HY@init@prefix}{\LP@HY@init@package}{Large}%
%
\let\hakyuucell\setcell%
%
\newcommand*\hakyuusetup[1]%
{%
  \setkeys{hakyuu.sty}{#1}%
}%
%    \end{macrocode}
% \begin{environment}{hakyuu}
%    \begin{macrocode}
\newenvironment{hakyuu}[1][]%
{%
  \setkeys{hakyuu}{#1}%
  \LP@set@package{hakyuu}%
  \LP@set@env@prefix{LP@HY}%
  \setcounter{LP@rows}{\LP@HY@rows}%
  \setcounter{LP@columns}{\LP@HY@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@HY@width}%
    \ifthenelse{\equal{\LP@HY@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@HY@titleindent}\parbox{\LP@HY@titlewidth}{\strut\LP@titleformat\LP@HY@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@HY@scale]%
      \LP@drawbackground{1}{1}{\LP@HY@columns}{\LP@HY@rows}{\LP@HY@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@HY@columns}{\LP@HY@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@HY@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% hitori environment and options
%
\newcommand*\LP@HT@init@prefix{LP@HT}%
\newcommand*\LP@HT@init@package{hitori}%
%
\LP@define@key{\LP@HT@init@prefix}{\LP@HT@init@package}{rows}{5}%
\LP@define@key{\LP@HT@init@prefix}{\LP@HT@init@package}{columns}{5}%
\LP@define@key{\LP@HT@init@prefix}{\LP@HT@init@package}{scale}{1}%
\LP@define@key{\LP@HT@init@prefix}{\LP@HT@init@package}{counterstyle}{none}%
\LP@define@key{\LP@HT@init@prefix}{\LP@HT@init@package}{bgcolor}{}%
\LP@define@key{\LP@HT@init@prefix}{\LP@HT@init@package}{width}{5.1cm}%
\LP@define@key{\LP@HT@init@prefix}{\LP@HT@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@HT@init@prefix}{\LP@HT@init@package}{title}{}%
\LP@define@key{\LP@HT@init@prefix}{\LP@HT@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@HT@init@prefix}{\LP@HT@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@HT@init@prefix}{\LP@HT@init@package}{Large}%
%
\let\hitoricell\setcell%
%
\newcommand*\hitorisetup[1]%
{%
  \setkeys{hitori.sty}{#1}%
}%
%    \end{macrocode}
% \begin{environment}{hitori}
%    \begin{macrocode}
\newenvironment{hitori}[1][]%
{%
  \setkeys{hitori}{#1}%
  \LP@set@package{hitori}%
  \LP@set@env@prefix{LP@HT}%
  \setcounter{LP@rows}{\LP@HT@rows}%
  \setcounter{LP@columns}{\LP@HT@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@HT@width}%
    \ifthenelse{\equal{\LP@HT@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@HT@titleindent}\parbox{\LP@HT@titlewidth}{\strut\LP@titleformat\LP@HT@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@HT@scale]%
      \LP@drawbackground{1}{1}{\LP@HT@columns}{\LP@HT@rows}{\LP@HT@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@HT@columns}{\LP@HT@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@HT@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% kakuro environment and options
%
\newcommand*\LP@KKR@init@prefix{LP@KKR}%
\newcommand*\LP@KKR@init@package{kakuro}%
%
\LP@define@key{\LP@KKR@init@prefix}{\LP@KKR@init@package}{rows}{5}%
\LP@define@key{\LP@KKR@init@prefix}{\LP@KKR@init@package}{columns}{5}%
\LP@define@key{\LP@KKR@init@prefix}{\LP@KKR@init@package}{scale}{1}%
\LP@define@key{\LP@KKR@init@prefix}{\LP@KKR@init@package}{counterstyle}{none}%
\LP@define@key{\LP@KKR@init@prefix}{\LP@KKR@init@package}{bgcolor}{}%
\LP@define@key{\LP@KKR@init@prefix}{\LP@KKR@init@package}{color}{green}%
\LP@define@key{\LP@KKR@init@prefix}{\LP@KKR@init@package}{width}{5.1cm}%
\LP@define@key{\LP@KKR@init@prefix}{\LP@KKR@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@KKR@init@prefix}{\LP@KKR@init@package}{title}{}%
\LP@define@key{\LP@KKR@init@prefix}{\LP@KKR@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@KKR@init@prefix}{\LP@KKR@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@KKR@init@prefix}{\LP@KKR@init@package}{Large}%
%
\newif\ifLP@KKR@solution\LP@KKR@solutionfalse%
%
\define@choicekey*{kakuro.sty}{solution}[\LP@KKR@solution\nr]{true,false}[true]%
{%
  \ifcase\nr\relax%
    \renewcommand*\LP@KKR@solution{true}%
    \LP@KKR@solutiontrue%
  \or%
    \renewcommand*\LP@KKR@solution{false}%
    \LP@KKR@solutionfalse%
  \fi%
}%
%
\define@choicekey*{kakuro}{solution}[\LP@KKR@solution\nr]{true,false}[true]%
{%
  \ifcase\nr\relax%
    \renewcommand*\LP@KKR@solution{true}%
    \LP@KKR@solutiontrue%
  \or%
    \renewcommand*\LP@KKR@solution{false}%
    \LP@KKR@solutionfalse%
  \fi%
}%
%
\let\kakurocell\setcell%
%
\newcommand*\kakurosetup[1]%
{%
  \setkeys{kakuro.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\LP@KKR@print@element}
% For the \env{kakuro} environment, we need to typeset numbers and special
% Kakuro cells (\cs{KKR}).
%
% \cs{LP@KKR@print@element}\marg{element}
%    \begin{macrocode}
\def\LP@KKR@print@element#1%
{%
%    \end{macrocode}
% First, we test if \marg{element} is a number and typeset \marg{element}
% into the grid cell, if we are in solution mode. Otherwise, we execute the \cs{KKR} command.
%    \begin{macrocode}
  \if!\ifnum9<1#1!\else_\fi%
    \ifLP@KKR@solution%
      \setcell{\arabic{LP@counti}}{\arabic{LP@countii}}{#1}%
    \else%
    \fi%
  \else%
    #1%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\kakurorow}
% For the \env{kakuro} environment, we need special row and column commands, which
% can also handle the \cs{KKR} commands.
%    \begin{macrocode}
\newcommand*\kakurorow[2]%
{%
  \setcounter{LP@counti}{1}%
  \setcounter{LP@countii}{#1}%
  \foreach \LP@element in {#2}%
  {%
    \LP@KKR@print@element{\LP@element}%
    \stepcounter{LP@counti}%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\kakurocolumn}
%    \begin{macrocode}
\newcommand*\kakurocolumn[2]%
{%
  \setcounter{LP@counti}{#1}%
  \setcounter{LP@countii}{1}%
  \foreach \LP@element in {#2}%
  {%
    \LP@KKR@print@element{\LP@element}%
    \stepcounter{LP@countii}%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\KKR}
% For the \env{kakuro} environment, we need to draw complex kakuro cells. They consist of
% a diagonally divided cell with the sums of the cells below and right of the current cell.
% They also have a special background color.
%
% \cs{KKR}\marg{vertical sum}\marg{horizontal sum}
%    \begin{macrocode}
\newcommand*\KKR[2]%
{%
%    \end{macrocode}
% First of all, we copy |scale|, |bgcolor| and |color|.
%    \begin{macrocode}
  \LP@set@LP@scale{\LP@env@prefix}%
  \LP@set@LP@bgcolor{\LP@env@prefix}%
  \LP@set@LP@color{\LP@env@prefix}%
%    \end{macrocode}
% If |bgcolor| is undefined, we assume |white|.
%    \begin{macrocode}
  \ifthenelse{\equal{\LP@bgcolor}{}}%
  {\gdef\LP@sr@bgcolor{white}}%
  {\gdef\LP@sr@bgcolor{\LP@bgcolor}}%
%    \end{macrocode}
% To get unique node names, we step our |unique| counter.
%    \begin{macrocode}
  \stepcounter{LP@counter@unique}%
%    \end{macrocode}
% In a first step, we draw a rectangular helper node in |bgcolor| color on the \layer{LPdump} layer.
%    \begin{macrocode}
  \begin{pgfonlayer}{LPdump}%
    \node [shape=rectangle,inner sep=0pt] (A_\theLP@counter@unique)%
      at (\arabic{LP@counti}\LP@Pfive,\arabic{LP@countii}\LP@Pfive)%
      {\tikz\draw[scale=\LP@scale,color=\LP@sr@bgcolor]%
        (0.08,0.1) rectangle (0.92,0.9);};%
  \end{pgfonlayer}%
%    \end{macrocode}
% In the second step, we fill the cell with |color| color and draw a diagonal line.
%    \begin{macrocode}
  \begin{puzzlebackground}%
    \fill[color=\LP@color]%
      (\arabic{LP@counti},\arabic{LP@countii}) rectangle ++(1,1);%
    \draw[line width=\LP@normallines]%
      (\arabic{LP@counti},\arabic{LP@countii}) -- ++(0,1) -- ++(1,-1);%
  \end{puzzlebackground}%
%    \end{macrocode}
% Finally, we use the corners of the helper node to place the sums.
%    \begin{macrocode}
  \node [shape=rectangle,inner sep=0pt,anchor=south west,%
         scale=\LP@scale,font=\small]%
           at (A_\theLP@counter@unique.south west) {#1};%
  \node [shape=rectangle,inner sep=0pt,anchor=north east,%
         scale=\LP@scale,font=\small]%
           at (A_\theLP@counter@unique.north east) {#2};%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Black}
% Sometimes, we need black cells.
%    \begin{macrocode}
\newcommand*\Black%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \begin{puzzlebackground}%
    \fill[color=black]%
      (\arabic{LP@counti},\arabic{LP@countii}) rectangle ++(1,1);%
  \end{puzzlebackground}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{kakuro}
%    \begin{macrocode}
\newenvironment{kakuro}[1][]%
{%
  \setkeys{kakuro}{#1}%
  \LP@set@package{kakuro}%
  \LP@set@env@prefix{LP@KKR}%
  \setcounter{LP@rows}{\LP@KKR@rows}%
  \setcounter{LP@columns}{\LP@KKR@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@KKR@width}%
    \ifthenelse{\equal{\LP@KKR@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@KKR@titleindent}\parbox{\LP@KKR@titlewidth}{\strut\LP@titleformat\LP@KKR@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@KKR@scale]%
      \LP@drawbackground{1}{1}{\LP@KKR@columns}{\LP@KKR@rows}{\LP@KKR@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@KKR@columns}{\LP@KKR@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@KKR@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% kendoku environment and options
%
\newcommand*\LP@KD@init@prefix{LP@KD}%
\newcommand*\LP@KD@init@package{kendoku}%
%
\LP@define@key{\LP@KD@init@prefix}{\LP@KD@init@package}{rows}{5}%
\LP@define@key{\LP@KD@init@prefix}{\LP@KD@init@package}{columns}{5}%
\LP@define@key{\LP@KD@init@prefix}{\LP@KD@init@package}{scale}{1}%
\LP@define@key{\LP@KD@init@prefix}{\LP@KD@init@package}{counterstyle}{none}%
\LP@define@key{\LP@KD@init@prefix}{\LP@KD@init@package}{bgcolor}{}%
\LP@define@key{\LP@KD@init@prefix}{\LP@KD@init@package}{width}{5.1cm}%
\LP@define@key{\LP@KD@init@prefix}{\LP@KD@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@KD@init@prefix}{\LP@KD@init@package}{title}{}%
\LP@define@key{\LP@KD@init@prefix}{\LP@KD@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@KD@init@prefix}{\LP@KD@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@KD@init@prefix}{\LP@KD@init@package}{Large}%
%
\let\kendokucell\setcell%
%
\newcommand*\kendokusetup[1]%
{%
  \setkeys{kendoku.sty}{#1}%
}%
%    \end{macrocode}
% \begin{environment}{kendoku}
%    \begin{macrocode}
\newenvironment{kendoku}[1][]%
{%
  \setkeys{kendoku}{#1}%
  \LP@set@package{kendoku}%
  \LP@set@env@prefix{LP@KD}%
  \setcounter{LP@rows}{\LP@KD@rows}%
  \setcounter{LP@columns}{\LP@KD@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@KD@width}%
    \ifthenelse{\equal{\LP@KD@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@KD@titleindent}\parbox{\LP@KD@titlewidth}{\strut\LP@titleformat\LP@KD@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@KD@scale]%
      \LP@drawbackground{1}{1}{\LP@KD@columns}{\LP@KD@rows}{\LP@KD@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@KD@columns}{\LP@KD@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@KD@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% killersudoku environment and options
%
\newcommand*\LP@KSDK@init@prefix{LP@KSDK}%
\newcommand*\LP@KSDK@init@package{killersudoku}%
%
\LP@define@key{\LP@KSDK@init@prefix}{\LP@KSDK@init@package}{rows}{5}%
\LP@define@key{\LP@KSDK@init@prefix}{\LP@KSDK@init@package}{columns}{5}%
\LP@define@key{\LP@KSDK@init@prefix}{\LP@KSDK@init@package}{scale}{1}%
\LP@define@key{\LP@KSDK@init@prefix}{\LP@KSDK@init@package}{counterstyle}{none}%
\LP@define@key{\LP@KSDK@init@prefix}{\LP@KSDK@init@package}{bgcolor}{}%
\LP@define@key{\LP@KSDK@init@prefix}{\LP@KSDK@init@package}{width}{5.1cm}%
\LP@define@key{\LP@KSDK@init@prefix}{\LP@KSDK@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@KSDK@init@prefix}{\LP@KSDK@init@package}{title}{}%
\LP@define@key{\LP@KSDK@init@prefix}{\LP@KSDK@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@KSDK@init@prefix}{\LP@KSDK@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@KSDK@init@prefix}{\LP@KSDK@init@package}{Large}%
%
\let\killersudokucell\setcell%
%
\newcommand*\killersudokusetup[1]%
{%
  \setkeys{killersudoku.sty}{#1}%
}%
%    \end{macrocode}
% \begin{environment}{killersudoku}
%    \begin{macrocode}
\newenvironment{killersudoku}[1][]%
{%
  \setkeys{killersudoku}{#1}%
  \LP@set@package{killersudoku}%
  \LP@set@env@prefix{LP@KSDK}%
  \setcounter{LP@rows}{\LP@KSDK@rows}%
  \setcounter{LP@columns}{\LP@KSDK@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@KSDK@width}%
    \ifthenelse{\equal{\LP@KSDK@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@KSDK@titleindent}\parbox{\LP@KSDK@titlewidth}{\strut\LP@titleformat\LP@KSDK@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@KSDK@scale]%
      \LP@drawbackground{1}{1}{\LP@KSDK@columns}{\LP@KSDK@rows}{\LP@KSDK@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@KSDK@columns}{\LP@KSDK@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@KSDK@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% laserbeam environment and options
%
\newcommand*\LP@LB@init@prefix{LP@LB}%
\newcommand*\LP@LB@init@package{laserbeam}%
%
\LP@define@key{\LP@LB@init@prefix}{\LP@LB@init@package}{rows}{5}%
\LP@define@key{\LP@LB@init@prefix}{\LP@LB@init@package}{columns}{5}%
\LP@define@key{\LP@LB@init@prefix}{\LP@LB@init@package}{scale}{1}%
\LP@define@key{\LP@LB@init@prefix}{\LP@LB@init@package}{counterstyle}{none}%
\LP@define@key{\LP@LB@init@prefix}{\LP@LB@init@package}{bgcolor}{}%
\LP@define@key{\LP@LB@init@prefix}{\LP@LB@init@package}{width}{6.5cm}%
\LP@define@key{\LP@LB@init@prefix}{\LP@LB@init@package}{cvoffset}{-38pt}%
\LP@define@key{\LP@LB@init@prefix}{\LP@LB@init@package}{title}{}%
\LP@define@key{\LP@LB@init@prefix}{\LP@LB@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@LB@init@prefix}{\LP@LB@init@package}{titlewidth}{6.5cm}%
\LP@define@choicekey@fontsize{\LP@LB@init@prefix}{\LP@LB@init@package}{Large}%
%
\let\laserH\LP@toprow%
\let\laserV\LP@leftcolumn%
\let\mirrorH\LP@bottomrow@edge%
\let\mirrorV\LP@rightcolumn@edge%
%
\newcommand*\laser[2][red]%
{%
%   avoid little laser peaks outside grid
  \clip (1,1) rectangle (\arabic{LP@columns},\arabic{LP@rows});%
  \framearea{#1}{#2}%
}%
%
\newcommand*\laserbeamsetup[1]%
{%
  \setkeys{laserbeam.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\placecross}
% Place a cross in the bottom left corner of the grid cell.
%
% \cs{placecross}\marg{column}\marg{row}
%    \begin{macrocode}
\newcommand*\placecross[2]%
{%
  \LP@G@setcellcontent{#1}{#2}{\LP@Cross}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\placemirror}
% Place a mirror in the bottom left corner of the grid cell.
%
% \cs{placemirror}\marg{column}\marg{row}
%    \begin{macrocode}
\newcommand*\placemirror[3]%
{%
  \LP@G@setcellcontent{#1}{#2}{\LP@Mirror{#3}}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\placearrow}
% Place an arrow in the bottom left corner of the grid cell.
% \marg{direction} may be: |RightUp|, |LeftUp|, |LeftDown| or |RightDown|
%
% \cs{placearrow}\marg{column}\marg{row}\marg{direction}
%    \begin{macrocode}
\newcommand*\placearrow[3]%
{%
  \LP@G@setcellcontent{#1}{#2}{\LP@Arrow{#3}}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@Arrow}
% We define a Ti{\itshape k}Z picture for an arrow in four directions:
% |RightUp|, |LeftUp|, |LeftDown| or |RightDown|
%    \begin{macrocode}
\newcommand*\LP@Arrow[1]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \def\LP@rotate{45}%
  \ifthenelse{\equal{#1}{LeftUp}}{\def\LP@rotate{135}}{}%
  \ifthenelse{\equal{#1}{LeftDown}}{\def\LP@rotate{225}}{}%
  \ifthenelse{\equal{#1}{RightDown}}{\def\LP@rotate{315}}{}%
%    \end{macrocode}
% We define the line width of the arrow base on |scale|. Line widths are absolut and not
% influenced by a |scale| factor of the picture.
%    \begin{macrocode}
  \pgfmathsetmacro{\LPlinewidth}{3pt*\LP@scale}%
  \tikz\draw[->,line width=\LPlinewidth,%
             rotate=\LP@rotate,scale=\LP@scale]%
              (0.1,.5) -- (0.9,.5);%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@Cross}
% We define a Ti{\itshape k}Z picture of a cross.
%    \begin{macrocode}
\newcommand*\LP@Cross%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \begin{tikzpicture}%
%    \end{macrocode}
% We ensure that the cross is on top of all elements on the \layer{main} layer.
%    \begin{macrocode}
    \begin{pgfonlayer}{LPforeground}%
      \pgfmathsetmacro{\LPlinewidth}{3pt*\LP@scale}%
%    \end{macrocode}
% For drawing the cross we defined a line width. Now we can draw the cross with the
% predefined color |LP@c@cross|.
%    \begin{macrocode}
      \draw[line width=\LPlinewidth,scale=\LP@scale,color=LP@c@cross]%
        (.35,.35) -- (0.65,.65) -- (.5,.5) -- (.65,.35)-- (.35,.65);%
    \end{pgfonlayer}%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@Mirror}
% We define a Ti{\itshape k}Z picture for a mirror.
%
% \cs{LP@Mirror}\marg{direction}
%    \begin{macrocode}
\newcommand*\LP@Mirror[1]%
{%
%    \end{macrocode}
% Based on \marg{direction}, we define the angle of the mirror.
%    \begin{macrocode}
  \def\LP@rotate{0}%
  \ifthenelse{\equal{#1}{V}}{\def\LP@rotate{90}}{}%
  \LP@set@LP@scale{\LP@env@prefix}%
  \begin{tikzpicture}%
%    \end{macrocode}
% Mirrors should be on to of everything, therefore we draw them on the
% \layer{LPforegroundtwo} layer and use the predefined color |LP@c@mirror|.
%    \begin{macrocode}
    \begin{pgfonlayer}{LPforegroundtwo}%
      \pgfmathsetmacro{\LPlinewidth}{3pt*\LP@scale}%
      \draw[line width=\LPlinewidth,scale=\LP@scale,%
            color=LP@c@mirror,rotate=\LP@rotate]%
             (.35,.5) -- (0.65,.5);%
    \end{pgfonlayer}%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{laserbeam}
%    \begin{macrocode}
\newenvironment{laserbeam}[1][]%
{%
  \setkeys{laserbeam}{#1}%
  \LP@set@package{laserbeam}%
  \LP@set@env@prefix{LP@LB}%
  \setcounter{LP@rows}{\LP@LB@rows}%
  \setcounter{LP@columns}{\LP@LB@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@LB@width}%
    \ifthenelse{\equal{\LP@LB@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@LB@titleindent}\parbox{\LP@LB@titlewidth}{\strut\LP@titleformat\LP@LB@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@LB@scale]%
      \LP@drawbackground{1}{1}{\LP@LB@columns}{\LP@LB@rows}{\LP@LB@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@LB@columns}{\LP@LB@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@LB@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% lpsudoku environment and options
%
\newcommand*\LP@SDK@init@prefix{LP@SDK}%
\newcommand*\LP@SDK@init@package{lpsudoku}%
%
\LP@define@key{\LP@SDK@init@prefix}{\LP@SDK@init@package}{rows}{9}%
\LP@define@key{\LP@SDK@init@prefix}{\LP@SDK@init@package}{columns}{9}%
\LP@define@key{\LP@SDK@init@prefix}{\LP@SDK@init@package}{scale}{1}%
\LP@define@key{\LP@SDK@init@prefix}{\LP@SDK@init@package}{counterstyle}{none}%
\LP@define@key{\LP@SDK@init@prefix}{\LP@SDK@init@package}{bgcolor}{}%
\LP@define@key{\LP@SDK@init@prefix}{\LP@SDK@init@package}{width}{9.1cm}%
\LP@define@key{\LP@SDK@init@prefix}{\LP@SDK@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@SDK@init@prefix}{\LP@SDK@init@package}{title}{}%
\LP@define@key{\LP@SDK@init@prefix}{\LP@SDK@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@SDK@init@prefix}{\LP@SDK@init@package}{titlewidth}{9.1cm}%
\LP@define@choicekey@fontsize{\LP@SDK@init@prefix}{\LP@SDK@init@package}{Large}%
%
\let\lpsudokucell\setcell%
%
\newcommand*\lpsudokusetup[1]%
{%
  \setkeys{lpsudoku.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\LP@drawsudokugrid}
% For the \env{lpsudoku} and \env{skyscrapers} environments, we need to add the typical
% thick Sudoku lines to the standard grid.
%    \begin{macrocode}
\newcommand*\LP@drawsudokugrid%
{%
  \draw[line width=\LP@thicklines,draw opacity=\LP@draw@opacity]%
       (1,1) -- (1,10);%
  \draw[line width=\LP@thicklines,draw opacity=\LP@draw@opacity]%
       (4,1) -- (4,10);%
  \draw[line width=\LP@thicklines,draw opacity=\LP@draw@opacity]%
       (7,1) -- (7,10);%
  \draw[line width=\LP@thicklines,draw opacity=\LP@draw@opacity]%
       (10,1) -- (10,10);%
  \draw[line width=\LP@thicklines,draw opacity=\LP@draw@opacity]%
       (1,1) -- (10,1);%
  \draw[line width=\LP@thicklines,draw opacity=\LP@draw@opacity]%
       (1,4) -- (10,4);%
  \draw[line width=\LP@thicklines,draw opacity=\LP@draw@opacity]%
       (1,7) -- (10,7);%
  \draw[line width=\LP@thicklines,draw opacity=\LP@draw@opacity]%
       (1,10) -- (10,10);%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@magnetsgrid}
% For the \env{magnets} environment, we need to add some lines to the
% standard grid.
%    \begin{macrocode}
\newcommand*\LP@magnetsgrid%
{%
%    \end{macrocode}
% First, we copy the values of |fontsize|, |columns| and |rows| from
% the environment we are in at the moment. Then, we step |columns| and
% |rows| to get the upper right grid coordinate.
%    \begin{macrocode}
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \LP@set@LP@columns{\LP@env@prefix}%
  \LP@set@LP@rows{\LP@env@prefix}%
  \setcounter{LP@counti}{\LP@columns}% max column
  \setcounter{LP@countii}{\LP@rows}% max row
  \stepcounter{LP@counti}%
  \stepcounter{LP@countii}%
%    \end{macrocode}
% Now, we can draw the additional lines and the |+| and |-| signs.
%    \begin{macrocode}
  \draw[step=1cm,line width=\LP@normallines]%
       (-1,1) grid (1,\arabic{LP@countii});%
  \draw[step=1cm,line width=\LP@normallines]%
       (1,\arabic{LP@countii}) grid ++(\LP@columns,2);%
  \draw[line width=\LP@normallines]%
       (0,\arabic{LP@countii}) -- ++(0,1) -- ++(1,0);%
  \draw[line width=\LP@thicklines]%
       (-1,1) rectangle (1,\arabic{LP@countii});%
  \draw[line width=\LP@thicklines]%
       (1,\arabic{LP@countii}) rectangle ++(\LP@columns,2);%
  \draw[line width=\LP@thicklines]%
       (1,\arabic{LP@countii}) rectangle ++(-2,2);%
  \node[font=\LP@fontsize\bfseries] at (0.5,\arabic{LP@counti}.5)%
       {$-$};%
  \stepcounter{LP@counti}%
  \node[font=\LP@fontsize\bfseries] at (-0.5,\arabic{LP@counti}.5)%
       {$+$};%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{lpsudoku}
%    \begin{macrocode}
\newenvironment{lpsudoku}[1][]%
{%
  \setkeys{lpsudoku}{#1}%
  \LP@set@package{lpsudoku}%
  \LP@set@env@prefix{LP@SDK}%
  \setcounter{LP@rows}{\LP@SDK@rows}%
  \setcounter{LP@columns}{\LP@SDK@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@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}[LPpreset,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@SDK@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% magiclabyrinth environment and options
%
\newcommand*\LP@ML@init@prefix{LP@ML}%
\newcommand*\LP@ML@init@package{magiclabyrinth}%
%
\LP@define@key{\LP@ML@init@prefix}{\LP@ML@init@package}{rows}{5}%
\LP@define@key{\LP@ML@init@prefix}{\LP@ML@init@package}{columns}{5}%
\LP@define@key{\LP@ML@init@prefix}{\LP@ML@init@package}{scale}{1}%
\LP@define@key{\LP@ML@init@prefix}{\LP@ML@init@package}{counterstyle}{none}%
\LP@define@key{\LP@ML@init@prefix}{\LP@ML@init@package}{bgcolor}{}%
\LP@define@key{\LP@ML@init@prefix}{\LP@ML@init@package}{width}{5.1cm}%
\LP@define@key{\LP@ML@init@prefix}{\LP@ML@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@ML@init@prefix}{\LP@ML@init@package}{title}{}%
\LP@define@key{\LP@ML@init@prefix}{\LP@ML@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@ML@init@prefix}{\LP@ML@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@ML@init@prefix}{\LP@ML@init@package}{Large}%
%
\let\magiclabyrinthcell\setcell%
%
\newcommand*\magiclabyrinthsetup[1]%
{%
  \setkeys{magiclabyrinth.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\mlline}
%    \begin{macrocode}
\newcommand*\mlline[1]%
{%
  \draw[color=black, line width=\LP@thicklines] #1;%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MasyuW}
%    \begin{macrocode}
\newcommand*\MasyuW%
{%
  \begin{tikzpicture}[scale=0.7*\LP@scale]%
    \draw[color=black,fill=white] (0.5,0.5) circle (0.5cm);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{magiclabyrinth}
%    \begin{macrocode}
\newenvironment{magiclabyrinth}[1][]%
{%
  \setkeys{magiclabyrinth}{#1}%
  \LP@set@package{magiclabyrinth}%
  \LP@set@env@prefix{LP@ML}%
  \setcounter{LP@rows}{\LP@ML@rows}%
  \setcounter{LP@columns}{\LP@ML@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@ML@width}%
    \ifthenelse{\equal{\LP@ML@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@ML@titleindent}\parbox{\LP@ML@titlewidth}{\strut\LP@titleformat\LP@ML@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@ML@scale]%
      \LP@drawbackground{1}{1}{\LP@ML@columns}{\LP@ML@rows}{\LP@ML@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@ML@columns}{\LP@ML@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@ML@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% magnets environment and options
%
\newcommand*\LP@MN@init@prefix{LP@MN}%
\newcommand*\LP@MN@init@package{magnets}%
%
\LP@define@key{\LP@MN@init@prefix}{\LP@MN@init@package}{rows}{6}%
\LP@define@key{\LP@MN@init@prefix}{\LP@MN@init@package}{columns}{6}%
\LP@define@key{\LP@MN@init@prefix}{\LP@MN@init@package}{scale}{1}%
\LP@define@key{\LP@MN@init@prefix}{\LP@MN@init@package}{counterstyle}{none}%
\LP@define@key{\LP@MN@init@prefix}{\LP@MN@init@package}{bgcolor}{}%
\LP@define@key{\LP@MN@init@prefix}{\LP@MN@init@package}{width}{8.1cm}%
\LP@define@key{\LP@MN@init@prefix}{\LP@MN@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@MN@init@prefix}{\LP@MN@init@package}{title}{}%
\LP@define@key{\LP@MN@init@prefix}{\LP@MN@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@MN@init@prefix}{\LP@MN@init@package}{titlewidth}{8.1cm}%
\LP@define@choicekey@fontsize{\LP@MN@init@prefix}{\LP@MN@init@package}{Large}%
%
\let\magnetscell\setcell%
%
\let\minusH\LP@toprow%
\let\minusV\LP@leftcolumn%
%
\newcommand*\plusV[1]%
{%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \setcounter{LP@counti}{1}%
  \foreach \LP@element in{#1}%
  {%
    \node at (-0.5,\arabic{LP@counti}\LP@Pfive){\LP@fontsize\LP@element};%
    \stepcounter{LP@counti}%
  };%
}%
%
\newcommand*\plusH[1]%
{%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \LP@set@LP@rows{\LP@env@prefix}%
  \setcounter{LP@counti}{1}%
  \setcounter{LP@countii}{\LP@rows}%
  \addtocounter{LP@countii}{2}%
  \foreach \LP@element in{#1}%
  {%
    \node at (\arabic{LP@counti}\LP@Pfive,\arabic{LP@countii}\LP@Pfive){\LP@fontsize\LP@element};%
    \stepcounter{LP@counti}%
  };%
}%
%
\newcommand*\magnetssetup[1]%
{%
  \setkeys{magnets.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\PMH}
%    \begin{macrocode}
\newcommand*\PMH[1]%
{%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \foreach \LP@fe@column/\LP@fe@row in {#1}%
  {%
    \setcounter{LP@counti}{\LP@fe@column}%
    \setcounter{LP@countii}{\LP@fe@row}%
    \draw[line width=\LP@thicklines,fill=white]%
      (\arabic{LP@counti},\arabic{LP@countii}) rectangle ++(2,1);%
    \node[font=\LP@fontsize\bfseries]%
      at (\arabic{LP@counti}.5,\arabic{LP@countii}.5) {$+$};%
    \stepcounter{LP@counti}%
    \node[font=\LP@fontsize\bfseries]%
      at (\arabic{LP@counti}.5,\arabic{LP@countii}.5) {$-$};%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MPH}
%    \begin{macrocode}
\newcommand*\MPH[1]%
{%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \foreach \LP@fe@column/\LP@fe@row in {#1}%
  {%
    \setcounter{LP@counti}{\LP@fe@column}%
    \setcounter{LP@countii}{\LP@fe@row}%
    \draw[line width=\LP@thicklines,fill=white]%
      (\arabic{LP@counti},\arabic{LP@countii}) rectangle ++(2,1);%
    \node[font=\LP@fontsize\bfseries]%
      at (\arabic{LP@counti}.5,\arabic{LP@countii}.5) {$-$};%
    \stepcounter{LP@counti}%
    \node[font=\LP@fontsize\bfseries]%
      at (\arabic{LP@counti}.5,\arabic{LP@countii}.5) {$+$};%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\PMV}
%    \begin{macrocode}
\newcommand*\PMV[1]%
{%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \foreach \LP@fe@column/\LP@fe@row in {#1}%
  {%
    \setcounter{LP@counti}{\LP@fe@column}%
    \setcounter{LP@countii}{\LP@fe@row}%
    \draw[line width=\LP@thicklines,fill=white]%
      (\arabic{LP@counti},\arabic{LP@countii}) rectangle ++(1,2);%
    \node[font=\LP@fontsize\bfseries]%
      at (\arabic{LP@counti}.5,\arabic{LP@countii}.5) {$+$};%
    \stepcounter{LP@countii}%
    \node[font=\LP@fontsize\bfseries]%
      at (\arabic{LP@counti}.5,\arabic{LP@countii}.5) {$-$};%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MPV}
%    \begin{macrocode}
\newcommand*\MPV[1]%
{%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \foreach \LP@fe@column/\LP@fe@row in {#1}%
  {%
    \setcounter{LP@counti}{\LP@fe@column}%
    \setcounter{LP@countii}{\LP@fe@row}%
    \draw[line width=\LP@thicklines,fill=white]%
      (\arabic{LP@counti},\arabic{LP@countii}) rectangle ++(1,2);%
    \node[font=\LP@fontsize\bfseries]%
      at (\arabic{LP@counti}.5,\arabic{LP@countii}.5) {$-$};%
    \stepcounter{LP@countii}%
    \node[font=\LP@fontsize\bfseries]%
      at (\arabic{LP@counti}.5,\arabic{LP@countii}.5) {$+$};%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\magnetsH}
%    \begin{macrocode}
\newcommand*\magnetsH[1]%
{%
  \foreach \LP@fe@column/\LP@fe@row in {#1}%
  {%
    \draw[line width=\LP@thicklines,fill=white]%
      (\LP@fe@column,\LP@fe@row) rectangle ++(2,1);%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\magnetsV}
%    \begin{macrocode}
\newcommand*\magnetsV[1]%
{%
  \foreach \LP@fe@column/\LP@fe@row in {#1}%
  {%
    \draw[line width=\LP@thicklines,fill=white]%
      (\LP@fe@column,\LP@fe@row) rectangle ++(1,2);%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{magnets}
%    \begin{macrocode}
\newenvironment{magnets}[1][]%
{%
  \setkeys{magnets}{#1}%
  \LP@set@package{magnets}%
  \LP@set@env@prefix{LP@MN}%
  \setcounter{LP@rows}{\LP@MN@rows}%
  \setcounter{LP@columns}{\LP@MN@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@MN@width}%
    \ifthenelse{\equal{\LP@MN@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@MN@titleindent}\parbox{\LP@MN@titlewidth}{\strut\LP@titleformat\LP@MN@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@MN@scale]%
      \LP@drawbackground{1}{1}{\LP@MN@columns}{\LP@MN@rows}{\LP@MN@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@MN@columns}{\LP@MN@rows}{1cm}%
      \LP@magnetsgrid%
      \framepuzzle%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@MN@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% masyu environment and options
%
\newcommand*\LP@MY@init@prefix{LP@MY}%
\newcommand*\LP@MY@init@package{masyu}%
%
\LP@define@key{\LP@MY@init@prefix}{\LP@MY@init@package}{rows}{5}%
\LP@define@key{\LP@MY@init@prefix}{\LP@MY@init@package}{columns}{5}%
\LP@define@key{\LP@MY@init@prefix}{\LP@MY@init@package}{scale}{1}%
\LP@define@key{\LP@MY@init@prefix}{\LP@MY@init@package}{counterstyle}{none}%
\LP@define@key{\LP@MY@init@prefix}{\LP@MY@init@package}{color}{green}%
\LP@define@key{\LP@MY@init@prefix}{\LP@MY@init@package}{bgcolor}{}%
\LP@define@key{\LP@MY@init@prefix}{\LP@MY@init@package}{width}{5.1cm}%
\LP@define@key{\LP@MY@init@prefix}{\LP@MY@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@MY@init@prefix}{\LP@MY@init@package}{title}{}%
\LP@define@key{\LP@MY@init@prefix}{\LP@MY@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@MY@init@prefix}{\LP@MY@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@MY@init@prefix}{\LP@MY@init@package}{Large}%
%
\let\masyucell\setcell%
%
\newcommand*\masyusetup[1]%
{%
  \setkeys{masyu.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\MasyuB}
%    \begin{macrocode}
\newcommand*\MasyuB%
{%
  \begin{tikzpicture}[scale=0.7*\LP@scale]%
    \fill[color=black] (0.5,0.5) circle (0.5cm);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\masyuline}
%    \begin{macrocode}
\newcommand*\masyuline[1]%
{%
  \LP@set@LP@color{\LP@env@prefix}%
  \begin{puzzleforeground}%
    \bgroup%
      \def\LP@rel@tikzpath{.5}%
      \draw[color=\LP@color, line width=\LP@thicklines] #1;%
    \egroup%
  \end{puzzleforeground}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{masyu}
%    \begin{macrocode}
\newenvironment{masyu}[1][]%
{%
  \setkeys{masyu}{#1}%
  \LP@set@package{masyu}%
  \LP@set@env@prefix{LP@MY}%
  \setcounter{LP@rows}{\LP@MY@rows}%
  \setcounter{LP@columns}{\LP@MY@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@MY@width}%
    \ifthenelse{\equal{\LP@MY@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@MY@titleindent}\parbox{\LP@MY@titlewidth}{\strut\LP@titleformat\LP@MY@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@MY@scale]%
      \LP@drawbackground{1}{1}{\LP@MY@columns}{\LP@MY@rows}{\LP@MY@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@MY@columns}{\LP@MY@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@MY@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% minesweeper environment and options
%
\newcommand*\LP@MS@init@prefix{LP@MS}%
\newcommand*\LP@MS@init@package{minesweeper}%
%
\LP@define@key{\LP@MS@init@prefix}{\LP@MS@init@package}{rows}{5}%
\LP@define@key{\LP@MS@init@prefix}{\LP@MS@init@package}{columns}{5}%
\LP@define@key{\LP@MS@init@prefix}{\LP@MS@init@package}{scale}{1}%
\LP@define@key{\LP@MS@init@prefix}{\LP@MS@init@package}{counterstyle}{none}%
\LP@define@key{\LP@MS@init@prefix}{\LP@MS@init@package}{bgcolor}{}%
\LP@define@key{\LP@MS@init@prefix}{\LP@MS@init@package}{width}{5.1cm}%
\LP@define@key{\LP@MS@init@prefix}{\LP@MS@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@MS@init@prefix}{\LP@MS@init@package}{title}{}%
\LP@define@key{\LP@MS@init@prefix}{\LP@MS@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@MS@init@prefix}{\LP@MS@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@MS@init@prefix}{\LP@MS@init@package}{Large}%
%
\let\minesweepercell\setcell%
%
\newcommand*\minesweepersetup[1]%
{%
  \setkeys{minesweeper.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\LP@Mine}
% We define a Ti{\itshape k}Z picture for a mine.
%    \begin{macrocode}
\newcommand*\LP@Mine%
{%
  \begin{tikzpicture}[scale=\LP@scale]%
%    \end{macrocode}
% We simply draw a shaded ball with four spikes.
%    \begin{macrocode}
    \fill[color=black] (.2,.5) -- (.5,.6) -- (.5,.4) -- cycle;%
    \fill[color=black] (.8,.5) -- (.5,.6) -- (.5,.4) -- cycle;%
    \fill[color=black] (.5,.8) -- (.4,.5) -- (.6,.5) -- cycle;%
    \fill[color=black] (.5,.2) -- (.4,.5) -- (.6,.5) -- cycle;%
    \shade[ball color=black] (.5,.5) circle (.225cm);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Mine}
% A user command for mines.
%    \begin{macrocode}
\let\Mine\LP@Mine%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{minesweeper}
%    \begin{macrocode}
\newenvironment{minesweeper}[1][]%
{%
  \setkeys{minesweeper}{#1}%
  \LP@set@package{minesweeper}%
  \LP@set@env@prefix{LP@MS}%
  \setcounter{LP@rows}{\LP@MS@rows}%
  \setcounter{LP@columns}{\LP@MS@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@MS@width}%
    \ifthenelse{\equal{\LP@MS@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@MS@titleindent}\parbox{\LP@MS@titlewidth}{\strut\LP@titleformat\LP@MS@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@MS@scale]%
      \LP@drawbackground{1}{1}{\LP@MS@columns}{\LP@MS@rows}{\LP@MS@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@MS@columns}{\LP@MS@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@MS@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% nonogram environment and options
%
\newcommand*\LP@NG@init@prefix{LP@NG}%
\newcommand*\LP@NG@init@package{nonogram}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{rows}{5}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{columns}{5}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{extracells}{5}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{helplines}{5}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{solution}{false}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{scale}{1}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{counterstyle}{none}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{bgcolor}{}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{color}{black}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{width}{5.1cm}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{title}{}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@NG@init@prefix}{\LP@NG@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@NG@init@prefix}{\LP@NG@init@package}{Large}%
%
%    \end{macrocode}
% \begin{macro}{\nonogramrow}
%    \begin{macrocode}
\newcommand*\nonogramrow[2]%
{%
  \foreach \LP@fe@column/\LP@fe@length in {#2}%
  {%
    \setcounter{LP@whiledo@i}{\LP@fe@length}%
    \setcounter{LP@countiii}{\LP@fe@column}%
    \whiledo{\value{LP@whiledo@i}>0}%
    {%
      \fillcell{\arabic{LP@countiii}}{#1}%
      \addtocounter{LP@countiii}{1}%
      \addtocounter{LP@whiledo@i}{-1}%
    }%    
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\nonogramcolumn}
%    \begin{macrocode}
\newcommand*\nonogramcolumn[2]%
{%
  \foreach \LP@fe@row/\LP@fe@length in {#2}%
  {%
    \setcounter{LP@whiledo@i}{\LP@fe@length}%
    \setcounter{LP@countiii}{\LP@fe@row}%
    \whiledo{\value{LP@whiledo@i}>0}%
    {%
      \fillcell{#1}{\arabic{LP@countiii}}%
      \addtocounter{LP@countiii}{1}%
      \addtocounter{LP@whiledo@i}{-1}%
    }%    
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\nonogramV}
%    \begin{macrocode}
\newcommand*\nonogramV[1]%
{%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \setcounter{LP@whiledo@i}{0}%
  \foreach \LP@line in {#1}%
  {%
    \setcounter{LP@countiii}{0}%
    \addtocounter{LP@whiledo@i}{1}%
    \foreach \LP@element in \LP@line%
    {%
      \ifthenelse{\value{LP@countiii}=0}%
      {%
        {\LP@fontsize\node at (0.5,\arabic{LP@whiledo@i}.5){\LP@element};}%
      }%
      {%
        \ifthenelse{\value{LP@countiii}=-1}%
        {%
          {\LP@fontsize\node at (-0.5,\arabic{LP@whiledo@i}.5){\LP@element};}%
        }%
        {%
          \addtocounter{LP@countiii}{1}%
          {\LP@fontsize\node at%
            (\arabic{LP@countiii}.5,\arabic{LP@whiledo@i}.5){\LP@element};}%
          \addtocounter{LP@countiii}{-1}%
        }%
      }%
      \addtocounter{LP@countiii}{-1}%
    }%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\nonogramH}
%    \begin{macrocode}
\newcommand*\nonogramH[1]%
{%
  \setcounter{LP@whiledo@i}{0}%
  \foreach \LP@line in {#1}%
  {%
    \setcounter{LP@countiii}{\LP@rows}%
    \addtocounter{LP@countiii}{1}%
    \addtocounter{LP@whiledo@i}{1}%
    \foreach \LP@element in \LP@line%
    {%
      {\LP@fontsize\node at%
        (\arabic{LP@whiledo@i}.5,\arabic{LP@countiii}.5){\LP@element};}%
      \addtocounter{LP@countiii}{1}%
    }%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@nonogramgrid}
%    \begin{macrocode}
\newcommand*\LP@nonogramgrid%
{%
  \LP@set@LP@columns{\LP@env@prefix}%
  \LP@set@LP@rows{\LP@env@prefix}%
  \setcounter{LP@counti}{\LP@columns}% max column
  \setcounter{LP@countii}{\LP@rows}% max row
  \setcounter{LP@countiii}{\LP@NG@extracells}%
  \stepcounter{LP@counti}%
  \stepcounter{LP@countii}%
  \addtocounter{LP@countiii}{-1}%
  \setcounter{LP@whiledo@i}{1}%
  \setcounter{LP@whiledo@ii}{\LP@NG@extracells}%
  \addtocounter{LP@whiledo@ii}{\arabic{LP@countii}}%
  \setcounter{LP@countiii}{\arabic{LP@countii}}%
  \addtocounter{LP@countiii}{\LP@NG@extracells}%
  \addtocounter{LP@counti}{1}%
  \whiledo{\value{LP@whiledo@i}<\value{LP@counti}}%
  {%
    \draw[line width=\LP@normallines]%
      (\arabic{LP@whiledo@i},1) --%
      (\arabic{LP@whiledo@i},\arabic{LP@countiii});%
    \addtocounter{LP@whiledo@i}{1}%
  }%
  \addtocounter{LP@counti}{-1}%
  \setcounter{LP@whiledo@i}{1}%
  \setcounter{LP@whiledo@ii}{-\LP@NG@extracells}%
  \addtocounter{LP@whiledo@ii}{1}%
  \addtocounter{LP@countii}{1}%
  \whiledo{\value{LP@whiledo@i}<\value{LP@countii}}%
  {%
    \draw[line width=\LP@normallines]%
      (\arabic{LP@whiledo@ii},\arabic{LP@whiledo@i}) --%
      (\arabic{LP@counti},\arabic{LP@whiledo@i});%
    \addtocounter{LP@whiledo@i}{1}%
  }%
  \addtocounter{LP@countii}{-1}%
  \setcounter{LP@countiii}{\LP@NG@helplines}%
  \ifthenelse{\arabic{LP@countiii}>0}%
  {%
    \setcounter{LP@whiledo@i}{1}%
    \addtocounter{LP@whiledo@i}{\LP@NG@helplines}%
    \setcounter{LP@whiledo@ii}{\LP@NG@extracells}%
    \addtocounter{LP@whiledo@ii}{\arabic{LP@countii}}%
    \setcounter{LP@countiii}{\arabic{LP@countii}}%
    \addtocounter{LP@countiii}{\LP@NG@extracells}%
    \whiledo{\value{LP@whiledo@i}<\value{LP@counti}}%
    {%
      \draw[line width=\LP@thicklines]%
        (\arabic{LP@whiledo@i},1) --%
        (\arabic{LP@whiledo@i},\arabic{LP@countiii});%
      \addtocounter{LP@whiledo@i}{\LP@NG@helplines}%
    }%
    \draw[line width=\LP@thicklines] (1,1) -- (1,\arabic{LP@countiii});%
    \draw[line width=\LP@thicklines]%
    (\arabic{LP@counti},1) --%
    (\arabic{LP@counti},\arabic{LP@countiii});%
    \setcounter{LP@whiledo@i}{1}%
    \addtocounter{LP@whiledo@i}{\LP@NG@helplines}%
    \setcounter{LP@whiledo@ii}{-\LP@NG@extracells}%
    \addtocounter{LP@whiledo@ii}{1}%
    \whiledo{\value{LP@whiledo@i}<\value{LP@countii}}%
    {%
      \draw[line width=\LP@thicklines]%
        (\arabic{LP@whiledo@ii},\arabic{LP@whiledo@i}) --%
        (\arabic{LP@counti},\arabic{LP@whiledo@i});%
      \addtocounter{LP@whiledo@i}{\LP@NG@helplines}%
    }%
    \draw[line width=\LP@thicklines]%
      (\arabic{LP@whiledo@ii},1) -- (\arabic{LP@counti},1);%
    \draw[line width=\LP@thicklines]%
      (\arabic{LP@whiledo@ii},\arabic{LP@countii}) --%
      (\arabic{LP@counti},\arabic{LP@countii});%
  }%
  {}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\nonogramsetup}
%    \begin{macrocode}
\newcommand*\nonogramsetup[1]%
{%
  \setkeys{nonogram.sty}{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{nonogram}
%    \begin{macrocode}
\newenvironment{nonogram}[1][]%
{%
  \setkeys{nonogram}{#1}%
  \LP@set@package{nonogram}%
  \LP@set@env@prefix{LP@NG}%
  \setcounter{LP@rows}{\LP@NG@rows}%
  \setcounter{LP@columns}{\LP@NG@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@NG@width}%
    \ifthenelse{\equal{\LP@NG@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@NG@titleindent}\parbox{\LP@NG@titlewidth}{\strut\LP@titleformat\LP@NG@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@NG@scale]%
      \LP@drawbackground{1}{1}{\LP@NG@columns}{\LP@NG@rows}{\LP@NG@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@NG@columns}{\LP@NG@rows}{1cm}%
      \framepuzzle%
      \ifthenelse{\equal{\LP@NG@solution}{false}}%
      {%
        \LP@nonogramgrid%
      }%
      {}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@NG@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% numberlink environment and options
%
\newcommand*\LP@NL@init@prefix{LP@NL}%
\newcommand*\LP@NL@init@package{numberlink}%
%
\LP@define@key{\LP@NL@init@prefix}{\LP@NL@init@package}{rows}{5}%
\LP@define@key{\LP@NL@init@prefix}{\LP@NL@init@package}{columns}{5}%
\LP@define@key{\LP@NL@init@prefix}{\LP@NL@init@package}{scale}{1}%
\LP@define@key{\LP@NL@init@prefix}{\LP@NL@init@package}{counterstyle}{none}%
\LP@define@key{\LP@NL@init@prefix}{\LP@NL@init@package}{bgcolor}{}%
\LP@define@key{\LP@NL@init@prefix}{\LP@NL@init@package}{color}{red}%
\LP@define@key{\LP@NL@init@prefix}{\LP@NL@init@package}{width}{5.1cm}%
\LP@define@key{\LP@NL@init@prefix}{\LP@NL@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@NL@init@prefix}{\LP@NL@init@package}{title}{}%
\LP@define@key{\LP@NL@init@prefix}{\LP@NL@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@NL@init@prefix}{\LP@NL@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@NL@init@prefix}{\LP@NL@init@package}{Large}%
%
\newcommand*\numberlinkcell[3]%
{%
  \fourwindscell{#1}{#2}{#3}{}%
}%
%
%
\newcommand*\numberlinksetup[1]%
{%
  \setkeys{numberlink.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\link}
%    \begin{macrocode}
\newcommand*\link[2][]%
{%
  \LP@set@LP@color{\LP@env@prefix}%
  \bgroup%
    \def\LP@rel@tikzpath{.5}%
    \LP@Line[color=\LP@color,#1]{#2}%
  \egroup%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{numberlink}
%    \begin{macrocode}
\newenvironment{numberlink}[1][]%
{%
  \setkeys{numberlink}{#1}%
  \LP@set@package{numberlink}%
  \LP@set@env@prefix{LP@NL}%
  \setcounter{LP@rows}{\LP@NL@rows}%
  \setcounter{LP@columns}{\LP@NL@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@NL@width}%
    \ifthenelse{\equal{\LP@NL@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@NL@titleindent}\parbox{\LP@NL@titlewidth}{\strut\LP@titleformat\LP@NL@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@NL@scale]%
      \LP@drawbackground{1}{1}{\LP@NL@columns}{\LP@NL@rows}{\LP@NL@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@NL@columns}{\LP@NL@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@NL@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% resuko environment and options
%
\newcommand*\LP@RSK@init@prefix{LP@RSK}%
\newcommand*\LP@RSK@init@package{resuko}%
%
\LP@define@key{\LP@RSK@init@prefix}{\LP@RSK@init@package}{rows}{5}%
\LP@define@key{\LP@RSK@init@prefix}{\LP@RSK@init@package}{columns}{5}%
\LP@define@key{\LP@RSK@init@prefix}{\LP@RSK@init@package}{scale}{1}%
\LP@define@key{\LP@RSK@init@prefix}{\LP@RSK@init@package}{counterstyle}{none}%
\LP@define@key{\LP@RSK@init@prefix}{\LP@RSK@init@package}{bgcolor}{}%
\LP@define@key{\LP@RSK@init@prefix}{\LP@RSK@init@package}{color}{blue}%
\LP@define@key{\LP@RSK@init@prefix}{\LP@RSK@init@package}{width}{5.1cm}%
\LP@define@key{\LP@RSK@init@prefix}{\LP@RSK@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@RSK@init@prefix}{\LP@RSK@init@package}{title}{}%
\LP@define@key{\LP@RSK@init@prefix}{\LP@RSK@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@RSK@init@prefix}{\LP@RSK@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@RSK@init@prefix}{\LP@RSK@init@package}{Large}%
%
\let\resukocell\setcell%
%
\newcommand*\resukosetup[1]%
{%
  \setkeys{resuko.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\LP@trackC}
% For the \env{resuko} environment, we need to draw differnt tiles of track segments.
% First, we start with a curve from the bottom to the left.
%    \begin{macrocode}
\newcommand*\LP@trackC%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \begin{tikzpicture}[scale=\LP@scale]%
    \pgfsetcornersarced{\pgfpoint{4mm*\LP@scale}{4mm*\LP@scale}}%
    \draw[color=LP@c@track, line width=.3cm*\LP@scale]%
      (0,.5)--(.5,.5)--(.5,0);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@G@trackC}
% A generic command for drawing track curves with a rotation \oarg{angle}.
%
% \cs{LP@G@trackC}\oarg{angle}
%    \begin{macrocode}
\newcommand*\LP@G@trackC[1][0]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
%    \end{macrocode}
% We draw a Ti\textit{k}Z picture and apply a rotation.
%    \begin{macrocode}
  \begin{tikzpicture}[scale=\LP@scale,rotate=#1]%
%    \end{macrocode}
% We want tiles fitting into a cell, so we clip the picture. Furthermore, we
% want rounded corners for the race track, of course!
%    \begin{macrocode}
    \clip (0,0) rectangle (1,1);%
    \pgfsetcornersarced{\pgfpoint{4mm*\LP@scale}{4mm*\LP@scale}}%
%    \end{macrocode}
% Then we draw a track curve from the bottom to the left. Rotation applies
% for the complete picture!
%    \begin{macrocode}
    \draw[color=LP@c@track, line width=.3cm*\LP@scale]%
      (0,.5)--(.5,.5)--(.5,0);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\CurveBL}
%    \begin{macrocode}
\let\CurveBL\LP@G@trackC%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\CurveBR}
%    \begin{macrocode}
\newcommand*\CurveBR{\LP@G@trackC[90]}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\CurveTR}
%    \begin{macrocode}
\newcommand*\CurveTR{\LP@G@trackC[180]}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\CurveTL}
%    \begin{macrocode}
\newcommand*\CurveTL{\LP@G@trackC[270]}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@trackS}
% Of course, we also need straights.
%    \begin{macrocode}
\newcommand*\LP@trackS%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \begin{tikzpicture}[scale=\LP@scale]%
    \draw[draw opacity=0] (.2,0) -- (.8,1);%
    \draw[color=LP@c@track, line width=.3cm*\LP@scale]%
      (.5,0)--(.5,1);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@G@trackS}
% We need horizontal and vertical straights, therefore we allow an rotate angle.
%
% \cs{LP@G@trackS}\oarg{angle}
%    \begin{macrocode}
\newcommand*\LP@G@trackS[1][0]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \begin{tikzpicture}[scale=\LP@scale,rotate=#1]%
    \clip (0,0) rectangle (1,1);%
    \draw[color=LP@c@track, line width=.3cm*\LP@scale]%
      (.5,0)--(.5,1);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\StraightV}
%    \begin{macrocode}
\newcommand*\StraightV{\LP@G@trackS}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\StraightH}
%    \begin{macrocode}
\newcommand*\StraightH{\LP@G@trackS[90]}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Straight}
%    \begin{macrocode}
\let\Straight\StraightV%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@trackCR}
% Crossings are needed as well!
%    \begin{macrocode}
\newcommand*\LP@trackCR%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \begin{tikzpicture}[scale=\LP@scale]%
    \draw[color=LP@c@track, line width=.3cm*\LP@scale]%
      (0,0.5)--(1,.5);%
    \draw[color=LP@c@track, line width=.3cm*\LP@scale]%
      (0.5,0)--(.5,.2);%
    \draw[color=LP@c@track, line width=.3cm*\LP@scale]%
      (0.5,1)--(.5,.8);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@G@trackCR}
% Same game again, we need also rotated versions.
%    \begin{macrocode}
\newcommand*\LP@G@trackCR[1][0]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \begin{tikzpicture}[scale=\LP@scale,rotate=#1]%
    \clip (0,0) rectangle (1,1);%
    \draw[color=LP@c@track, line width=.3cm*\LP@scale]%
      (0,0.5)--(1,.5);%
    \draw[color=LP@c@track, line width=.3cm*\LP@scale]%
      (0.5,0)--(.5,.2);%
    \draw[color=LP@c@track, line width=.3cm*\LP@scale]%
      (0.5,1)--(.5,.8);%
  \end{tikzpicture}%
}%
%
\newcommand*\CrossH{\LP@G@trackCR}%
\newcommand*\CrossV{\LP@G@trackCR[90]}%
\let\Cross\CrossH%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@graveltrap}
% We also need a gravel trap.
%
%    \begin{macrocode}
\newcommand*\LP@graveltrap%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \begin{tikzpicture}[scale=\LP@scale]%
    \clip (0,0) rectangle (1,1);%
    \fill[color=LP@c@track] (.5,.5) circle (.1cm);%
  \end{tikzpicture}%
}%
%
\let\Graveltrap\LP@graveltrap%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\parkinglot}
% And a parking lot!
%    \begin{macrocode}
\newcommand*\parkinglot[2]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \LP@set@LP@color{\LP@env@prefix}%
  \LP@set@LP@bgcolor{\LP@env@prefix}%
  \LP@set@LP@fontsize{\LP@env@prefix}%
  \ifthenelse{\equal{\LP@color}{}}%
  {\gdef\LP@c@parkinglot{black}}%
  {\gdef\LP@c@parkinglot{\LP@color}}%
  \ifthenelse{\equal{\LP@bgcolor}{}}%
  {\gdef\LP@c@bg@parkinglot{white}}%
  {\gdef\LP@c@bg@parkinglot{\LP@bgcolor}}%
  \setcounter{LP@counti}{#1}%
  \setcounter{LP@countii}{#2}%
  \stepcounter{LP@counti}%
  \stepcounter{LP@countii}%
  \draw[color=\LP@c@parkinglot,line width=\LP@normallines,%
        fill=\LP@c@bg@parkinglot] (#1,#2) rectangle ++(2,2);%
  \node[color=\LP@c@parkinglot,font=\sffamily\bfseries\LP@fontsize]%
    at (\arabic{LP@counti},\arabic{LP@countii}){P};%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pitlane}
% And finally, the pitlane!
%    \begin{macrocode}
\newcommand*\pitlane[3]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \LP@set@LP@color{\LP@env@prefix}%
  \ifthenelse{\equal{\LP@color}{}}%
  {\gdef\LP@c@pitlane{black}}%
  {\gdef\LP@c@pitlane{\LP@color}}%
  \ifthenelse{\equal{#3}{V}}%
  {\draw[color=black,line width=\LP@normallines,fill=\LP@c@pitlane]%
    (#1,#2) rectangle ++(1,4);}%
  {\draw[color=black,line width=\LP@normallines,fill=\LP@c@pitlane]%
    (#1,#2) rectangle ++(4,1);}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@trackline}
% This macro provides the "box" placed next to the grid, showing the
% straights, curves and crossings, which are needed in that line!
%
% \cs{LP@trackline}\marg{\string# straights}\marg{\string# curves}\marg{\string# crossings}
%    \begin{macrocode}
\newcommand*\LP@trackline[3]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \pgfmathsetlength{\LP@length}{.1cm*\LP@scale}%
  \scalebox{\LP@tracks@scale}%
  {%
    \hspace{\LP@length}%
    \setcounter{LP@whiledo@i}{#1}%
    \whiledo{\arabic{LP@whiledo@i}>0}%
    {%
      \LP@trackS%
      \addtocounter{LP@whiledo@i}{-1}%
    }%
    \setcounter{LP@whiledo@i}{#2}%
    \whiledo{\arabic{LP@whiledo@i}>0}%
    {%
      \LP@trackC%
      \addtocounter{LP@whiledo@i}{-1}%
    }%
    \hspace{\LP@length}%
    \setcounter{LP@whiledo@i}{#3}%
    \whiledo{\arabic{LP@whiledo@i}>0}%
    {%
      \LP@trackCR%
      \addtocounter{LP@whiledo@i}{-1}%
    }%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\trackV}
% This macro places the vertical track lines and expects a csv list
% in the format straights/curves/crossings!
%
% \cs{trackV}\marg{csv list}
%    \begin{macrocode}
\newcommand*\trackV[1]%
{%
  \LP@set@LP@columns{\LP@env@prefix}%
  \setcounter{LP@counti}{\LP@columns}%
  \stepcounter{LP@counti}%
  \setcounter{LP@countii}{1}%
  \foreach \LP@c@straight/\LP@c@curve/\LP@c@cross in {#1}%
  {%
    \node[anchor=west] at (\arabic{LP@counti},\arabic{LP@countii}.5)%
      {\LP@trackline{\LP@c@straight}{\LP@c@curve}{\LP@c@cross}};%
    \stepcounter{LP@countii}%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\trackH}
% The same for the horizontal track lines!
%
% \cs{trackH}\marg{csv list}
%    \begin{macrocode}
\newcommand*\trackH[1]%
{%
  \setcounter{LP@counti}{1}%
  \setcounter{LP@countii}{1}%
  \foreach \LP@c@straight/\LP@c@curve/\LP@c@cross in {#1}%
  {%
    \node[anchor=west,rotate=-90]%
      at (\arabic{LP@counti}.5,\arabic{LP@countii})%
        {\LP@trackline{\LP@c@straight}{\LP@c@curve}{\LP@c@cross}};%
    \stepcounter{LP@counti}%
  };%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\track}
% We still need to draw the race track. The used decoration - which allows
% automatic over-/underbridges - was provided by
% \href{http://tex.stackexchange.com/users/3708/frederic}{Frédéric} in this
% \href{http://tex.stackexchange.com/questions/115923/crossing-paths-in-tikz-without-intersection}{question}!
%
% \cs{track}\marg{Ti\textit{k}z path}
%    \begin{macrocode}
\newcommand*\track[1]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \LP@set@LP@bgcolor{\LP@env@prefix}%
  \ifthenelse{\equal{\LP@bgcolor}{}}%
  {\gdef\LP@c@bg@track{white}}%
  {\gdef\LP@c@bg@track{\LP@bgcolor}}%
  \bgroup%
    \def\LP@rel@tikzpath{.5}%
    \begin{pgfonlayer}{LPbackgroundtwo}%
      \pgfsetcornersarced{\pgfpoint{4.9mm*\LP@scale}{4.9mm*\LP@scale}}%
      \draw[decorate,decoration={show path construction,%
        lineto code={%
          \draw [\LP@c@bg@track,line width=0.15cm*\LP@scale,%
                 double=LP@c@track,double distance=.3cm*\LP@scale]%
            (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);},%
        curveto code={%
          \draw [LP@c@track,line width=0.3cm*\LP@scale]%
            (\tikzinputsegmentfirst) .. controls%
            (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)%
            ..(\tikzinputsegmentlast);}}] #1;%
    \end{pgfonlayer}%
  \egroup%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{resuko}
%    \begin{macrocode}
\newenvironment{resuko}[1][]%
{%
  \setkeys{resuko}{#1}%
  \LP@set@package{resuko}%
  \LP@set@env@prefix{LP@RSK}%
  \setcounter{LP@rows}{\LP@RSK@rows}%
  \setcounter{LP@columns}{\LP@RSK@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@RSK@width}%
    \ifthenelse{\equal{\LP@RSK@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@RSK@titleindent}\parbox{\LP@RSK@titlewidth}{\strut\LP@titleformat\LP@RSK@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@RSK@scale]%
      \LP@drawbackground{1}{1}{\LP@RSK@columns}{\LP@RSK@rows}{\LP@RSK@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@RSK@columns}{\LP@RSK@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@RSK@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% schatzsuche environment and options
%
\newcommand*\LP@SS@init@prefix{LP@SS}%
\newcommand*\LP@SS@init@package{schatzsuche}%
%
\LP@define@key{\LP@SS@init@prefix}{\LP@SS@init@package}{rows}{5}%
\LP@define@key{\LP@SS@init@prefix}{\LP@SS@init@package}{columns}{5}%
\LP@define@key{\LP@SS@init@prefix}{\LP@SS@init@package}{scale}{1}%
\LP@define@key{\LP@SS@init@prefix}{\LP@SS@init@package}{counterstyle}{none}%
\LP@define@key{\LP@SS@init@prefix}{\LP@SS@init@package}{bgcolor}{}%
\LP@define@key{\LP@SS@init@prefix}{\LP@SS@init@package}{width}{5.1cm}%
\LP@define@key{\LP@SS@init@prefix}{\LP@SS@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@SS@init@prefix}{\LP@SS@init@package}{title}{}%
\LP@define@key{\LP@SS@init@prefix}{\LP@SS@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@SS@init@prefix}{\LP@SS@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@SS@init@prefix}{\LP@SS@init@package}{Large}%
%
\let\schatzsuchecell\setcell%
%
\newcommand*\schatzsuchesetup[1]%
{%
  \setkeys{schatzsuche.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\LP@Diamond}
% For the \env{schatzsuche} environment, we need to draw diamonds.
%    \begin{macrocode}
\newcommand*\LP@Diamond%
{%
  \begin{tikzpicture}[scale=\LP@scale*.9]%
  \clip (.05,.905) rectangle (.95,.1);%
  \draw[line width=\LP@normallines,fill=yellow!20]%
    (.5,.1) -- (.7,.9) -- (.3,.9) -- cycle;%
  \draw[line width=\LP@normallines,fill=orange!20]%
    (.5,.1) -- (.7,.9) -- (.9,.8) -- cycle;%
  \draw[line width=\LP@normallines,fill=orange!20]%
    (.5,.1) -- (.3,.9) -- (.1,.8) -- cycle;%
  \draw[line width=\LP@normallines] (.1,.8) -- (.9,.8);%
\end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Diamond}
% A user command for drawing diamonds.
%    \begin{macrocode}
\let\Diamond\LP@Diamond%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{schatzsuche}
%    \begin{macrocode}
\newenvironment{schatzsuche}[1][]%
{%
  \setkeys{schatzsuche}{#1}%
  \LP@set@package{schatzsuche}%
  \LP@set@env@prefix{LP@SS}%
  \setcounter{LP@rows}{\LP@SS@rows}%
  \setcounter{LP@columns}{\LP@SS@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@SS@width}%
    \ifthenelse{\equal{\LP@SS@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@SS@titleindent}\parbox{\LP@SS@titlewidth}{\strut\LP@titleformat\LP@SS@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@SS@scale]%
      \LP@drawbackground{1}{1}{\LP@SS@columns}{\LP@SS@rows}{\LP@SS@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@SS@columns}{\LP@SS@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@SS@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% skyline environment and options
%
\newcommand*\LP@SL@init@prefix{LP@SL}%
\newcommand*\LP@SL@init@package{skyline}%
%
\LP@define@key{\LP@SL@init@prefix}{\LP@SL@init@package}{rows}{5}%
\LP@define@key{\LP@SL@init@prefix}{\LP@SL@init@package}{columns}{5}%
\LP@define@key{\LP@SL@init@prefix}{\LP@SL@init@package}{scale}{1}%
\LP@define@key{\LP@SL@init@prefix}{\LP@SL@init@package}{counterstyle}{none}%
\LP@define@key{\LP@SL@init@prefix}{\LP@SL@init@package}{bgcolor}{}%
\LP@define@key{\LP@SL@init@prefix}{\LP@SL@init@package}{width}{6.7cm}%
\LP@define@key{\LP@SL@init@prefix}{\LP@SL@init@package}{cvoffset}{-38pt}%
\LP@define@key{\LP@SL@init@prefix}{\LP@SL@init@package}{title}{}%
\LP@define@key{\LP@SL@init@prefix}{\LP@SL@init@package}{titleindent}{0.75cm}%
\LP@define@key{\LP@SL@init@prefix}{\LP@SL@init@package}{titlewidth}{5.85cm}%
\LP@define@choicekey@fontsize{\LP@SL@init@prefix}{\LP@SL@init@package}{Large}%
%
\newcommand*\LP@SL@sudoku{false}%
%
\define@choicekey*{skyline.sty}{sudoku}[\LP@SL@sudoku\nr]{true,false}[true]%
{%
  \ifcase\nr\relax%
    \renewcommand*\LP@SL@sudoku{true}%
    \renewcommand*\LP@SL@rows{9}%
    \renewcommand*\LP@SL@columns{9}%
  \or%
    \renewcommand*\LP@SL@sudoku{false}%
  \fi%
}%
%
\define@choicekey*{skyline}{sudoku}[\LP@SL@sudoku\nr]{true,false}[true]%
{%
  \ifcase\nr\relax%
    \renewcommand*\LP@SL@sudoku{true}%
    \renewcommand*\LP@SL@rows{9}%
    \renewcommand*\LP@SL@columns{9}%
  \or%
    \renewcommand*\LP@SL@sudoku{false}%
  \fi%
}%
%
\let\skylineB\LP@bottomrow%
\let\skylineT\LP@toprow%
\let\skylineL\LP@leftcolumn%
\let\skylineR\LP@rightcolumn%
\let\skylinecell\setcell%
%
\newcommand*\skylinesetup[1]%
{%
  \setkeys{skyline.sty}{#1}%
}%
%    \end{macrocode}
% \begin{environment}{skyline}
%    \begin{macrocode}
\newenvironment{skyline}[1][]%
{%
  \setkeys{skyline}{#1}%
  \LP@set@package{skyline}%
  \LP@set@env@prefix{LP@SL}%
  \setcounter{LP@rows}{\LP@SL@rows}%
  \setcounter{LP@columns}{\LP@SL@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@SL@width}%
    \ifthenelse{\equal{\LP@SL@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@SL@titleindent}\parbox{\LP@SL@titlewidth}{\strut\LP@titleformat\LP@SL@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@SL@scale]%
      \LP@drawbackground{1}{1}{\LP@SL@columns}{\LP@SL@rows}{\LP@SL@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@SL@columns}{\LP@SL@rows}{1cm}%
      \ifthenelse{\equal{\LP@SL@sudoku}{true}}%
      {\LP@drawsudokugrid}%
      {}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@SL@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% slitherlink environment and options
%
\newcommand*\LP@SK@init@prefix{LP@SK}%
\newcommand*\LP@SK@init@package{slitherlink}%
%
\LP@define@key{\LP@SK@init@prefix}{\LP@SK@init@package}{rows}{5}%
\LP@define@key{\LP@SK@init@prefix}{\LP@SK@init@package}{columns}{5}%
\LP@define@key{\LP@SK@init@prefix}{\LP@SK@init@package}{scale}{1}%
\LP@define@key{\LP@SK@init@prefix}{\LP@SK@init@package}{counterstyle}{none}%
\LP@define@key{\LP@SK@init@prefix}{\LP@SK@init@package}{bgcolor}{}%
\LP@define@key{\LP@SK@init@prefix}{\LP@SK@init@package}{width}{5.2cm}%
\LP@define@key{\LP@SK@init@prefix}{\LP@SK@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@SK@init@prefix}{\LP@SK@init@package}{title}{}%
\LP@define@key{\LP@SK@init@prefix}{\LP@SK@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@SK@init@prefix}{\LP@SK@init@package}{titlewidth}{5.2cm}%
\LP@define@choicekey@fontsize{\LP@SK@init@prefix}{\LP@SK@init@package}{Large}%
%
\let\slitherlinkcell\setcell%
%
\newcommand*\slitherlinksetup[1]%
{%
  \setkeys{slitherlink.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\LP@drawgriddots}
% For the \env{slitherlink} environment, we need little dots in every cell corner.
% Therefore, we loop through all rows and columns and paint the dots on the \layer{LPforeground} layer.
% \changes{v2.5}{2013/07/22}{removed unnecessary \texttt{scale} update}
%    \begin{macrocode}
\newcommand*\LP@drawgriddots%
{%
  \pgfmathsetmacro{\START}{1}%
%    \end{macrocode}
% The dots are drawn immediatly after the grid, so we can recycle |LP@counti| and |LP@countii|.
%    \begin{macrocode}
  \pgfmathsetmacro{\ENDC}{\arabic{LP@counti}}%
  \pgfmathsetmacro{\ENDR}{\arabic{LP@countii}}%
  \begin{pgfonlayer}{LPforeground}%
    \foreach \i in {\START,...,\ENDC}%
      \foreach \j in {\START,...,\ENDR}%
        \fill[color=LP@c@griddots] (\i,\j) circle [radius=3pt];%
  \end{pgfonlayer}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{slitherlink}
%    \begin{macrocode}
\newenvironment{slitherlink}[1][]%
{%
  \setkeys{slitherlink}{#1}%
  \LP@set@package{slitherlink}%
  \LP@set@env@prefix{LP@SK}%
  \ifthenelse{\equal{\LP@grid@linestyle}{}}%
    {\setgridlinestyle{dashed}}{}%
  \setcounter{LP@rows}{\LP@SK@rows}%
  \setcounter{LP@columns}{\LP@SK@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@SK@width}%
    \ifthenelse{\equal{\LP@SK@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@SK@titleindent}\parbox{\LP@SK@titlewidth}{\strut\LP@titleformat\LP@SK@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@SK@scale]%
      \LP@drawbackground{1}{1}{\LP@SK@columns}{\LP@SK@rows}{\LP@SK@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@SK@columns}{\LP@SK@rows}{1cm}%
      \LP@drawgriddots%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@SK@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% starbattle environment and options
%
\newcommand*\LP@SB@init@prefix{LP@SB}%
\newcommand*\LP@SB@init@package{starbattle}%
%
\LP@define@key{\LP@SB@init@prefix}{\LP@SB@init@package}{rows}{5}%
\LP@define@key{\LP@SB@init@prefix}{\LP@SB@init@package}{columns}{5}%
\LP@define@key{\LP@SB@init@prefix}{\LP@SB@init@package}{scale}{1}%
\LP@define@key{\LP@SB@init@prefix}{\LP@SB@init@package}{counterstyle}{none}%
\LP@define@key{\LP@SB@init@prefix}{\LP@SB@init@package}{bgcolor}{}%
\LP@define@key{\LP@SB@init@prefix}{\LP@SB@init@package}{width}{5.1cm}%
\LP@define@key{\LP@SB@init@prefix}{\LP@SB@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@SB@init@prefix}{\LP@SB@init@package}{title}{}%
\LP@define@key{\LP@SB@init@prefix}{\LP@SB@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@SB@init@prefix}{\LP@SB@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@SB@init@prefix}{\LP@SB@init@package}{Large}%
%
\let\starbattlecell\setcell%
%
\newcommand*\starbattlesetup[1]%
{%
  \setkeys{starbattle.sty}{#1}%
}%
%    \end{macrocode}
% \begin{environment}{starbattle}
%    \begin{macrocode}
\newenvironment{starbattle}[1][]%
{%
  \setkeys{starbattle}{#1}%
  \LP@set@package{starbattle}%
  \LP@set@env@prefix{LP@SB}%
  \setcounter{LP@rows}{\LP@SB@rows}%
  \setcounter{LP@columns}{\LP@SB@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@SB@width}%
    \ifthenelse{\equal{\LP@SB@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@SB@titleindent}\parbox{\LP@SB@titlewidth}{\strut\LP@titleformat\LP@SB@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@SB@scale]%
      \LP@drawbackground{1}{1}{\LP@SB@columns}{\LP@SB@rows}{\LP@SB@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@SB@columns}{\LP@SB@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@SB@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% starsandarrows environment and options
%
\newcommand*\LP@SAA@init@prefix{LP@SAA}%
\newcommand*\LP@SAA@init@package{starsandarrows}%
%
\LP@define@key{\LP@SAA@init@prefix}{\LP@SAA@init@package}{rows}{5}%
\LP@define@key{\LP@SAA@init@prefix}{\LP@SAA@init@package}{columns}{5}%
\LP@define@key{\LP@SAA@init@prefix}{\LP@SAA@init@package}{scale}{1}%
\LP@define@key{\LP@SAA@init@prefix}{\LP@SAA@init@package}{counterstyle}{none}%
\LP@define@key{\LP@SAA@init@prefix}{\LP@SAA@init@package}{bgcolor}{}%
\LP@define@key{\LP@SAA@init@prefix}{\LP@SAA@init@package}{width}{5.9cm}%
\LP@define@key{\LP@SAA@init@prefix}{\LP@SAA@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@SAA@init@prefix}{\LP@SAA@init@package}{title}{}%
\LP@define@key{\LP@SAA@init@prefix}{\LP@SAA@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@SAA@init@prefix}{\LP@SAA@init@package}{titlewidth}{5.9cm}%
\LP@define@choicekey@fontsize{\LP@SAA@init@prefix}{\LP@SAA@init@package}{Large}%
%
\let\starsH\LP@toprow%
\let\starsV\LP@leftcolumn%
%
\newcommand*\starsandarrowssetup[1]%
{%
  \setkeys{starsandarrows.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\LP@Star}
% For several environments, we need to draw stars.
%    \begin{macrocode}
\newcommand*\LP@Star%
{%
  \tikz\node[shape=star,fill=yellow,draw,scale=.8*\LP@scale,%
             star point height=.25cm] {};%
}%
%    \end{macrocode}
% A user command for drawing stars.
%    \begin{macrocode}
\let\Star\LP@Star%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@ArrowA}
% A generic macro for drawing arrows with different colors and angles.
%
% \cs{LP@ArrowA}\oarg{color}\marg{angle}
%    \begin{macrocode}
\newcommand*\LP@ArrowA[2][red]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \pgfmathsetmacro{\LPlinewidth}{3pt*\LP@scale}%
  \tikz\draw[->,line width=\LPlinewidth,rotate=#2,%
             scale=\LP@scale,color=#1]%
               (0.1,.5) -- (0.9,.5);%
}%
%    \end{macrocode}
% The we define some arrows with standard angles.
%    \begin{macrocode}
\newcommand*\LP@c@stararrow{red}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Right}
%    \begin{macrocode}
\newcommand*\Right{\LP@ArrowA[\LP@c@stararrow]{0}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\RightUp}
%    \begin{macrocode}
\newcommand*\RightUp{\LP@ArrowA[\LP@c@stararrow]{45}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Up}
%    \begin{macrocode}
\newcommand*\Up{\LP@ArrowA[\LP@c@stararrow]{90}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LeftUp}
%    \begin{macrocode}
\newcommand*\LeftUp{\LP@ArrowA[\LP@c@stararrow]{135}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Left}
%    \begin{macrocode}
\newcommand*\Left{\LP@ArrowA[\LP@c@stararrow]{180}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LeftDown}
%    \begin{macrocode}
\newcommand*\LeftDown{\LP@ArrowA[\LP@c@stararrow]{225}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Down}
%    \begin{macrocode}
\newcommand*\Down{\LP@ArrowA[\LP@c@stararrow]{270}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\RightDown}
%    \begin{macrocode}
\newcommand*\RightDown{\LP@ArrowA[\LP@c@stararrow]{315}}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{starsandarrows}
%    \begin{macrocode}
\newenvironment{starsandarrows}[1][]%
{%
  \setkeys{starsandarrows}{#1}%
  \LP@set@package{starsandarrows}%
  \LP@set@env@prefix{LP@SAA}%
  \setcounter{LP@rows}{\LP@SAA@rows}%
  \setcounter{LP@columns}{\LP@SAA@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@SAA@width}%
    \ifthenelse{\equal{\LP@SAA@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@SAA@titleindent}\parbox{\LP@SAA@titlewidth}{\strut\LP@titleformat\LP@SAA@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@SAA@scale]%
      \LP@drawbackground{1}{1}{\LP@SAA@columns}{\LP@SAA@rows}{\LP@SAA@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@SAA@columns}{\LP@SAA@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@SAA@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% sunandmoon environment and options
%
\newcommand*\LP@SAM@init@prefix{LP@SAM}%
\newcommand*\LP@SAM@init@package{sunandmoon}%
%
\LP@define@key{\LP@SAM@init@prefix}{\LP@SAM@init@package}{rows}{5}%
\LP@define@key{\LP@SAM@init@prefix}{\LP@SAM@init@package}{columns}{5}%
\LP@define@key{\LP@SAM@init@prefix}{\LP@SAM@init@package}{scale}{1}%
\LP@define@key{\LP@SAM@init@prefix}{\LP@SAM@init@package}{counterstyle}{none}%
\LP@define@key{\LP@SAM@init@prefix}{\LP@SAM@init@package}{bgcolor}{}%
\LP@define@key{\LP@SAM@init@prefix}{\LP@SAM@init@package}{width}{5.1cm}%
\LP@define@key{\LP@SAM@init@prefix}{\LP@SAM@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@SAM@init@prefix}{\LP@SAM@init@package}{title}{}%
\LP@define@key{\LP@SAM@init@prefix}{\LP@SAM@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@SAM@init@prefix}{\LP@SAM@init@package}{titlewidth}{5.1cm}%
\LP@define@choicekey@fontsize{\LP@SAM@init@prefix}{\LP@SAM@init@package}{Large}%
%
\let\sunandmooncell\setcell%
%
\newcommand*\sunandmoonsetup[1]%
{%
  \setkeys{sunandmoon.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\LP@DarkCloud}
% For the \env{sunandmoon} environment, we need to draw a dark cloud and differently%
% lighted moons.
%    \begin{macrocode}
\newcommand*\LP@DarkCloud{%
  \tikz[scale=0.7*\LP@scale]\fill[color=black!60] (0,0)%
    rectangle (1,1);%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@Moon}
%    \begin{macrocode}
\newcommand*\LP@Moon{%
  \tikz[scale=0.7*\LP@scale]\fill[color=black!60]%
    (0,0) circle (0.5cm);%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@MoonR}
%    \begin{macrocode}
\newcommand*\LP@MoonR%
{%
  \begin{tikzpicture}[scale=0.7*\LP@scale]%
    \fill[color=black!60] (0.5,0.5) circle (0.5cm);%
    \fill[color=yellow] (.5,0) arc (270:450:.5);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@MoonL}
%    \begin{macrocode}
\newcommand*\LP@MoonL%
{%
  \begin{tikzpicture}[scale=0.7*\LP@scale]%
    \fill[color=black!60] (0.5,0.5) circle (0.5cm);%
    \fill[color=yellow] (.5,0) arc (270:90:.5);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@MoonT}
%    \begin{macrocode}
\newcommand*\LP@MoonT%
{%
  \begin{tikzpicture}[scale=0.7*\LP@scale]%
    \fill[color=black!60] (0.5,0.5) circle (0.5cm);%
    \fill[color=yellow] (0,0.5) arc (180:0:.5);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@MoonB}
%    \begin{macrocode}
\newcommand*\LP@MoonB%
{%
  \begin{tikzpicture}[scale=0.7*\LP@scale]%
    \fill[color=black!60] (0.5,0.5) circle (0.5cm);%
    \fill[color=yellow] (0,0.5) arc (180:360:.5);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@MoonTL}
%    \begin{macrocode}
\newcommand*\LP@MoonTL%
{%
  \begin{tikzpicture}[scale=0.7*\LP@scale]%
    \fill[color=yellow] (0.5,0.5) circle (0.5cm);%
    \fill[color=black!60] (1,.5) -- (.5,.5) -- (.5,0)%
                          arc (270:360:.5);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@MoonBL}
%    \begin{macrocode}
\newcommand*\LP@MoonBL%
{%
  \begin{tikzpicture}[scale=0.7*\LP@scale]%
    \fill[color=yellow] (0.5,0.5) circle (0.5cm);%
    \fill[color=black!60] (1,.5) -- (.5,.5) -- (.5,1)%
                          arc (90:0:.5);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@MoonBR}
%    \begin{macrocode}
\newcommand*\LP@MoonBR%
{%
  \begin{tikzpicture}[scale=0.7*\LP@scale]%
    \fill[color=yellow] (0.5,0.5) circle (0.5cm);%
    \fill[color=black!60] (0,.5) -- (.5,.5) -- (.5,1)%
                          arc (90:180:.5);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@MoonTR}
%    \begin{macrocode}
\newcommand*\LP@MoonTR%
{%
  \begin{tikzpicture}[scale=0.7*\LP@scale]%
    \fill[color=yellow] (0.5,0.5) circle (0.5cm);%
    \fill[color=black!60] (0,.5) -- (.5,.5) -- (.5,0)%
                          arc (270:180:.5);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Cloud}
%    \begin{macrocode}
\let\Cloud\LP@DarkCloud%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Moon}
%    \begin{macrocode}
\let\Moon\LP@Moon%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MoonR}
%    \begin{macrocode}
\let\MoonR\LP@MoonR%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MoonL}
%    \begin{macrocode}
\let\MoonL\LP@MoonL%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MoonT}
%    \begin{macrocode}
\let\MoonT\LP@MoonT%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MoonB}
%    \begin{macrocode}
\let\MoonB\LP@MoonB%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MoonTL}
%    \begin{macrocode}
\let\MoonTL\LP@MoonTL%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MoonBL}
%    \begin{macrocode}
\let\MoonBL\LP@MoonBL%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MoonBR}
%    \begin{macrocode}
\let\MoonBR\LP@MoonBR%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MoonTR}
%    \begin{macrocode}
\let\MoonTR\LP@MoonTR%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{sunandmoon}
%    \begin{macrocode}
\newenvironment{sunandmoon}[1][]%
{%
  \setkeys{sunandmoon}{#1}%
  \LP@set@package{sunandmoon}%
  \LP@set@env@prefix{LP@SAM}%
  \setcounter{LP@rows}{\LP@SAM@rows}%
  \setcounter{LP@columns}{\LP@SAM@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@SAM@width}%
    \ifthenelse{\equal{\LP@SAM@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@SAM@titleindent}\parbox{\LP@SAM@titlewidth}{\strut\LP@titleformat\LP@SAM@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@SAM@scale]%
      \LP@drawbackground{1}{1}{\LP@SAM@columns}{\LP@SAM@rows}{\LP@SAM@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@SAM@columns}{\LP@SAM@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@SAM@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% tentsandtrees environment and options
%
\newcommand*\LP@TAT@init@prefix{LP@TAT}%
\newcommand*\LP@TAT@init@package{tentsandtrees}%
%
\LP@define@key{\LP@TAT@init@prefix}{\LP@TAT@init@package}{rows}{5}%
\LP@define@key{\LP@TAT@init@prefix}{\LP@TAT@init@package}{columns}{5}%
\LP@define@key{\LP@TAT@init@prefix}{\LP@TAT@init@package}{scale}{1}%
\LP@define@key{\LP@TAT@init@prefix}{\LP@TAT@init@package}{counterstyle}{none}%
\LP@define@key{\LP@TAT@init@prefix}{\LP@TAT@init@package}{bgcolor}{}%
\LP@define@key{\LP@TAT@init@prefix}{\LP@TAT@init@package}{width}{5.9cm}%
\LP@define@key{\LP@TAT@init@prefix}{\LP@TAT@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@TAT@init@prefix}{\LP@TAT@init@package}{title}{}%
\LP@define@key{\LP@TAT@init@prefix}{\LP@TAT@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@TAT@init@prefix}{\LP@TAT@init@package}{titlewidth}{5.9cm}%
\LP@define@choicekey@fontsize{\LP@TAT@init@prefix}{\LP@TAT@init@package}{Large}%
%
\let\tentH\LP@toprow%
\let\tentV\LP@leftcolumn%
%
\newcommand*\tentsandtreessetup[1]%
{%
  \setkeys{tentsandtrees.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\LP@Tree}
% For the \env{tentsandtree} environments, we need to draw trees.
%    \begin{macrocode}
\newcommand*\LP@Tree%
{%
  \begin{tikzpicture}[scale=.07*\LP@scale]%
    \draw[fill=brown!95!black!95,line width=.1pt*\LP@scale]%
      (.75,-1) .. controls (.5,.5) and   (.5,3) .. (0.5,4) --%
      (-0.5,4) .. controls (-.5,3) and (-.5,.5) .. (-.75,-1);%
    \shade[top color=green!50!black!60,draw=black,%
           line width=.1pt*\LP@scale,bottom color=green!50!black]%
      (0,10) .. controls (0,8)     and (1,7)    .. (1.5,7)%
             .. controls (1,7)     and (1,7)    .. (0.5,7.25)%
             .. controls (1.5,5)   and (2.5,4)  .. (3,4)%
             .. controls (2,4)     and (1.25,4) .. (1,4.5)%
             .. controls (2,2)     and (3.5,2)  .. (4,2)%
             .. controls (1,1)     and (-1,1)   .. (-4,2)%
             .. controls (-3.5,2)  and (-2,2)   .. (-1,4.5)%
             .. controls (-1.25,4) and (-2,4)   .. (-3,4)%
             .. controls (-2.5,4)  and (-1.5,5) .. (-0.5,7.25)%
             .. controls (-1,7)    and (-1,7)   .. (-1.5,7)%
             .. controls (-1,7)    and (0,8)    .. (0,10);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Tree}
% A user command for drawing a tree.
%    \begin{macrocode}
\let\Tree\LP@Tree%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LP@Tent}
% We also need tents.
%    \begin{macrocode}
\newcommand*\LP@Tent%
{%
  \begin{tikzpicture}[scale=\LP@scale]%
    \draw[fill=yellow!50,line width=.1pt*\LP@scale]%
      (.1,.1) -- (.6,.1) -- (.9,.5) -- (.75,.8) -- (.35,.6)%
      -- cycle;%
    \draw[line width=.1pt*\LP@scale] (.35,.6) -- (.35,.1);%
    \draw[line width=.1pt*\LP@scale] (.35,.6) -- (.6,.1);%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Tent}
% A user command for drawing tents.
%    \begin{macrocode}
\let\Tent\LP@Tent%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{tentsandtrees}
%    \begin{macrocode}
\newenvironment{tentsandtrees}[1][]%
{%
  \setkeys{tentsandtrees}{#1}%
  \LP@set@package{tentsandtrees}%
  \LP@set@env@prefix{LP@TAT}%
  \setcounter{LP@rows}{\LP@TAT@rows}%
  \setcounter{LP@columns}{\LP@TAT@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@TAT@width}%
    \ifthenelse{\equal{\LP@TAT@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@TAT@titleindent}\parbox{\LP@TAT@titlewidth}{\strut\LP@titleformat\LP@TAT@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@TAT@scale]%
      \LP@drawbackground{1}{1}{\LP@TAT@columns}{\LP@TAT@rows}{\LP@TAT@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@TAT@columns}{\LP@TAT@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@TAT@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%
% tunnel environment and options
%
\newcommand*\LP@TN@init@prefix{LP@TN}%
\newcommand*\LP@TN@init@package{tunnel}%
%
\LP@define@key{\LP@TN@init@prefix}{\LP@TN@init@package}{rows}{5}%
\LP@define@key{\LP@TN@init@prefix}{\LP@TN@init@package}{columns}{5}%
\LP@define@key{\LP@TN@init@prefix}{\LP@TN@init@package}{scale}{1}%
\LP@define@key{\LP@TN@init@prefix}{\LP@TN@init@package}{counterstyle}{none}%
\LP@define@key{\LP@TN@init@prefix}{\LP@TN@init@package}{bgcolor}{}%
\LP@define@key{\LP@TN@init@prefix}{\LP@TN@init@package}{width}{5.9cm}%
\LP@define@key{\LP@TN@init@prefix}{\LP@TN@init@package}{cvoffset}{-23pt}%
\LP@define@key{\LP@TN@init@prefix}{\LP@TN@init@package}{title}{}%
\LP@define@key{\LP@TN@init@prefix}{\LP@TN@init@package}{titleindent}{0cm}%
\LP@define@key{\LP@TN@init@prefix}{\LP@TN@init@package}{titlewidth}{5.9cm}%
\LP@define@choicekey@fontsize{\LP@TN@init@prefix}{\LP@TN@init@package}{Large}%
%
\let\tunnelH\LP@toprow%
\let\tunnelV\LP@leftcolumn%
%
\newcommand*\tunnelsetup[1]%
{%
  \setkeys{tunnel.sty}{#1}%
}%
%    \end{macrocode}
% \begin{macro}{\LP@Portal}
% We define a Ti{\itshape k}Z picture that symbolizes a tunnel portal.
%    \begin{macrocode}
\newcommand*\LP@Portal%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \begin{tikzpicture}[scale=\LP@scale]%
    \fill[color=black]%
      (0,0) -- (0,1) -- (.4,.5) -- (.4,0) -- cycle;%
    \fill[color=LP@c@tunnel@ii]%
      (0,1) -- (1,1) -- (1,.5) -- (.4,.5) -- cycle;%
    \fill[color=LP@c@tunnel@i]%
      (.4,0) rectangle (1,.5);%
    \draw[line width=\LP@normallines] (0,0) rectangle (1,1) ;%
  \end{tikzpicture}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\portal}
% We define a user command to set a tunnel portal into a grid cell.
%
% \cs{portal}\marg{column}\marg{row}
%    \begin{macrocode}
\newcommand*\portal[2]%
{%
%    \end{macrocode}
% To avoid interference with the grid lines, we use the \layer{LPbackground} layer.
%    \begin{macrocode}
  \begin{puzzlebackground}%
    \LP@G@setcellcontent[hcenter,vcenter]{#1}{#2}{\LP@Portal}%
  \end{puzzlebackground}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\tube}
% For the \env{tunnel} environments, we need to draw tubes.
%
% \cs{tube}\marg{TikZ path}
%    \begin{macrocode}
\newcommand*\tube[1]%
{%
  \LP@set@LP@scale{\LP@env@prefix}%
  \bgroup%
%    \end{macrocode}
% Tubes start in the center of a grid cell, therefore we must redefine\newline
% \cs{LP@rel@tikzpath} to |.5| inside a group for \cs{tikzpath} and \cs{xtikzpath}.
%    \begin{macrocode}
    \def\LP@rel@tikzpath{.5}%
%        \end{macrocode}
% We draw on the \layer{LPbackgroundtwo} layer to get a segmented look behind
% the grid lines.
%    \begin{macrocode}
    \begin{pgfonlayer}{LPbackgroundtwo}%
      \pgfsetcornersarced{\pgfpoint{3mm}{3mm}}%
%    \end{macrocode}
% We draw the tube several times with slightly different colors to get a 3D effect.
%    \begin{macrocode}
      \draw[color=LP@c@tunnel!80!black, line width=.4cm*\LP@scale]%
        #1;%
      \draw[color=LP@c@tunnel, line width=.38cm*\LP@scale] #1;%
      \draw[color=LP@c@tunnel!85, line width=.35cm*\LP@scale] #1;%
      \draw[color=LP@c@tunnel!70, line width=.32cm*\LP@scale] #1;%
      \draw[color=LP@c@tunnel!55, line width=.29cm*\LP@scale] #1;%
      \draw[color=LP@c@tunnel!45, line width=.25cm*\LP@scale] #1;%
      \draw[color=LP@c@tunnel!35, line width=.2cm*\LP@scale] #1;%
    \end{pgfonlayer}%
  \egroup%
}%
%    \end{macrocode}
% \end{macro}
% \begin{environment}{tunnel}
%    \begin{macrocode}
\newenvironment{tunnel}[1][]%
{%
  \setkeys{tunnel}{#1}%
  \LP@set@package{tunnel}%
  \LP@set@env@prefix{LP@TN}%
  \setcounter{LP@rows}{\LP@TN@rows}%
  \setcounter{LP@columns}{\LP@TN@columns}%
  \stepcounter{LP@rows}%
  \stepcounter{LP@columns}%
  \begin{minipage}[t]{\LP@TN@width}%
    \ifthenelse{\equal{\LP@TN@title}{}}%
    {\par\enspace\par}% empty
    {\enspace\par\noindent\hspace{\LP@TN@titleindent}\parbox{\LP@TN@titlewidth}{\strut\LP@titleformat\LP@TN@title}\vspace{3mm}\par}%
    \begin{tikzpicture}[LPpreset,scale=\LP@TN@scale]%
      \LP@drawbackground{1}{1}{\LP@TN@columns}{\LP@TN@rows}{\LP@TN@bgcolor}%
      \LP@drawgrid{1}{1}{\LP@TN@columns}{\LP@TN@rows}{1cm}%
}%
{%
    \end{tikzpicture}%
    \LP@drawcounter{\LP@TN@counterstyle}%
    \stepcounter{LP@puzzlecounter}%
  \end{minipage}%
}%
%    \end{macrocode}
% \end{environment}
%    \begin{macrocode}
%</lpenv>
%    \end{macrocode}
%\Finale