1

Consider the following example by 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}

This printes either the file in which the pawn is located or the pawn symbol.

Then I have another piece of code from 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}

How do I combine the two code snippets in a command \bonde so that it printes either the file in which the pawn is located or the pawn symbol in either black or white depending on whether I use \usesymfigblack or not? (Please let me know if the question doesn't make sense.)

1 Answers1

1

I still don't understand why you want a command that prints sometimes a file and sometimes a figurine -- imho this will only lead to confusing code later -- but beside this you can test against a list of languages:

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

enter image description here

Ulrike Fischer
  • 327,261