CTAN
Bitbucket
jkLaTeX
TeXdoku
——
The TeX community aggregator
- An error occurred while fetching this feed: http://www.texample.net/feeds/community/
Impressum / Datenschutzerklärung
CTAN
Bitbucket
jkLaTeX
TeXdoku
——
The TeX community aggregator
Impressum / Datenschutzerklärung
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. Here’s a little self-explanatory example:
\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{1cm}
\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}
rows (5)
defines the number of rows in the grid
columns (5)
specifies the number of columns in the grid
width (6cm)
sets the width of the minipage, in which the grid is typeset
scale (1)
scales the size of the grid in the minipage
fontsize (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, Huge
title ()
sets the title of a puzzle
titleindent (0.75cm)
defines the indent of the title
titlewidth (5.15cm)
specifies the width of the box the title is set in
sbindent (0.75cm)
defines the indent of the ship box below the grid
sbwidth (5.15cm)
specifies the width of the minipage, in which the ships are typeset
sbshipscale (1)
scales the size of the ships in the ship box
shipcolor (green)
sets the color of the ship segments
bgcolor ()
sets the background color of the grid
counterstyle (none)
defines the counter style. Predefined styles: none, left, right
cvoffset (-38pt)
sets the vertical offset of the counters in the margin
\begin{battleship}
\end{battleship}
The environment 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 that you can fill with ships using other commands.
\placeship{direction}{column}{row}{lenght}
With the command \placeship
you can place complete ships in the grid. It expects the specification of the {direction}
as horizontal (H) or vertical (V). Furthermore, it requires the starting coordinates {column}{row}
and the {length}
of the ship.
\placesegment{column}{row}{ship segment}
The command \placesegment
is used for the placement of ship segments in the grid. In the mandatory argument {ship segment}
, you can use the following commands:
\Ship
\ShipC
\ShipB
\ShipT
\ShipL
\ShipR
The command \ship
was replaced by the command \placesegment
. The command is deprecated and should not be used longer. It may still be used, but it is not recommended.
\placewater{column}{row}
With the command \placewater
you can place water markers in the grid.
\placeisland{column}{row}
With the command \placeisland
you can place islands in the grid. The island outlines are created randomly.
\shipH{csv list}
The command \shipH
typesets the horizontal numbers above the grid. It expects a comma-separated list as an argument.
\shipV{csv list}
The command \shipV
typesets the vertical numbers beside the grid. It also expects a comma separated list.
\shipbox{csv list}
The command \shipbox
defines the number and size of the ships, which are typeset under the grid.
The command allows you to define your own styles. For example, the style left
is defined as follows:
\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
The command provides the counter in textual form to use it for example in \definecounterstyle
.
\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}}
\battleshipsetup{options}
With the command \battleshipsetup
you can reset the options with global scope.
\classicgame{csv list}
The command \classicgame
typesets a game sheet for playing classic Battleship. It expects a comma separated list with the number and sizes of the ships.
setpuzzlecounter{number}
With the command \setpuzzlecounter
, you can reset the puzzle counter, for example before the solutions.
You can download application examples and their solutions from the project page. The puzzles are originally licensed under CC-BY-NC-SA.
You can also download a game sheet for playing the classic Battleship.