![在命令中定义参数](https://linux22.com/image/444790/%E5%9C%A8%E5%91%BD%E4%BB%A4%E4%B8%AD%E5%AE%9A%E4%B9%89%E5%8F%82%E6%95%B0.png)
我正在使用skak
和xskak
包来记录国际象棋的笔记。每次我需要打印棋盘时,我都必须手动设置可选参数,如下面的代码:
\chessboard[
%--> ADD PIECES TO THE BOARD:
setwhite={Kd3, Bd4},
addblack={Ke8, Pe2},
%--> ARROW STYLE:
pgfstyle=straightmove,
arrow=stealth,
linewidth=3pt,
padding=1ex,
color=red!75,
shortenstart=1ex,
%--> DRAW THE ARROWS
markmoves={d3-e2},
showmover=false,
%--> HIGHLIGHT STYLE:
color=green!50,
pgfstyle=color,
opacity=.3,
%--> HIGHLIGHT SQUARES:
colorbackfields={e4, e3, e2, d2, c2, c3, c4},
]
我的问题是:如何使用其中一些参数定义命令?*
例如,假设我想创建这样的命令:
\newcommand{\ArrowStyle}{%
pgfstyle=straightmove,
arrow=stealth,
linewidth=3pt,
padding=1ex,
color=red,
shortenstart=1ex}
...这样我就可以简单地写:
\chessboard[
%--> ADD PIECES TO THE BOARD:
setwhite={Kd3, Bd4},
addblack={Ke8, Pe2},
%--> ARROW STYLE:
\ArrowStyle
%--> DRAW THE ARROWS
markmoves={d3-e2},
showmover=false,
%--> HIGHLIGHT STYLE:
color=green!50,
pgfstyle=color,
opacity=.3,
%--> HIGHLIGHT SQUARES:
colorbackfields={e4, e3, e2, d2, c2, c3, c4},
]
但是,这不起作用。有人能帮助我吗?谢谢!
答案1
你可以定义一种风格,参见棋盘的文档:
\documentclass{article}
\usepackage{chessboard}
\begin{document}
\storechessboardstyle{arrowstyle}{%
pgfstyle=straightmove,
arrow=stealth,
linewidth=3pt,
padding=1ex,
color=red,
shortenstart=1ex}
\chessboard[
%--> ADD PIECES TO THE BOARD:
setwhite={Kd3, Bd4},
addblack={Ke8, Pe2},
%--> ARROW STYLE:
style=arrowstyle,
%--> DRAW THE ARROWS
markmoves={d3-e2},
showmover=false,
%--> HIGHLIGHT STYLE:
color=green!50,
pgfstyle=color,
opacity=.3,
%--> HIGHLIGHT SQUARES:
colorbackfields={e4, e3, e2, d2, c2, c3, c4},
]
\end{document}