2

Is actually possible to obtain the text output of a game in a column with one line for every move, instead of a compact body of text where everything is bundled together as it currently happens with the following MWE?

\documentclass[twocolumn]{book}

\usepackage{skak}
\usepackage{texmate}

\begin{document}

\whitename{Dubois} \blackname{Steinitz} \chessevent{London 1862} 3
\ECO{C50} \chessopening{Giucco Pianissimo}

|1 e4 e5 Nf3 Nc6 Bc4 Bc5 d3 Nf6 Bg5?! [Nc3] d6 O-O?! h6 Bh4 g5 Bg3 h5!
 Nxg5 h4! Nxf7 hxg3!! Nxd8 [Nxh8 Qe7! \threat<Qh7> Nf7 Bxf2+ Rxf2 gxf2+
 Kxf2 Ng4+ Kg3 Qf6 Qf3 Qg7\BBetter] Bg4 Qe1 Nd4 Nc3\onlymove [h3 Ne2+
 Kh1 Rxh3+ gxh3 Bf3\#] Nf3+! gxf3 Bxf3 \resigns|


\end{document}

Here there is an example of what I had in mind:

enter image description here

Thanks in advance for any feedback.

11
  • Your example doesn't compile. \whitename and other commands are not defined. Dec 17 '17 at 12:23
  • I am really sorry. Now it should work, even if still there is something fishy, but nothing that precludes to solve what I had i mind.
    – Kolmin
    Dec 17 '17 at 12:34
  • have you tried adding \\ after each move?
    – Old Nick
    Dec 17 '17 at 12:54
  • 1
    It is possible to get your output but I don't know if it will work with the input of texmate -- the package is turned toward easy input than sophisticated output. Check the xskak package and the "styleC" variant. Dec 17 '17 at 15:25
  • 1
    @user41974 Actually I am not completely sure but if I remember correctly it should be Nunn's "Understanding Chess Move by Move".
    – Kolmin
    Jan 14 '18 at 13:23
4

It is possible to get your output but I don't know if it will work with the input of texmate -- the package is more turned toward easy input than sophisticated output. With the xskak package you could do something like this:

\documentclass[twocolumn]{book}

\usepackage{xskak,lipsum}

\begin{document}
\newchessgame
\xskakset{style=styleC}
\mainline
{1. e4 e5 2. Nf3 Nc6 3. Bc4}

blblbl blbllb

{\centering \chessboard[smallboard]\par}

\mainline{3... Bc5 4. d3 Nf6 5. Bg5?!}

\end{document}

enter image description here

2

The texmate package defines some macros to control what appears after moves and the variation delimiters (see Sections 3.3 and 3.4 of the manual). By redefining these macros, we can add an \hfill before each move number, and another one after each Black's move to achieve the centering. Similarly, we can add . \quad after each number and \qquad after White's moves to mimic the spacing in the example.

The problem is that you probably want to be able to typeset moves inside comments without the centering and large spacing. Therefore, each redefinition needs to check that we are not inside a comment using \ifnum\@commlevel<2. In addition, if a comment starts before Black's move, we need to add more whitespace to account for the missing move in the current line. This check is done with \if@white. The complete redefinition code is as follows:

\makeatletter
    \renewcommand{\beforeno}{\ifnum\@commlevel<2 \null\hfill\fi}
    \renewcommand{\afterno}{\ifnum\@commlevel<2.\quad\else.~\fi}
    \renewcommand{\afterw}{\ifnum\@commlevel<2\qquad\else\ \fi}
    \renewcommand{\afterb}{\ifnum\@commlevel<2\hfill\null\\\else\ \fi}
    \renewcommand{\beforeb}{\ifnum\@commlevel<2\null\hfill\the\move\quad\dots\qquad\else\the\move\dots\fi}
    \renewcommand{\iiopen}{\ifnum\@commlevel<3\if@white\hspace{3em}\fi\hfill\null\par[\else\ [\fi}
    \renewcommand{\iiclose}{\ifnum\@commlevel<3]\hfill\null\\\else]\ \fi}
    \renewcommand{\iiopent}{\ifnum\@commlevel<3\if@white\hspace{3em}\fi\hfill\null\par\else\ \fi}
    \renewcommand{\iicloset}{\ifnum\@commlevel<3\hfill\null\\\else\ \fi}
\makeatother

Your code does not compile, so I did my best to fix it. There seems to be a very weird problem that produces compiler errors whenever a rook moves, so I replaced all R by r to produce a working example. If I change R to any other piece (for example N), the code compiles even if the game would not make sense. It looks like a bug in the package...

chess

\documentclass[twocolumn]{book}

\usepackage{skak}
\usepackage{texmate}

\makeatletter
    \renewcommand{\beforeno}{\ifnum\@commlevel<2 \null\hfill\fi}
    \renewcommand{\afterno}{\ifnum\@commlevel<2.\quad\else.~\fi}
    \renewcommand{\afterw}{\ifnum\@commlevel<2\qquad\else\ \fi}
    \renewcommand{\afterb}{\ifnum\@commlevel<2\hfill\null\\\else\ \fi}
    \renewcommand{\beforeb}{\ifnum\@commlevel<2\null\hfill\the\move\quad\dots\qquad\else\the\move\dots\fi}
    \renewcommand{\iiopen}{\ifnum\@commlevel<3\if@white\hspace{3em}\fi\hfill\null\par[\else\ [\fi}
    \renewcommand{\iiclose}{\ifnum\@commlevel<3]\hfill\null\\\else]\ \fi}
    \renewcommand{\iiopent}{\ifnum\@commlevel<3\if@white\hspace{3em}\fi\hfill\null\par\else\ \fi}
    \renewcommand{\iicloset}{\ifnum\@commlevel<3\hfill\null\\\else\ \fi}
\makeatother

\begin{document}

    \whitename{Dubois} \blackname{Steinitz} \chessevent{London 1862} 3
    \ECO{C50} \chessopening{Giucco Pianissimo}

    \makegametitle
    \noindent|1 e4 e5 \[|This is a comment. Comments can include moves (| d5 Nc3 |), which are typeset without extra space.|\] Nf3 Nc6 Bc4 Bc5 d3 Nf6 Bg5?! \[|This is a comment after White's move. It can also include moves (|Nc3|), and respects the spacing on the next actual move.|\] d6 O-O?! h6 Bh4 g5 Bg3 h5!
    Nxg5 h4! Nxf7 hxg3!! Nxd8 [Nxh8 Qe7! \threat<Qh7> Nf7 Bxf2+ rxf2 gxf2+ Kxf2 Ng4+ Kg3 Qf6 Qf3 Qg7\BBetter] Bg4 Qe1 Nd4 Nc3\onlymove [h3 Ne2+ Kh1 rxh3+ gxh3 Bf3\#] Nf3+! gxf3 Bxf3 \resigns|


\end{document}
3
  • First of all, thanks a lot for your answer. I edited my question with a pics that shows exactly what I had in mind (moves centered in the column, larger space for the comments). Do you think this can be achieved?
    – Kolmin
    Dec 17 '17 at 13:12
  • @Kolmin That was considerably more complicated. I updated my answer with code that achieves something very close to what you are looking for. I needed to redefine almost every macro, but hopefully al those \renewcommand lines give you insight into how you can further tweak the spacings/delimiters if needed :)
    – wimi
    Dec 17 '17 at 17:36
  • 2
    Thanks a lot for the effort. However, out of fairness, I have to say that xskakdoes the job effortlessly, with a better look.
    – Kolmin
    Dec 18 '17 at 10:48

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.