Laser Beam
The puzzle
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. Here’s a little self-explanatory example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
\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} |
Options
rows (5)
defines the number of rows in the gridcolumns (5)
specifies the number of columns in the gridwidth (6.5cm)
sets the width of the minipage, in which the grid is typesetscale (1)
scales the size of the grid in the minipagefontsize (Large)
specifies the size of the numbers next to the grid. Here, the usual LaTeX sizes are used. Possible values: tiny, scriptsize, footnotesize, small, normalsize, large, Large, LARGE, huge, Hugetitle ()
sets the title of a puzzletitleindent (0cm)
defines the indent of the titletitlewidth (6.5cm)
specifies the width of the box the title is set inbgcolor ()
sets the background color of the gridcounterstyle (none)
defines the counter style. Predefined styles: none, left, rightcvoffset (-38pt)
sets the vertical offset of the counters in the margin
Environments
slitherlink
1 2 3 |
\begin{slitherlink} \end{slitherlink} |
The environment slitherlink
is the central core of the style file. With the optional argument of the environment, you can reset the options with local scope. Here, a blank grid is created.
puzzlebackground
1 2 3 |
\begin{puzzlebackground} \end{puzzlebackground} |
The puzzlebackground
environment allows you to place elements behind the main layer. This
is for example usefull for the \fillarea
command.
puzzleforeground
1 2 3 |
\begin{puzzleforeground} \end{puzzleforeground} |
The puzzleforeground
environment allows you to place elements in front of the main layer.
This is for example usefull for the \framearea
command.
Commands
In the grid and around
laserH
1 |
`\laserH{csv list}` |
The command laserH
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.
laserV
1 |
`\laserV{cvs list}` |
The command laserV
typesets the numbers left to the grid.
mirrorH
1 |
`\mirrorH{cvs list}` |
The command mirrorH
typesets the numbers below the grid indicating how many mirrors are placed in the intersections of this column.
mirrorV
1 |
`\mirrorV{cvs list}` |
The command mirrorV
typesets the numbers right to the grid.
placearrow
1 |
`\placearrow{column}{row}{direction}` |
The command \placearrow
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 direction
, you can use the following indicators: LeftUp,
LeftDown, RightUp, RightDown
placecross
1 |
`\placecross{column}{row}` |
With the \placecross
command you can place a cross in the intersections of the grid.
placemirror
1 |
`\placemirror{column}{row}{direction}` |
With the \placemirror
command you can place mirrors in the intersections of the grid. In the mandatory argument direction
, you can use the following indicators: H, V
laser
1 |
`\laser[color]{tikz path}` |
The command \laser
draws the laser beam given by with color color
(default: red). The reference for coordinates is the bottom left corner of the cell.
1 |
\laser[green]{(1,2)--(2,3)--(1,4)} |
You should consider using this command in the environment puzzlebackground
.
tikzpath
\tikzpath{column}{row}{csv list}
With the \tikzpath
command, you can easily construct a \tikz
path. You just need to define a starting point (bottom left corner) and a csv list
with direction indicators relative to the current position.
1 2 3 |
7: up left 8: up 9: up right 4: left 5: no change 6: right 1: down left 2: down 3: down right |
1 |
\framearea{green}{\tikzpath{2}{2}{8,6,2,4}} |
This command will frame grid cell (2,2)
green.
Presentation
definecounterstyle
The command allows you to define your own styles. For example, the style left
is defined as follows:
1 2 3 4 5 6 |
\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} } |
To typeset the counter into the margin we use the command \marginnote
. We need to use the command \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 \puzzlecounter
in a \tikz
node with a vertical offset set with the option cvoffset
.
puzzlecounter
\puzzlecounter
The command provides the counter in textual form to use it for example in \definecounterstyle
.
titleformat
\titleformat{format}
With the command \titleformat
, you can define the format of the title. By default, the definition is as follows:
\titleformat{\centering\Large\color{blue}}
Miscellaneous
laserbeamsetup
\laserbeamsetup{options}
With the command laserbeamsetup
you can reset the options with global scope.
setpuzzlecounter
\setpuzzlecounter{number}
With the command \setpuzzlecounter
, you can reset the puzzle counter, for example before the solutions.
Examples & Solutions
You can download application examples and their solutions from the project page. The puzzles are originally licensed under
CC-BY-NC-SA.