\printchessgame 参数问题

\printchessgame 参数问题

\printchessgame 采用参数初始化移动标识停止移动标识。如果我直接输入 ID,一切都会正常。但是,如果我设置stopmoveid=\xskakgetgame{lastmoveid}我收到一个错误。

    \documentclass{article}
    \usepackage[german, ngerman]{babel}
    \usepackage[latin1]{inputenc}
    \usepackage{xskak}

\begin{document}        
    \newchessgame[id=demo]

    \hidemoves{%
    1.d4 Nf6 
    2.c4 g6 
    3.Nc3 Bg7 
    4. Nd5 d6 
    }

% Works well
\printchessgame[initmoveid=2w, stopmoveid=4b]

\typeout{Last move id = \xskakgetgame{lastmoveid}}

% Replace 4b by \xskakgetgame{lastmoveid} generates error
\printchessgame[initmoveid=2w, stopmoveid=\xskakgetgame{lastmoveid}]

\end{document}

我该如何解决这个问题?

答案1

添加战略性放置\expandafter

    \documentclass{article}
    \usepackage[german, ngerman]{babel}
    \usepackage[latin1]{inputenc}
    \usepackage{xskak}

\begin{document}        
    \newchessgame[id=demo]

    \hidemoves{%
    1.d4 Nf6 
    2.c4 g6 
    3.Nc3 Bg7 
    4. Nd5 d6 
    }

% Works well
\printchessgame[initmoveid=2w, stopmoveid=4b]

\typeout{Last move id = \xskakgetgame{lastmoveid}}

% Replace 4b by \xskakgetgame{lastmoveid} generates error
\printchessgame[initmoveid=2w, stopmoveid\expandafter=\xskakgetgame{lastmoveid}]

\end{document}

在此处输入图片描述

相关内容