1

I'm using xskak and chessboard to typeset a game. How can I constrain the printing of the moves to the with of the board? I'm basically looking to constrain the width of the text box. In the image below you can see that the moves extend both left and right of the area over the board.

Here is the MWE for this game:

\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{5mm}
\usepackage{xskak}
\usepackage{chessboard}
\begin{document}
\begin{preview}
\newchessgame
\mainline{1. e4 c5 2. Nf3 d6 3. d4 cxd4 4. Nxd4 Nf6 5. Nc3 a6 6. Be3 e6
7. g4 e5 8. Nf5 g6 9. g5}\\
\chessboard[label=False]
\end{preview}
\end{document}

Thanks!

1

You can just put the movements into a \parbox of the desired width:

enter image description here

Here's the code:

\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{5mm}
\usepackage{xskak}
\usepackage{chessboard}
\begin{document}
\begin{preview}
\newchessgame
\parbox{60mm}{
\mainline{1. e4 c5 2. Nf3 d6 3. d4 cxd4 4. Nxd4 Nf6 5. Nc3 a6 6. Be3 e6
7. g4 e5 8. Nf5 g6 9. g5}
}

\chessboard[label=False]
\end{preview}
\end{document}

EDIT In light of the comments below, perhaps you want to use something like this:

\documentclass{article}
\usepackage{xskak}

\begin{document}

  \newchessgame
  \hspace*{7mm}\mainline{1. e4 c5 2. Nf3 d6 3. d4 cxd4 4. Nxd4 Nf6}\\
  \hspace*{7mm}\mainline{5. Nc3 a6 6. Be3 e6 7. g4 e5 8. Nf5 g6 9.  g5}
  \par\leavevmode\vspace*{-60mm}
  \chessboard[label=False]

\end{document}

This produces:

enter image description here

Note that I have removed the use of preview and used two \mainline commands to control the line spacing.

8
  • Thanks, is there a way to offset the position of the parbox so that the left side of the text is flush with the left side of the board? Or the parbox is centered over the board? Apr 28 '19 at 5:42
  • When in doubt try a random LaTeX command! For example, try putting \hspace*{6mm} before the \parbox command. Is there a reason why you are using the preview package? I've not seen it before and would not have guessed that you needed it.
    – user30471
    Apr 28 '19 at 6:09
  • I am using preview because the code didn't seem to work without it (I get no pages of output written). Do you know what preview actually does, I copied it from an example? Apr 28 '19 at 6:30
  • Thanks for the tip on the \hspace*, I'm new enough at LaTeX that I don't know which random commands to try. Apr 28 '19 at 6:35
  • Do you know how to make the text box line break only right before a move number? Do you know how to reduce the vertical space between the text and the diagram? Or should I accept this answer now and ask these as separate questions? Apr 28 '19 at 6:36

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.