我尝试使用xsaveboxes
:markmoves
\xsbox{list1}{a8-e4}
\chessboard[tinyboard,
markmoves=\xusebox{list1}% <--- error
]
这样我就可以使用编号框了。
但这不起作用,我该怎么办?
\documentclass{article}
\usepackage{xsavebox}
\usepackage{xskak}
\usepackage{chessboard}
\setchessboard{showmover=false, pgfstyle=straightmove, color=red,}
\begin{document}
\newchessgame[id=A, setwhite={Ba8}]
\mainline{1. Be4 ... 2. Bh7 ... 3. Bg8 ... 4. Ba2 ...}
\section{def works}
\def\List{a8-e4}
List: \List
\chessboard[tinyboard, markmoves=\List]
\section{xsavebox works not}
\xsbox{list1}{a8-e4}
list1: \xusebox{list1}
\chessboard[tinyboard,
%markmoves=\xusebox{list1}<----- error!
]
\end{document}
答案1
标准 LaTeX 保存框和使用该xsavebox
包创建的保存框都存储了排版好的材料,以便以后重新插入到文档中。它们不能用于存储用作命令参数的逐字文本。为了解决这个问题,可以使用相同的名称以两种方式保存移动:
\documentclass{article}
\usepackage{xsavebox}
\usepackage{xskak}
\usepackage{chessboard}
\setchessboard{showmover=false, pgfstyle=straightmove, color=red,}
\makeatletter
\def\mynamedef#1#2{\expandafter\xdef\csname#1\endcsname{#2}}
\let\mynameuse\@nameuse
\makeatother
\begin{document}
\newchessgame[id=A, setwhite={Ba8}]
\mainline{1. Be4 ... 2. Bh7 ... 3. Bg8 ... 4. Ba2 ...}
\section{xsavebox and namedef}
%%%%%%%%%%%%%%%%%%%%%%%%
\mynamedef{list1}{a8-e4}
\xsbox{list1}{a8-e4}
%%%%%%%%%%%%%%%%%%%%%%%%
list1: \xusebox{list1}
\chessboard[tinyboard,
markmoves=\mynameuse{list1}
]
\end{document}
但毕竟,我只会使用\mynamedef
来逐字存储文本,并在需要时将其插入以进行排版或作为命令参数。在目前的情况下,使用保存框可能有点太多了:
\documentclass{article}
\usepackage{xskak}
\usepackage{chessboard}
\setchessboard{showmover=false, pgfstyle=straightmove, color=red,}
\makeatletter
\def\mynamedef#1#2{\expandafter\xdef\csname#1\endcsname{#2}}
\let\mynameuse\@nameuse
\makeatother
\begin{document}
\newchessgame[id=A, setwhite={Ba8}]
\mainline{1. Be4 ... 2. Bh7 ... 3. Bg8 ... 4. Ba2 ...}
\section{namedef alone}
\mynamedef{List 1}{a8-e4}
List 1: \mynameuse{List 1}
\chessboard[tinyboard,
markmoves=\mynameuse{List 1}
]
\end{document}