1

Consider Ulrike Fischer'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
  \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}

\Huge
\svendusefigurine
\svendusefigblack
\textsymfigsymbol{Q}\capturesymbol\bonde{e}

\svendusefigwhite
\textsymfigsymbol{Q}\capturesymbol\bonde{e}

\end{document}

output

There is more whitespace around the black pieces than around the white pieces. Can the whitespace around the black pieces be cropped so that they have the same amount as the white pieces?

1 Answers1

2

The black pieces are faked from a board font. board font chars are quadratic, this means they have not only a different baseline but also different side bearings than the figurines. For the pawn this more obvious than for the other chars. You can measure the white pawn and use this width- You can use \vphantom to set the height and depth.

\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
\newlength\svendfigwidthA
  \newcommand*\cfss@king@@LSBblack  {\raisebox{-0.31ex}{\setboardfontsize{\f@size}%
    \settowidth\svendfigwidthA{\symking}%
    \makebox[\svendfigwidthA]{\BlackKingOnWhite}}}
\newlength\svendfigwidthB
  \newcommand*\cfss@queen@@LSBblack {\raisebox{-0.37ex}{\setboardfontsize{\f@size}%
    \settowidth\svendfigwidthB{\symqueen}%
    \makebox[\svendfigwidthB]{\BlackQueenOnWhite}}}
\newlength\svendfigwidthC
  \newcommand*\cfss@rook@@LSBblack  {\raisebox{-0.26ex}{\setboardfontsize{\f@size}%
    \settowidth\svendfigwidthC{\symrook}%
    \makebox[\svendfigwidthC]{\BlackRookOnWhite}}}
\newlength\svendfigwidthD
  \newcommand*\cfss@bishop@@LSBblack{\raisebox{-0.35ex}{\setboardfontsize{\f@size}%
    \settowidth\svendfigwidthD{\symbishop}%
    \makebox[\svendfigwidthD]{\BlackBishopOnWhite}}}
\newlength\svendfigwidthE
  \newcommand*\cfss@knight@@LSBblack{\raisebox{-0.30ex}{\setboardfontsize{\f@size}%
    \settowidth\svendfigwidthE{\sympknight}%
    \makebox[\svendfigwidthE]{\BlackKnightOnWhite}}}
\newlength\svendfigwidthF
  \newcommand*\cfss@pawn@@LSBblack  {%
   \vphantom{\sympawn}%
   \raisebox{-0.31ex}[0pt][0pt]{%
    \setboardfontsize{\f@size}%
    \settowidth\svendfigwidthF{\sympawn}%
    \makebox[\svendfigwidthF]{\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}
\makeatletter \Huge
\fbox{\setboardfontsize{\f@size}\BlackPawnOnWhite} \fbox{\sympawn} \fbox{\cfss@pawn@@LSBblack}


\svendusefigurine
\svendusefigblack
\textsymfigsymbol{Q}\capturesymbol\bonde{e}


\svendusefigwhite
\textsymfigsymbol{Q}\capturesymbol\bonde{e}

\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • Thanks you, Ulrike! You are my LaTeX chess notation hero! :-) – Svend Tveskæg Dec 05 '17 at 09:07
  • 1
    Could you retag some of your question? Quite a number are not xskak but chessfss questions. And it would be good if the general tag "chess" is everywhere. – Ulrike Fischer Dec 05 '17 at 11:24
  • Sure. I think I got it right now regarding the tags. – Svend Tveskæg Dec 05 '17 at 11:55
  • Hmm! Can I also set the height of the pieces to be the same? (It has to be the height of the tallest piece.) Then the linespread will be consistent. – Svend Tveskæg Dec 05 '17 at 14:13
  • 1
    \raisebox has two optional argument to set the height and depth of the resulting box. – Ulrike Fischer Dec 05 '17 at 14:15
  • The spacing is still wrong (Test: `\begin{document}

    \Huge \svendusefigurine \svendusefigblack \textsymfigsymbol{B}\capturesymbol\bonde{e}

    \svendusefigwhite \textsymfigsymbol{B}\capturesymbol\bonde{e}

    \end{document}`) Also, can I make you implement the height argument -- something is wrong in my approach.

    – Svend Tveskæg Dec 05 '17 at 17:05
  • 1
    Did you apply the code also for the other pieces? – Ulrike Fischer Dec 05 '17 at 23:02
  • Do'h! No I didn't. That was embarrassing. (I've added the code to your answer.) Can I make you fix the height issue? (Test: \newlength\widthKing \newlength\heightKing \newcommand*\cfss@king@@LSBblack {\raisebox{-0.31ex}{\setboardfontsize{\f@size}% \settowidth\widthKing{\symking}% \settoheight\heightKing{\symking}% \makebox(\heightKing,\widthKing){\BlackKingOnWhite}}} doesn't work.) – Svend Tveskæg Dec 06 '17 at 09:15
  • 1
    Try regarding the height/depth {\vphantom{\sympawn}\raisebox{-0.31.ex}[0pt][0pt]{....}}` (naturally with the correct figurine) – Ulrike Fischer Dec 06 '17 at 09:17
  • I'm not sure I follow you. :-( Any chance I can make you fix the height issue for one of the pieces? – Svend Tveskæg Dec 06 '17 at 09:26
  • 1
    I edited the pawn. – Ulrike Fischer Dec 06 '17 at 09:33