1

How to add comments and display movement notations for each move, using the following code

\documentclass{beamer}
\usepackage{xskak, chessboard}
\setbeamertemplate{navigation symbols}{}

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

\begin{center}
\[\newchessgame\]
\hidemoves{1.d4 Nf6 2.c4 g6 3.Nc3 Bg7}
\xskakloop{%
\getmovestyle{\xskakget{piecechar}}%
\chessboard[normalboard,
 pgfstyle=\mymovestyle, color=blue!50,
  markmoves=\xskakget{move}, pgfshortenend=0.3em, arrow=to,     coloremph, color=red!50, markstyle=circle, markfield=\xskakget{movefrom},
  emphfields=\xskakget{moveto}, setfen=\xskakget{nextfen}]
  }% End of \xskakloop...
\end{center}
\end{document}
Hany
  • 4,709

1 Answers1

4

I do have the impression to repeat myself. You already had everything in your previous examples.

\documentclass{beamer}
\usepackage{xskak, chessboard}
\setbeamertemplate{navigation symbols}{}
\makeatletter
\providecommand\xskak@beforecomment{} %ups a bug, definition is missing
\makeatother
\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}}}}%

\begin{center}
\newchessgame %don't add math here.
\hidemoves{1.d4 \xskakcomment{A good opening} Nf6 2.c4 g6 \xskakcomment{King's  indian}  3.Nc3 Bg7}
\xskakloop{%
\getmovestyle{\xskakget{piecechar}}%
\chessboard[normalboard,
 pgfstyle=\mymovestyle, color=blue!50,
  markmoves=\xskakget{move}, pgfshortenend=0.3em, arrow=to,     coloremph, color=red!50, markstyle=circle, markfield=\xskakget{movefrom},
  emphfields=\xskakget{moveto}, setfen=\xskakget{nextfen}]\\
  \xskakget{opennr}%print the move number
  \xskakget{lan} %print the move
  \xskakget{nag} % print the comment
  \par           % new paragraph 
  }% End of \xskakloop...
\end{center}
\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • The problem was in using math in the following line \newchessgame %don't add math here.

    and putting the \makeatletter command in the preamble.

    Thank you very much for your patience.

    – Hany Aug 04 '17 at 14:35