# \chapter command and skak package

Is there a way to write a chapter title using chess figurines? I'm using the skak package and

\chapter{\mainline{1.e4 e6 2.d4 b6}}


doesn't work. Same error using the \variation command.

I'll post the exact error output when I'll be back home if needed.

-

## migrated from stackoverflow.comAug 10 '12 at 22:19

This question came from our site for professional and enthusiast programmers.

Using a parsing command like \mainline in an moving argument is very problematic. I would suggest to do the parsing outside with \hidemoves and to print the moves with xskak:

\documentclass{book}
\usepackage{xskak}

\begin{document}
\newchessgame[id=title]
\hidemoves{1.e4 e6 2.d4 b6}

\tableofcontents

\chapter{\protect\printchessgame[id=title]}

\printchessgame[id=title]
\chessboard[id=title]

\end{document}

-

Since the contents of a \chapter (or any/most sectional headings) are moving/fragile (they end up in the ToC, for example), care should be taken. However, you can box the content and then insert the box as part of your chapter heading. This is also not fool-proof, but at least provides a means to obtain the desired output in the chapter heading:

\documentclass{book}
\usepackage{skak}% http://ctan.org/pkg/skak
\newsavebox{\mybox}
\begin{document}
\begin{lrbox}{\mybox}\huge\newgame\longmoves\longmoves\mainline{1.e4 c5 2.Nf3 Nc6}\end{lrbox}
\chapter{\usebox{\mybox}}
\end{document}


Since the contents of \mybox is fixed in terms of its typesetting, I've used \huge which is similar to that of the regular \chapter title (in book.cls).

Another (better) alternative would be to use the Chess Font Selection Scheme chessfss to construct your chapter/symbol headings:

\documentclass{book}
\usepackage{chessfss}% http://ctan.org/pkg/chessfss
\begin{document}
\chapter{Chess: \textsymking, \textsymqueen, \textsymrook, \textsymbishop, \textsymknight, \textsympawn}
\end{document}


This works well with inserting the content in the ToC without problem. See the chessfss documentation for more details on how to modify the symbol masks and colours.

-
thank you. I'll try chessff and if it works for me (as I hope) and I will not receive any solution using skak I'll vote your answer as the best one ;) –  MementoMori Aug 10 '12 at 16:46
@MementoMori: What is it that you want exactly? A chess board, some pieces/symbols, or create a board via moves? You could capture the content of \mainline in a box and then use that as your chapter title. That is another alternative. –  Werner Aug 10 '12 at 16:54
capturing the output of \mainline (or \variation) and reusing it would be a great solution! –  MementoMori Aug 10 '12 at 17:14
@MementoMori: I've updated my answer to reflect a box-capturing technique. It depends highly on your usage though. –  Werner Aug 10 '12 at 20:15
thank you for sharing your knowledge but I've tried the solution offered by Ulrike and it seems a little easier to use. Anyway I'm sure your answer will save me time and headhaches in the future. Thank you again. –  MementoMori Aug 13 '12 at 20:35