Define arguments in a command

argumentsmacrosoptional argumentsskakxskak

I am using the skak and xskak packages to make notes about chess. Everytime I need to print a board, I have to manually set the optional parameters, like the code below:

\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},
        ]

My question is: how to define a command with some of these arguments?*

For example, say that I would like to create a command like this:

\newcommand{\ArrowStyle}{%
    pgfstyle=straightmove,
    arrow=stealth,
    linewidth=3pt,
    padding=1ex,
    color=red,
    shortenstart=1ex}

… so that I could simply write:

\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},
        ]

However, this doesn't work. Can anyone help me? Thank you!

Best Answer

You can define a style, see the documentation of chessboard:

\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}

enter image description here