[Tex/LaTex] Chess mode in texmate: wrong side to move

chessskak

This is my first post here 🙂

I am starting with LaTeX, and I am trying now to apply it annotate some chess positions.

My problem is the use of the chess mode (|...chess moves to show figurines...|) when using the texmate package. I don't want to be strict when editing the chess moves in LaTeX, so I use \SkakOff to avoid texmate/skak to check every move sequence entered.

I am planning to use only \fenboard{...} or \position{...} and then the chess mode to insert the moves. Every board is a new position in a different game, so that's why I don't need (nor want) skak to check every chess move(s). I have read Typesetting nested chess variations in Skak but I wanted to avoid the use of \mainline, \variation, etc.

The problem appears when in the last "variation" (in fact I am not using \mainline, \variation, etc., as commented above) the last side who made the move is white, then, in the next sequence, LaTeX starts as if it was black to move.

Here there is the example 10.1.15 from The LaTeX Graphics Companion (page 680), modified to ilustrate the problem:

\documentclass[10pt]{book}
\usepackage[utf8]{inputenc}

\usepackage{texmate}  \SkakOff
\begin{document}
%Original code
Input as |e4 c5 Nf3 d6 d4 cxd4|
or as    |1 e4 c5 2 Nf3 d6 3 d4 cxd4|
or as    |1. e4 c5 ; 2. Nf3 d6 ; 3. d4 cxd4|

%Modified (buggy) code
But if   |1 e4 c5 2 Nf3 d6 3 d4 cxd4 4 Na3| (the last move is played by white)
then     |1 e4 c5 2 Nf3 d6 3 d4 cxd4 4 Na3| (the next time, skak starts 
the chess mode as moving black first, not white)
\end{document}

How can I force to start again the chess move with white to move if the last move in the main variation was made by white? Or the opposite, force start again with black to move, if it was black who made the last move.

Thanks,

P.S. I am using texmate because I use the \makegametitle command.

Addendum:

My question is related to the translation form HTML to LaTeX of an old document I have been working and using for long. Now, I want to print it, but the HTML printout looks poor, so I thought about translating it to LaTeX.

That document is quite well debugged in chess terms, so I do not need the help of skak/texmate to check the positions and move sequences, as every position is in HTML format and I have created an small script to translate them to FEN and I already have the consequent \fenboard{} blocks. But when I substituted the HTML format of the moves to the LaTeX chess mode |...| I found the (unexpected for me) behavoir explained above. Thanks to DJP for explaining me that behavoir.

I do not want to go through the hundred of positions I already have, checking and rewriting every mainline/variation and including the corresponding LaTeX command. I expected to use the chess mode to just highlight (\textbf) the chess moves and change from the spanish algebraic notation to the figurine notation.

Now, to avoid all the hard work of revising everything, I would like to know if there was any way to easily mark a sequence of moves (which already have their correct move number) as show them as in the LaTeX chess mode. Some sort of reseting the chess mode, like the \newgame trick suggested by DJP, but being able to set also the side to move.

If it is not possible, then I will have to make another script to detect all the chess move sequences and replace Ka1 for \king{}a1, e3 for \pawn{}e3, and so on (with the problem of showing black pieces). That is possible, and easy, but would make the final tex file source very obfuscated compared with the simple chess mode notation. It is not at all easy to automate the substitution using \mainline, \variation, etc.

Sorry for my bad explanation, but I am not english speaker, and it is hard for me to explain my problem better. I understand that this problem is quite specific, and that it is not the LaTeX philosophy way of work.

Best Answer

A good night's sleep helped me to realize a mistake in my post, so this is a substantial edit: The problem is code between | ... | IS the mainline and not a variation; so in the game it would be black's turn to move because you've broken it before a move pair has been completed. It then picks up the mainline where where you left off producing the unwanted ellipsis. Therefore, start with a new mainline by typing \newgame which will, of course, begin with a white move. This code will give you how the numbering can be changed to give what you want:

\documentclass[10pt]{book}
\usepackage[utf8]{inputenc}

\usepackage{texmate}  \SkakOff
\begin{document}
With  |1 e4 c5 2 Nf3 d6 3 d4 cxd4| writing |e4 c5 Nf3 d6 d4 cxd4| continues the mainline.
But you can step in and renumber with |3. e4 c5 4. Nf3 d6 5. d4 cxd4| if you want.

For |1 e4 c5 2 Nf3 d6 3 d4 cxd4 4 Na3| (the last move is played by white)
then  \newgame   resets to a new game (new main line) so 
| e4 c5  Nf3 d6  d4 cxd4  Na3| will achieve what you want.
If you want to start with different numbers then 
\newgame |22 e4 c5  23 Nf3 d6  24 d4 cxd4 25 Na3| will work.
\end{document}

With respect to your goal, I've used LaTeX along with the \mainline command to produce documents that look fine from the chess perspective. However, I guess your method looks viable as well.

Here is the output from the code above:

output

Related Question