Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Aug 10 '12 at 22:19

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

2 Answers 2

up vote 9 down vote accepted

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}
share|improve this answer

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:

enter image description here

\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:

enter image description here

\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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.