I'm new in LaTeX and I've been trying to write chess moves on it. All was good until this big problem I got after I've written this of line chess moves, extracted from a game of Chess played by Botvinnik, I didn't understand and I can't solve it. One more detail: it is NOT from the begining of the game, but nearly the twentieth move.

\documentclass[a4paper, 11pt]{report}

\usepackage[left=3cm, right=3cm, top=3cm, bottom=3cm]{geometry}


\mainline{1. Nb2 Rc3 \, 2. Bd2 Rb3 \, 3. Qc2 Qb5 \, 4. Rc1 Bf8 \, 5. Rd1 Re2 \,  6. Qc1 
Rxh3+ ! \, 7. gxh3 d4  0--1}



Here's the error message :

! Undefined control sequence.
<argument> \MoveFrom
l.132 ...e2 \, 6. Qc1 Rxh3+ ! \, 7. gxh3 d4 0--1}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

Any help will be welcome.


  • 3
    \mainline plays the game. It tries to keep the internal board up-to-date. This means that you should setup the correct start position. And you shouldn't put formatting instructions in the argument. May 27 '17 at 7:54

As Ulrike Fisher suggested in a comment, something was missing in the code: the first moves of the game. skak can follow the moves from the beginning as if was playing and print the chessboard at the final state as well. Additionally, you can set the chessboard by putting every single piece on its own square and then print it with some relevant moves and comments aside with the written moves. For those purpouses, xskak is an improved version of the package, since corrects some bugs detected and adds some other features (see xskak: An extension to the package skak)

When displaying only move games, you must write them from the beginning or, from some move to finish.

I did both in the code. First column is the complete game with all the moves (I retrieved the information on Stolberg vs. Botvinnik game). Here xskak plays the game -as Fisher said-, and returns the final possition with \chessboard command.

Second column is what you were pretending. But in this case -since xskak does not know how to interpret the last 7 moves of a game without preamble and middle game, would place pieces in positions that could overlap each other on every square-, you needed to write a command to tell xskak to forget first moves and displays last ones by typing \xskakset{defaultmoveid=35w} (p.28, CTAN xskak), and then you can settle by hand the pieces on the chessboard with the final positions if you want.

Your code generated two errors, one because of the last moves written and second, due to 0--1 at the end of \mainline{...} (this one caused the error The control sequence ... was never \def'ed). You should write the key result=0--1 inside \newchessboard and call it after \mainline{...} with \xskakgetgame{result}. There is no need to put \, to separate moves within this environment.

enter image description here




    \centering {\large\bf Stolberg vs. Botvinnik} 
        1.      d4      Nf6    2.       c4      e6      3.      Nc3     Bb4
        4.      e3      O-O    5.       Bd3     d5      6.      cxd5    exd5
        7.      Nge2    c5     8.       O-O     Nc6     9.      a3      cxd4
        10.     exd4    Bd6    11.      h3      h6      12.     b4      Re8
        13.     Qb3     Be6    14.      Bd2     Qd7     15.     f4      Bf5
        16.     Qc2     Be4    17.      b5      Bxd3    18.     Qxd3    Na5
        19.     Ng3     Nc4    20.      Bc1     Rac8    21.     Ra2     Bf8
        22.     a4      Bb4    23.      Nd1     Ne4     24.     f5      Nxg3
        25.     Qxg3    Bd6    26.      Qf3     Be7     27.     Qg3     Bf6
        28.     Bxh6    Bxd4+  29.      Kh1     f6      30.     Bc1     Re4
        31.     Qd3     Ne5    32.      Qb1     Rc4     33.     a5      Bc5
        34.     b6      a6     35.      Nb2     Rc3     36.     Bd2     Rb3
        37.     Qc2     Qb5    38.      Rc1     Bf8     39.     Rd1     Re2
        40.     Qc1     Rxh3+  41.      gxh3!   d4}
%Last 7 moves
%Chessboard has to be set by hand with keys \newchessgame[setwhite={...},setblack={...}]
    \centering {\large\bf Stolberg vs. Botvinnik} \\ (last 7 moves) 
    \xskakgetgame{white}--\xskakgetgame{black}: %Competitors names
        35.     Nb2     Rc3     36.     Bd2     Rb3       37.       Qc2     Qb5
        38.     Rc1     Bf8     39.     Rd1     Re2       40.       Qc1     Rxh3+
        41.     pxh3!   pd4} \quad\mbox{\xskakgetgame{result}}


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.