2

I am modifying the Latex output from Scid vs PC. In doing it, I am applying Fischer's solution of xskakloop into making the game displaying move by move.

Here's my code for Morphy's famous game.

I can not figure out why the 1st display diagram is not aligned with the other diagram.

I also like to know how I can highlight the to square. For example, 1e4. I want the e4 square to be highlighted like in yellow.

Output

\documentclass[10pt,DIV=20]{scrreprt}
% This is a LaTeX file generated by Scid.
% You must have the skak, KOMAScript and pstricks packages installed to typeset this file.

\usepackage{scrpage2}
\usepackage{charter}
\usepackage[svgnames]{xcolor}
\usepackage{xskak}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{latexsym}
\usepackage{pstricks-add}
\usepackage{tabularx}
\usepackage{multicol}
\pagestyle{empty}
\usepackage{titlesec}
\usepackage[LSB2,LSBC4,T1]{fontenc} % use fontenc before chessboard
\usepackage{skak, xskak,chessboard}


\newcommand\getmovestyle[1]{
\ifthenelse
  {\equal{#1}{N}}
  {\def\mymovestyle{[clockwise=false,style=knight]curvemove}}
  {\ifthenelse
    {\equal{#1}{}}
    {\def\mymovestyle{curvemove}}
    {\def\mymovestyle{straightmove}}}}

\newcommand\mychessloop[1][]{%
 \xskakloop[step=1]{%
\getmovestyle{\xskakget{piecechar}}%
\begin{tabular}{c}
\chessboard[boardfontfamily=alphadia,
 boardfontencoding=LSBC4,
  smallboard, showmover=false, label=false, pgfstyle=\mymovestyle, color=red,
  markmoves=\xskakget{move}, pgfshortenend=0.3em, arrow=to,color=blue, markstyle=circle, markfield=\xskakget{movefrom},
  emphfields=\xskakget{moveto}, setfen=\xskakget{nextfen}]\\
  \xskakget{opennr}
  \xskakget{lan}
  \xskakget{nag}
  \par
  \end{tabular}\quad
  }}%


\begin{document}

\xskakset{style=UF}

\fontsize{10pt}{14pt}\selectfont

\font\sachy=SkakNew-Diagram at 10pt

\newdimen\muj \muj=-0.32ex

\makeatletter
\xskaknewstyleitem[%
 whiteopen={.~},
 blackopen={.\,\space\ldots},
 beforewhite={},%\space,
 beforeblack=\space,%\space,
 afterwhite=,%\space,
 afterblack={\space\,},%\space,
 ]{styleD}
\makeatother

\makeatletter
\providecommand\xskak@beforecomment{}
\makeatother
%********************* GAME ONE ***************************
\onecolumn\begin{multicols}{2}
{
\begin{tabularx}{0.9\textwidth}{rllXr}
White: & Morphy & & & \\
Black: & Duke/Count of Brunswick &  & & Paris\\
Opening ECO: & C41 & & & 1858\\
Result: & 1-0\\
\end{tabularx}
}
\end{multicols}

\setfigstyle{\normalfont}

\setboardfontcolors{blackfieldmask=gray!40}


\newchessgame
\mainline
{1. e4 e5  2.Nf3 d6  3.d4 Bg4  4.dxe5 Bxf3  5.Qxf3 dxe5  6.Bc4 Nf6  7.Qb3 Qe7  8.Nc3 c6 9.Bg5 b5  10.Nxb5 cxb5  11.Bxb5+ Nbd7  12.O-O-O Rd8  13.Rxd7 Rxd7  14.Rd1 Qe6  15.Bxd7+ Nxd7  16.Qb8+ Nxb8  17.Rd8# }

\mychessloop
\end{document}
4

Add \noindent to avoid the indentation at the begin of the paragraph. To get yellow fields color the fieldmask:

\documentclass[10pt,DIV=20]{scrreprt}
    % This is a LaTeX file generated by Scid.
    % You must have the skak, KOMAScript and pstricks packages installed to typeset this file.

    \usepackage{scrpage2}
    \usepackage{charter}
    \usepackage[svgnames]{xcolor}
    \usepackage{xskak}
    \usepackage{lmodern}
    \usepackage[T1]{fontenc}
    \usepackage{latexsym}
    %\usepackage{pstricks-add}
    \usepackage{tabularx}
    \usepackage{multicol}
    \pagestyle{empty}
    \usepackage{titlesec}
    \usepackage[LSB2,LSBC4,T1]{fontenc} % use fontenc before chessboard
    \usepackage{skak, xskak,chessboard}


    \newcommand\getmovestyle[1]{
    \ifthenelse
      {\equal{#1}{N}}
      {\def\mymovestyle{[clockwise=false,style=knight]curvemove}}
      {\ifthenelse
        {\equal{#1}{}}
        {\def\mymovestyle{curvemove}}
        {\def\mymovestyle{straightmove}}}}

    \newcommand\mychessloop[1][]{%
     \xskakloop[step=1]{%
    \getmovestyle{\xskakget{piecechar}}%
    \noindent\begin{tabular}{c}
    \chessboard[boardfontfamily=alphadia,
     boardfontencoding=LSBC4,
      smallboard, showmover=false, label=false, pgfstyle=\mymovestyle, color=red,
      markmoves=\xskakget{move}, pgfshortenend=0.3em, arrow=to,color=blue, markstyle=circle, markfield=\xskakget{movefrom},
      emphfields=\xskakget{moveto}, setfen=\xskakget{nextfen},
      coloremph=true,
      whitefieldmaskcolor=yellow,blackfieldmaskcolor=yellow,emphfield=\xskakget{moveto},
      ]\\
      \xskakget{opennr}
      \xskakget{lan}
      \xskakget{nag}
      \par
      \end{tabular}\quad
      }}%


    \begin{document}

    \xskakset{style=UF}

    \fontsize{10pt}{14pt}\selectfont

    \font\sachy=SkakNew-Diagram at 10pt

    \newdimen\muj \muj=-0.32ex

    \makeatletter
    \xskaknewstyleitem[%
     whiteopen={.~},
     blackopen={.\,\space\ldots},
     beforewhite={},%\space,
     beforeblack=\space,%\space,
     afterwhite=,%\space,
     afterblack={\space\,},%\space,
     ]{styleD}
    \makeatother

    \makeatletter
    \providecommand\xskak@beforecomment{}
    \makeatother
    %********************* GAME ONE ***************************
    \onecolumn\begin{multicols}{2}
    {
    \begin{tabularx}{0.9\textwidth}{rllXr}
    White: & Morphy & & & \\
    Black: & Duke/Count of Brunswick &  & & Paris\\
    Opening ECO: & C41 & & & 1858\\
    Result: & 1-0\\
    \end{tabularx}
    }
    \end{multicols}

    \setfigstyle{\normalfont}

    \setboardfontcolors{blackfieldmask=gray!40}


    \newchessgame
    \mainline
    {1. e4 e5  2.Nf3 d6  3.d4 Bg4  4.dxe5 Bxf3  5.Qxf3 dxe5  6.Bc4 Nf6  7.Qb3 Qe7  8.Nc3 c6 9.Bg5 b5  10.Nxb5 cxb5  11.Bxb5+ Nbd7  12.O-O-O Rd8  13.Rxd7 Rxd7  14.Rd1 Qe6  15.Bxd7+ Nxd7  16.Qb8+ Nxb8  17.Rd8# }

    \mychessloop
    \end{document}

enter image description here

3

The problem is easily fixed if the empty line above \mychessloop is removed (or commented out).

From the looks of it, you are going to display multiple games. I highly suggest that you break your code into sub files where the main file is the one that has all the setup and other .tex files containing the games. It will make the code a lot more cleaner and easier. For example, create a game1.tex file and include the following in it:

\newchessgame
\mainline{
1.e4 e5  
2.Nf3 d6  
3.d4 Bg4  
4.dxe5 Bxf3  
5.Qxf3 dxe5  
6.Bc4 Nf6  
7.Qb3 Qe7  
8.Nc3 c6 
9.Bg5 b5  
10.Nxb5 cxb5  
11.Bxb5+ Nbd7  
12.O-O-O Rd8  
13.Rxd7 Rxd7  
14.Rd1 Qe6  
15.Bxd7+ Nxd7  
16.Qb8+ Nxb8  
17.Rd8#
}
\mychessloop

Note that I have inserted every move on its own line (not mandatory but helpful in case you want to edit something and it is visually appealing).

Do the same for games 2, 3, etc. Thanks to @Ulrike Fischer for solving the highlighting part which I copied and pasted from :). Then, your main file will have the following:

\documentclass[10pt,DIV=20]{scrreprt}
% This is a LaTeX file generated by Scid.
% You must have the skak, KOMAScript and pstricks packages installed to typeset this file.
\usepackage{scrpage2}
\usepackage{charter}
\usepackage[svgnames]{xcolor}
\usepackage{xskak}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{latexsym}
\usepackage{pstricks-add}
\usepackage{tabularx}
\usepackage{multicol}
\pagestyle{empty}
\usepackage{titlesec}
\usepackage[LSB2,LSBC4,T1]{fontenc} % use fontenc before chessboard
\usepackage{skak, xskak,chessboard}
\newcommand\getmovestyle[1]{
\ifthenelse
  {\equal{#1}{N}}
  {\def\mymovestyle{[clockwise=false,style=knight]curvemove}}
  {\ifthenelse
    {\equal{#1}{}}
    {\def\mymovestyle{curvemove}}
    {\def\mymovestyle{straightmove}}}}

\newcommand\mychessloop[1][]{%
 \xskakloop[step=1]{%
\getmovestyle{\xskakget{piecechar}}%
\begin{tabular}{c}
\chessboard[boardfontfamily=alphadia,
     boardfontencoding=LSBC4,
      smallboard, showmover=false, label=false, pgfstyle=\mymovestyle, color=red,
      markmoves=\xskakget{move}, pgfshortenend=0.3em, arrow=to,color=blue, markstyle=circle, markfield=\xskakget{movefrom},
      emphfields=\xskakget{moveto}, setfen=\xskakget{nextfen},
      coloremph=true,
      whitefieldmaskcolor=yellow,blackfieldmaskcolor=yellow,emphfield=\xskakget{moveto},
      ]\\
  \xskakget{opennr}
  \xskakget{lan}
  \xskakget{nag}
  \par
  \end{tabular}\quad
  }}%

\xskakset{style=UF}
\fontsize{10pt}{14pt}\selectfont
\font\sachy=SkakNew-Diagram at 10pt
\newdimen\muj \muj=-0.32ex

\makeatletter
\xskaknewstyleitem[%
 whiteopen={.~},
 blackopen={.\,\space\ldots},
 beforewhite={},%\space,
 beforeblack=\space,%\space,
 afterwhite=,%\space,
 afterblack={\space\,},%\space,
 ]{styleD}
\makeatother

\makeatletter
\providecommand\xskak@beforecomment{}
\makeatother

\begin{document}
%********************* GAME ONE ***************************
\onecolumn\begin{multicols}{2}
{
\begin{tabularx}{0.9\textwidth}{rllXr}
White: & Morphy & & & \\
Black: & Duke/Count of Brunswick &  & & Paris\\
Opening ECO: & C41 & & & 1858\\
Result: & 1-0\\
\end{tabularx}
}
\end{multicols}%
\setfigstyle{\normalfont}%
\setboardfontcolors{blackfieldmask=gray!40}
\input{Game1}

%********************* GAME TWO ***************************
%...
%...
%...
\end{document}

Output

  • I thank you for your time. That's my plan. I am planning to do a "Visualization of Fischer's 60 Games" with each tex being game 1, game 2. Then I will merge them into one main pdf with sections. I am still doing research on how to merge and using \include and \input. I am still stuck on whether I have to include the preamble into each tex. But these are for another questions and not related to the topic at hand. – user92127 Jun 17 '19 at 23:13
  • We are happy to help! Best of luck :) – M. Al Jumaily Jun 17 '19 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.