我使用该软件包设计了海军战斗网格logicpuzzle
。我想做一些修改,你能帮我吗?
我想将 ABCDE 字母移至网格的底部。
我希望能够在绿色摩托艇里面写一封信。
\documentclass{standalone}
\usepackage{logicpuzzle}
\let\puzzletitleformat\titleformat
\let\titleformat\relax
\usepackage{titlesec}
\begin{document}
% sffamily
\tikzset{every node/.style={font=\sffamily}}
% use scale and fontsize options to change size
%\begin{center}
\begin{battleship}
\placesegment{5}{2}{\ShipR}
\placesegment{1}{5}{\ShipL}
\placesegment{1}{1}{\ShipR}
\placesegment{4}{4}{\ShipL}
\placesegment{2}{3}{\ShipL}
\shipH{A,B,C,D,E}
\shipV{1,2,3,4,5}
\end{battleship}
\end{document}
答案1
Bobyandbob 在他的评论中回答了第一个问题,我在下面的代码中实现了这一点。
要将字母放在\ShipL
/内\ShipR
,只需在其后添加第二个具有相同坐标的字母即可\placesegment
。例如,
\placesegment{5}{2}{\ShipR}
\placesegment{5}{2}{a}
会将 置于a
之上\ShipR
。如果您想要更简单的语法,例如\ShipR[a]
,您可以重新定义\ShipR
/\ShipL
宏,例如如以下代码所示。
\documentclass{standalone}
\usepackage{logicpuzzle}
\makeatletter
\renewcommand*\shipH[1]{%
\LP@setrowcontents{#1}{1}{0}%
}%
\renewcommand*\ShipL[1][]{%
\tikz[scale=\LP@BS@scale]
\draw[scale=.36,fill=\LP@BS@shipcolor,
path picture={\node at (path picture bounding box.center) {#1};}
](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}%
\renewcommand*\ShipR[1][]{%
\tikz[scale=\LP@BS@scale]
\draw[scale=.36,fill=\LP@BS@shipcolor,
path picture={\node at (path picture bounding box.center) {#1};}
](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}%
\makeatother
\let\puzzletitleformat\titleformat
\let\titleformat\relax
\usepackage{titlesec}
\begin{document}
% sffamily
\tikzset{every node/.style={font=\sffamily}}
% use scale and fontsize options to change size
%\begin{center}
\begin{battleship}
\placesegment{5}{2}{\ShipR[A]}
\placesegment{1}{5}{\ShipL[B]}
\placesegment{1}{1}{\ShipR[C]}
\placesegment{4}{4}{\ShipL[D]}
\placesegment{2}{3}{\ShipL[E]}
\shipH{A,B,C,D,E}
\shipV{1,2,3,4,5}
\end{battleship}
\end{document}
答案2
另外,您也可以创建\ShipLmod{Input Text}
和\ShipRmod{Input Text}
(使用\renewcommand*
)。文本居中并不完美(也许我们可以(一起)找到更好的解决方案)。
-1.将 ABCDE 字母移动到网格底部:
\makeatletter
\renewcommand*\shipH[1]%
{%
\LP@setrowcontents{#1}{1}{0}%
}%
\makeatother
-\ShipLmod
2.在绿色摩托艇里写一封信:\ShipRmod
\makeatletter
\newcommand*\ShipRmod[1]{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1) node[xshift=-0.05cm,yshift=-0.37cm] {#1};}%
\makeatother
\makeatletter
\newcommand*\ShipLmod[1]{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1) node[xshift=0.05cm,yshift=-0.37cm] {#1};}%
\makeatother
梅威瑟:
\documentclass{standalone}
\usepackage{logicpuzzle}
\let\puzzletitleformat\titleformat
\let\titleformat\relax
\usepackage{titlesec}
\makeatletter
\renewcommand*\shipH[1]%
{%
\LP@setrowcontents{#1}{1}{0}%
}%
\makeatother
\makeatletter
\newcommand*\ShipRmod[1]{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1) node[xshift=-0.05cm,yshift=-0.37cm] {#1};}%
\makeatother
\makeatletter
\newcommand*\ShipLmod[1]{\tikz[scale=\LP@BS@scale]\draw[scale=.36,fill=\LP@BS@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1) node[xshift=0.05cm,yshift=-0.37cm] {#1};}%
\makeatother
\begin{document}
% sffamily
\tikzset{every node/.style={font=\sffamily}}
\begin{battleship}
\placesegment{5}{2}{\ShipR}
\placesegment{1}{5}{\ShipL}
\placesegment{1}{1}{\ShipRmod{A}}
\placesegment{4}{4}{\ShipLmod{B}}
\placesegment{2}{3}{\ShipL}
\shipH{A,B,C,D,E}
\shipV{1,2,3,4,5}
\end{battleship}
\end{document}