3

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!

1
  • 1
    It would be easier to help you if you provided a small minimal document in which we can test things and we could play with. (E.g., though I've never used xskak so have no idea about its interfaces I'm rather good at programming (and sometimes I even skim over manuals), so I'm pretty I could've provided an answer -- this is just a general advice on how to get (better) answers earlier). Oh, and ignore @UlrikeFischer, creating the package to be able to answer questions is cheating!
    – Skillmon
    Jan 16 at 22:07

1 Answer 1

6

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.