2

This is a follow-up question to the one here.

Using Ulrike's code from here,

\documentclass{article}

\usepackage{xskak}
\usepackage{expl3}

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

I would like the \usetextfig switch to "overrule" \usesymfigblack when they are both used. By this I mean that if I use \usetextfig in the preamble and

\usesymfigblack
\textsymfigsymbol{Q}, \bonde{e}

somewhere between \begin{document} and \end{document}, then the output should be a Q and an e. The reason for this is that I use \usesymfigblack multiple times in my document to indicate black pieces via figurines but I would like to globally switch between algebraic notation and figurine algebraic notation.

How do I achieve this?

1 Answers1

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


\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\svendusefigurine{%
\def\svend@blacklanguage{@LSBblack}
\def\svend@whitelanguage{@LSB}}

\newcommand\svendusealgebraic{%
  \def\svend@blacklanguage{english}% change if needed
  \def\svend@whitelanguage{english}%
  }

\newcommand\svendusefigblack{%
 \def\cfss@figlanguage{\svend@blacklanguage}}
\newcommand\svendusefigwhite{%
 \def\cfss@figlanguage{\svend@whitelanguage}}

\newcommand\svendfigblack[1]{%
 \csname cfss@\csname cfss@input@#1@english\endcsname @\svend@blacklanguage\endcsname}

\newcommand\svendfigwhite[1]{%
 \csname cfss@\csname cfss@input@#1@english\endcsname @\svend@whitelanguage\endcsname}


\makeatother

\svendusealgebraic

\begin{document}

\svendusealgebraic
\svendusefigblack
\textsymfigsymbol{Q}, \bonde{e} --
\svendusefigwhite
\textsymfigsymbol{Q}, \bonde{e} --
\svendfigwhite{Q}, \svendfigblack{Q}

\svendusefigurine
\svendusefigblack
\textsymfigsymbol{Q}, \bonde{e} --
\svendusefigwhite
\textsymfigsymbol{Q}, \bonde{e} --
\svendfigwhite{Q}, \svendfigblack{Q}   

\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • Hmm! Can I somehow use \bonde{} as an argument to \svendfigwhite{}/\svendfigblack{}, e.g., \svendfigwhite{\bonde{}}? (That doesn't work for me at the moment.) – Svend Tveskæg Dec 04 '17 at 22:33
  • 1
    Perhaps,but imho it would be easier to extend the input so that \svenfigwhite{a}, \svenfigwhite{b} etc works. – Ulrike Fischer Dec 04 '17 at 22:38
  • Okay, but if possible I would really like to use \svendfigwhite{\bonde{}} since I would have to change a lot in various documents if I should use, say, \svenfigwhite{b}. – Svend Tveskæg Dec 04 '17 at 22:48