在 xskak 循环中添加注释并显示符号

在 xskak 循环中添加注释并显示符号

如何使用以下代码添加注释并显示每一步的移动符号

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

答案1

我确实有重复的感觉。您在前面的例子中已经说明了一切。

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

在此处输入图片描述

相关内容