# Chessboard Book of exercises: Layout template

I am trying to create a book of exercises and I want to make a template. I want to have 3 diagrams side by side. The layout of one exercise is like the description below. I have found out that I can just place 3 diagrams from the chessboard package:

\chessboard[smallboard,setfen=8/7k/r3nPpp/p1q1P1p1/2pp2P1/4R2Q/7P/5R1K w]
\chessboard[smallboard,setfen=8/7k/r3nPpp/p1q1P1p1/2pp2P1/4R2Q/7P/5R1K w]
\chessboard[smallboard,setfen=8/7k/r3nPpp/p1q1P1p1/2pp2P1/4R2Q/7P/5R1K w]

My problem is how to lay out the top boxes. I want to have the number (26) aligned horizontally so it is in line with the next 27 and 28 exercises. The same goes for the players and the location/year. The player and location/year may span on more than one line. Below is the last move before the diagram.

Is it a smart way I can lay out these boxes so they align nicely?

------------------
|      26        |
------------------
|  Keres-Gilfer  |
------------------
| Munich, 1936   |
------------------
|                |
|  Chessboard    |
|                |
------------------
|   14... Kgh8   |
------------------
-
Why don't you use a tabular if you want to align a lot of things? –  Ulrike Fischer Jul 17 '13 at 10:30

Maybe the following MWE will help. I did not know how you specify your margins or what documentclass you were using, so I fixed something up, but I cannot be sure if that was what you desired. (I could not fit three but only two boards side by side.)

\documentclass{article}
\usepackage{chessboard}

\newlength{\chessboardwidth}
\newlength{\chessboardheight}
%Define width and height of the box for the exercise
\setlength{\chessboardwidth}{0.5\linewidth} %may be overitten after \begin{document}
\setlength{\chessboardheight}{0.40\textheight}
\newcommand{\mychessboard}[5]{\parbox[b][\chessboardheight][b]{\chessboardwidth}{%
\centering%
#1\\\vfill
\parbox[t][2\baselineskip][t]{\linewidth}{\centering #2}\\\vfill
\parbox[t][2\baselineskip][t]{\linewidth}{\centering #3}\\\vfill
\chessboard[#4]\\
#5}}

\begin{document}

%Change to actual width of the chessboard (Thanks to Ulrike)
\settowidth{\chessboardwidth}{\chessboard[smallboard]}

\fbox{\mychessboard{26}{Keres-Gilfer}{Munich, 1936}{smallboard,setfen=8/7k/r3nPpp/p1q1P1p1/2pp2P1/4R2Q/7P/5R1K w}{14... Kgh8}}%
\fbox{\mychessboard{27}{A Nasty Long Name versus A Very Dangerously Long Name}{At the End of the World, 2033}{smallboard,setfen=8/7k/r3nPpp/p1q1P1p1/2pp2P1/4R2Q/7P/5R1K w}{42... Kgh23}}

\vspace{1ex}
\fbox{\mychessboard{28}{Vader versus Luke}{Coruscant, in a Galaxy far, far away, 4 ABY}{smallboard,setfen=8/7k/r3nPpp/p1q1P1p1/2pp2P1/4R2Q/7P/5R1K w}{42... Kgh23}}%
\fbox{\mychessboard{26}{Keres-Gilfer}{Munich, 1936}{smallboard,setfen=8/7k/r3nPpp/p1q1P1p1/2pp2P1/4R2Q/7P/5R1K w}{14... Kgh8}}%

\end{document}

You may set \chessboardwidth and \chessboardheight to fit your needs. (You also have to, otherwise it will produce errors.)

I did not find anything in the documentation of chessboard, that specifys the width of a chessboard. But thanks to Ulrike's comment the initial value of \chessboardwidth may be overwritten to fit to the width of the chessboard as well.

The 'string value' for players and place is wrapped in parboxes that can hold two lines, which should be enough. This should fix the bad alignment.

The community may still provide a more sophisticated answer.

-
This is almost brilliant. I would ideally like to align the "Munich, 1936" and "At the End of the World, 2033" vertically. Is that possible? –  Chessaddict Jul 16 '13 at 17:58
Regarding the width of a chessboard: After \getsquaresize\BlackEmptySquare the width of a field is stored in the length \len@cfss@squarewidth (it is normally the same as the font size of the chessfont) and you can use if for calculations. But the easiest way to get the total width is naturally \settowidth\chessboardwidth{\chessboard} –  Ulrike Fischer Jul 17 '13 at 7:37
@UlrikeFischer Das werde ich gleich einbauen. Das alignment habe ich mit ein paar parboxen umgangen. Ich poste eine verbesserte Version in ein paar Minuten. Ob das jetzt der eleganteste Weg ist, sei mal dahingestellt. –  Martin Jul 17 '13 at 8:13