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:


\usepackage{texmate}  \SkakOff
%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)

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.


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


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.

1 Answer 1


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:


\usepackage{texmate}  \SkakOff
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.

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:


  • Thank you for your replies. I was just going to clarify my post, as the previous solution was not good enough as the HTML I am going to convert to LaTeX is already very well debuged and I just want the spanish algebraic notation translated to the figurine one. I have tested to insert \newgame before every chess mode block and it seems to be working really fine. That way the tex source is still quite easy to read, solving the printout appearance. For the new positions, I will follow the LaTeX standard way to comment the games. Thx! Commented Aug 10, 2011 at 17:24
  • Ops, sorry. I have tried to insert \newgame before every chess mode block and it works well ONLY when white is next to move, but not when is black to move. In such case, the \newgame starts the new chess sequence move with white, regarless it started like |3...Nc3 4.Nf6| Nevertheless, I am going to work a bit with your idea to see if I can get my goal. If I get a solution, I will post it. Also, I have edited the original post, including an Addendum to explaing better what and why I was looking for. Commented Aug 10, 2011 at 18:00
  • It sounds like you are looking at 4 cases, depending on what color starts a sequence of moves and what ends it. Cases beginning with white are done. For cases beginning with black look at something like 2. \bmove{d6} (in bold) and then use \newgame |more moves|.
    – DJP
    Commented Aug 10, 2011 at 18:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .