考虑以下Ulrike Fischer 的示例:
\documentclass{article}
\usepackage{chessfss}
\makeatletter
\def\testchessfiglanguage{\cfss@textfiglanguage}
\newcommand*\bonde[1]{\ifx\cfss@figlanguage\testchessfiglanguage #1\else\figsymbol{p}\fi}
\makeatletter
\begin{document}
\bonde{e} \usetextfig \bonde{e}
\end{document}
这将打印棋子所在的文件或棋子符号。
然后我还有另一块来自 Ulrike 的代码:
\documentclass{article}
\usepackage{xskak}
\usesymfig
\makeatletter
\newcommand*\cfss@king@@LSBblack {\raisebox{-0.31ex}{\setboardfontsize{\f@size}\BlackKingOnWhite}}
\newcommand*\cfss@queen@@LSBblack {\raisebox{-0.37ex}{\setboardfontsize{\f@size}\BlackQueenOnWhite}}
\newcommand*\cfss@rook@@LSBblack {\raisebox{-0.26ex}{\setboardfontsize{\f@size}\BlackRookOnWhite}}
\newcommand*\cfss@bishop@@LSBblack{\raisebox{-0.35ex}{\setboardfontsize{\f@size}\BlackBishopOnWhite}}
\newcommand*\cfss@knight@@LSBblack{\raisebox{-0.30ex}{\setboardfontsize{\f@size}\BlackKnightOnWhite}}
\newcommand*\cfss@pawn@@LSBblack {\raisebox{-0.31ex}{\setboardfontsize{\f@size}\BlackPawnOnWhite}}
\newcommand\usesymfigblack{%
\def\cfss@figlanguage{@LSBblack}}
\makeatother
\begin{document}
\usetextfig
\textsymfigsymbol{Q}
\usesymfig
\textsymfigsymbol{Q}
\usesymfigblack
\textsymfigsymbol{Q}
\footnotesize
\usetextfig
\textsymfigsymbol{Q}
\usesymfig
\textsymfigsymbol{Q}
\usesymfigblack
\textsymfigsymbol{Q}
\end{document}
如何在命令中组合这两个代码片段\bonde
,以便根据我是否使用来打印棋子所在的文件或黑色或白色的棋子符号\usesymfigblack
?(如果问题没有意义,请告诉我。)
答案1
我仍然不明白为什么你想要一个有时打印文件有时打印小雕像的命令 - 在我看来这只会导致以后代码混乱 - 但除此之外你还可以针对语言列表进行测试:
\documentclass{article}
\usepackage{xskak}
\usepackage{expl3}
\ExplSyntaxOn\makeatletter
\clist_const:Nn \c_svend_figlanguages_clist {@LSB , @LSBblack}
\cs_generate_variant:Nn \clist_if_in:NnTF {NxTF}
\newcommand*\bonde[1]
{
\clist_if_in:NxTF \c_svend_figlanguages_clist { \cfss@figlanguage }
{ \textsymfigsymbol {p} } { #1 }
}
\ExplSyntaxOff\makeatother
\usesymfig
\makeatletter
\newcommand*\cfss@king@@LSBblack {\raisebox{-0.31ex}{\setboardfontsize{\f@size}\BlackKingOnWhite}}
\newcommand*\cfss@queen@@LSBblack {\raisebox{-0.37ex}{\setboardfontsize{\f@size}\BlackQueenOnWhite}}
\newcommand*\cfss@rook@@LSBblack {\raisebox{-0.26ex}{\setboardfontsize{\f@size}\BlackRookOnWhite}}
\newcommand*\cfss@bishop@@LSBblack{\raisebox{-0.35ex}{\setboardfontsize{\f@size}\BlackBishopOnWhite}}
\newcommand*\cfss@knight@@LSBblack{\raisebox{-0.30ex}{\setboardfontsize{\f@size}\BlackKnightOnWhite}}
\newcommand*\cfss@pawn@@LSBblack {\raisebox{-0.31ex}{\setboardfontsize{\f@size}\BlackPawnOnWhite}}
\newcommand\usesymfigblack{%
\def\cfss@figlanguage{@LSBblack}}
\makeatother
\begin{document}
\usetextfig
\textsymfigsymbol{Q}, \bonde{e} --
\usesymfig
\textsymfigsymbol{Q}, \bonde{e} --
\usesymfigblack
\textsymfigsymbol{Q}, \bonde{e}
\footnotesize
\usetextfig
\textsymfigsymbol{Q}, \bonde{e} --
\usesymfig
\textsymfigsymbol{Q}, \bonde{e} --
\usesymfigblack
\textsymfigsymbol{Q}, \bonde{e}
\end{document}