Consider the following example:
\documentclass{article}
\usepackage[
a4paper,
hmargin = 2.4cm,
vmargin = 3cm
]{geometry} % https://ctan.org/pkg/geometry
\usepackage{xskak} % https://ctan.org/pkg/xskak
\newcommand*\hestA[2][\svarstedA]{%
\underline{\makebox[\ifdim\width>#1\width\else#1\fi]{#2}}}
\newcommand*\opgaverLoesningerA[1]{\hestA{\textcolor{blue}{#1}}}
\newcommand*\opgaverLoesningerEkstra[6]{%
\def\tempA{#1}%
\def\tempB{#2}%
\def\tempC{#3}%
\def\tempD{#4}%
\def\tempE{#5}%
\def\tempF{#6}%
\opgaverLoesninger
}
\newcommand*\opgaverLoesninger[6]{%
\begin{figure}[!htbp]
\centering
\begin{minipage}{0.5\textwidth}
\centering
\newgame
\fenboard{\tempB \tempA - - 0 1}%
\scalebox{1.2}{\showboard}%
\vspace*{2ex}
{\LARGE Løsning: \opgaverLoesningerA{\tempC}}%
\end{minipage}%
\begin{minipage}{0.5\textwidth}
\centering
\newgame
\fenboard{\tempE \tempD - - 0 1}%
\scalebox{1.2}{\showboard}%
\vspace*{2ex}
{\LARGE Løsning: \opgaverLoesningerA{\tempF}}%
\end{minipage}
\end{figure}
\vspace*{2ex}
\begin{figure}[!htbp]
\centering
\begin{minipage}{0.5\textwidth}
\centering
\newgame
\fenboard{#2 #1 - - 0 1}%
\scalebox{1.2}{\showboard}%
\vspace*{2ex}
{\LARGE Løsning: \opgaverLoesningerA{#3}}%
\end{minipage}%
\begin{minipage}{0.5\textwidth}
\centering
\newgame
\fenboard{#5 #4 - - 0 1}%
\scalebox{1.2}{\showboard}%
\vspace*{2ex}
{\LARGE Løsning: \opgaverLoesningerA{#6}}%
\end{minipage}
\end{figure}}
\begin{document}
\opgaverLoesninger%
{w}{6k1/6p1/1p5p/3r4/1P6/6P1/4B1KP/8}{Lc4}%
{w}{1k6/pp6/2p3p1/4n1P1/8/P6P/KP1B4/8}{Lf4}%
{w}{8/1p4kp/p5p1/B7/3n4/1P5P/2P3P1/6K1}{Lc3}%
{w}{k7/p6p/1p4p1/3r4/1P5P/P5P1/1KB5/8}{Le4}
\end{document}
When I compile using xelatex
, I get the error
! Paragraph ended before \FenBoard was complete.
<to be read again>
\par
l.73 {w}{1k6/pp6/2p3p1/4n1P1/8/P6P/KP1B4/8}{Lf4}
%
Can anyone help me fix this?
P.S. I think it is related to the fact that I try to have more than 9 arguments (here it is 12 arguments) in my macro but I am not sure.
Best Answer
What about having five boards to draw? Or eight?
Here's an implementation that accepts any number of boards and outputs them in pairs in
figure
environments. If the number is odd, the last one is output by itself in anotherfigure
.Instead of a syntax with braces, separating boards with
\\
and data in each one with commas is simpler and more readable.With slight changes, you can also set the magnification for the boards (default 1.2) and the number of boards per row (default 2).
The magnification is changed with
mag=<factor>
, the number of boards per row is set withn=<number>
in the optional argument to\opgaverLoesninger
.The option
single
(a boolean,single=true
is implicit) will make a single figure environment, but you're responsible for it to fit on a page, of course. It is present in the example just by way of example. If you try\opgaverLoesninger[single]{...}
(same mandatory argument for five boards), the float will be too large (not with four boards).