如何在不同框架的 LaTeX 投影机中添加棋盘图 \xskakloop?

如何在不同框架的 LaTeX 投影机中添加棋盘图 \xskakloop?
\documentclass[aspectratio=169]{beamer}
\hypersetup{pdfpagemode=FullScreen}
\renewcommand{\familydefault}{\rmdefault} 
\usepackage{tikz}

\usepackage[LSB2,LSBC4,T1]{fontenc} % use fontenc before chessboard
\usepackage{skak,xskak,chessboard,texmate}
\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{frame}
\newchessgame
\mainline{1. e4 d5}\\  
\setchessboard{boardfontsize=19.7pt,labelfontsize=12pt,labelfont=\rmfamily,moverstyle=circle,restorefen=current}

 \setboardfontcolors{blackfieldmask=green!60}
 \xskakloop{%
 \getmovestyle{\xskakget{piecechar}}%
 \chessboard[boardfontencoding=LSBC4,  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}
\xskakget{lan}
\xskakget{nag} 
\par            
 }
\end{frame}
\end{document} 

当我使用 \xskakloop 按顺序排版棋图时,它会向下移动而不是嵌入到 LaTeX 投影机的不同框架中。

在此处输入图片描述

答案1

\documentclass[aspectratio=169]{beamer}
\hypersetup{pdfpagemode=FullScreen}
\renewcommand{\familydefault}{\rmdefault}
\usepackage{tikz}

\usepackage[LSB2,LSBC4,T1]{fontenc} % use fontenc before chessboard
\usepackage{skak,xskak,chessboard,texmate}
\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}}}}%
\newcounter{chessmoves} %<--------------------

\begin{frame}
  \newchessgame
  \mainline{1. e4 d5}\\
  \setchessboard{
    boardfontsize=19.7pt,
    labelfontsize=12pt,
    labelfont=\rmfamily,
    moverstyle=circle,
    restorefen=current
  }

  \setboardfontcolors{blackfieldmask=green!60}
  \setcounter{chessmoves}{0}%
  \xskakloop{%
    \getmovestyle{\xskakget{piecechar}}%
    \refstepcounter{chessmoves}% <----------------
    \only<\arabic{chessmoves}>{% <----------------
      \chessboard[
          boardfontencoding=LSBC4,
          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}
      \xskakget{lan}
      \xskakget{nag}
      \par
    }%<----------------------------
  }
\end{frame}
\end{document}

相关内容