8

How can I draw arrows on a chess game?

For example, if the game starts with 1. e4 ..., I want to draw a black arrow from e2 to e4 to show the movement, and, in the same diagram, two red arrows from e4 to f5, and another from e4 to d5, to show the pawn attacking the squares.

Following game works for me. I'd like to find additional highlighting possibilities. For example, for educational purposes, an arrow between the knight in f6 to the squares being attacked by it.

\documentclass[a4paper,10pt]{article}
\usepackage{skak}
\usepackage{xskak}


\begin{document}

\newgame
\mainline{1. e4 e5 2. Nf3 Bc5}
\chessboard

\end{document}
5
  • 1
    Your question leaves all the effort to our community, even typing the essentials of a TeX document such as \documentclass{}...\begin{document} etc. As it is, most of our users will be very reluctant to touch your question, and you are left to the mercy of our procrastination team who are very few in number and very picky about selecting questions. You can improve your question by adding a minimal working example (MWE) that more users can copy/paste onto their systems to work on. If no hero takes the challenge we might have to close your question.
    – Adam Liter
    Mar 14 '14 at 21:20
  • Also, welcome to TeX.SX!
    – Adam Liter
    Mar 14 '14 at 21:20
  • @Adam: done (I think). Mar 14 '14 at 21:29
  • 1
    Read the documentation of the chessboard package. Mar 14 '14 at 23:08
  • Especially page 29. Mar 15 '14 at 2:06
7

I followed the documentation of the xskak package, especially pages 35 and 36, and this is what I've got.

%! *latex mal-chess.tex
\documentclass[a4paper,10pt]{article}
\pagestyle{empty}\parindent=0pt
\usepackage{xskak}
%\usepackage{chessboard}
\begin{document}
\newcommand\getmovestyle[1]{%
\ifthenelse
  {\equal{#1}{N}}%knight move
  {\def\mymovestyle{[clockwise=false,style=knight]curvemove}}%
  {\ifthenelse
    {\equal{#1}{}}% castling
    {\def\mymovestyle{curvemove}}%
    {\def\mymovestyle{straightmove}}}}%
\newchessgame
\hidemoves{1. e4 e5 2. Nf3 Bc5}%
%\chessboard[setfen=\xskakgetgame{initfen}]% Show me the empty board.
\xskakloop{%
\getmovestyle{\xskakget{piecechar}}%
\chessboard[pgfstyle=\mymovestyle, color=blue,
  markmoves=\xskakget{move}, pgfshortenend=0.3em, arrow=to, coloremph, color=red, markstyle=circle, markfield=\xskakget{movefrom},
  emphfields=\xskakget{moveto}, setfen=\xskakget{nextfen}]
  }% End of \xskakloop...
\end{document}

mwe

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.