Prior to posting this question, I have read the post here: OP asks the same question two or three times or does the same strange things several times
My purpose in asking same questions with different wordings is I don't think many understand the situation. For the final time, here's my predicament.
I have a chess worksheet.
Each worksheet has 4 different group. GroupA, Group B, Group C, and GroupD
Each group has three diagrams.
The worksheet would show in proper order: Group A with three diagrams, Group B with three diagrams, Group C with three diagrams, and Group D with three diagrams in the same orders.
If you compile it, the 1st page of pdf output will show correctly the group with their diagrams. Let's call this Model Worksheet.
Let us suppose I add another 3 diagrams to each group so that each group will now have 6 diagrams.
Using the same foreach loop, here's what I get.
Page 1: (Model Worksheet) Group A, Group B, Group C, Group D
Page 2 output is showing Group A, Group A, Group B, and Group B
Page 3 output is showing Group C, Group C, Group D, and Group D.
What must I do to fix the foreach loop to show same as the Model Worksheet? It has been suggested that I used expl3 to solve the problem. I have no idea on how to implement it.
I am willing to research and learn. Please offer me steps so I can get to the solution. Thank you for your time.
\documentclass{article}
\usepackage{xskak,chessboard}
\usepackage[margin=3cm]{geometry}
\begin{document}
%**** MODEL WORKSHEET. HAS CORRECT ORDER - 3 IN GROUP A, B, C, AND D **************
%***** FOREACH LOOP WORKS CORRECTLY *****
\foreach \X/\Y in
%******* GROUP A *****************
{GroupA/{3k4/8/2Q5/4K3/8/8/8/8 w - - 0 1,
8/8/2k5/7R/6R1/8/5K2/8 w - - 0 1,
1k6/7R/3K4/8/8/8/8/8 w - - 0 1},
%******* GROUP B *****************
GroupB/{8/8/8/8/8/1k6/7P/4K3 w - - 0 1,
8/8/8/8/4k3/4p3/4K3/8 w - - 0 1,
8/1k6/8/8/1PK5/8/8/8 w - - 0 1},
%************ GROUP C *******************
GroupC/{8/8/8/4p1K1/2k1P3/8/8/8 w - - 0 1,
8/8/8/p7/P7/7k/7P/6K1 w - - 0 1,
k7/P1K5/6p1/7p/7P/8/8/8 w - - 0 1},
%************ GROUP D ********************
GroupD/{4BK2/6P1/5k2/8/8/1b6/8/8 w - - 0 1,
8/8/4k3/2p4n/2P1K3/8/7B/8 w - - 0 1,
8/p7/P5p1/1P4P1/5P2/3kb3/8/3K4 w - - 0 1}}
{\noindent\tikz{\node[rotate=90,font=\bfseries,align=center,text width=4cm]{\X};}
\foreach \Z in \Y
{\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,setfen=\Z]
\end{minipage}}
}
%****** WHEN NEW 3 MORE DIAGRAMS ARE ADDED, FOREACH LOOP GETS WRONG. WORKSHEET IS NOT SAME AS MODEL WORKSHEET *****
\foreach \X/\Y in
%******* GROUP A *****************
{GroupA/{3k4/8/2Q5/4K3/8/8/8/8 w - - 0 1,
8/8/2k5/7R/6R1/8/5K2/8 w - - 0 1,
1k6/7R/3K4/8/8/8/8/8 w - - 0 1},
GroupA/{3k4/8/2Q5/4K3/8/8/8/8 w - - 0 1,
8/8/2k5/7R/6R1/8/5K2/8 w - - 0 1,
1k6/7R/3K4/8/8/8/8/8 w - - 0 1},
%******* GROUP B *****************
GroupB/{8/8/8/8/8/1k6/7P/4K3 w - - 0 1,
8/8/8/8/4k3/4p3/4K3/8 w - - 0 1,
8/1k6/8/8/1PK5/8/8/8 w - - 0 1},
GroupB/{8/8/8/8/8/1k6/7P/4K3 w - - 0 1,
8/8/8/8/4k3/4p3/4K3/8 w - - 0 1,
8/1k6/8/8/1PK5/8/8/8 w - - 0 1},
%************ GROUP C *******************
GroupC/{8/8/8/4p1K1/2k1P3/8/8/8 w - - 0 1,
8/8/8/p7/P7/7k/7P/6K1 w - - 0 1,
k7/P1K5/6p1/7p/7P/8/8/8 w - - 0 1},
GroupC/{8/8/8/4p1K1/2k1P3/8/8/8 w - - 0 1,
8/8/8/p7/P7/7k/7P/6K1 w - - 0 1,
k7/P1K5/6p1/7p/7P/8/8/8 w - - 0 1},
%************ GROUP D ********************
GroupD/{4BK2/6P1/5k2/8/8/1b6/8/8 w - - 0 1,
8/8/4k3/2p4n/2P1K3/8/7B/8 w - - 0 1,
8/p7/P5p1/1P4P1/5P2/3kb3/8/3K4 w - - 0 1},
GroupD/{4BK2/6P1/5k2/8/8/1b6/8/8 w - - 0 1,
8/8/4k3/2p4n/2P1K3/8/7B/8 w - - 0 1,
8/p7/P5p1/1P4P1/5P2/3kb3/8/3K4 w - - 0 1}}
{\noindent\tikz{\node[rotate=90,font=\bfseries,align=center,text width=4cm]{\X};}
\foreach \Z in \Y
{\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,setfen=\Z]
\end{minipage}}
\par
}
\end{document}
\foreachloop: currently you have them in orderA,A,B,B,C,C,D,Dso you get the output in this order. If you change the input order toA,B,C,D,A,B,C,Dthen, if I understand what you are asking, you will get the output that you want? – Jun 23 '19 at 06:56A,A...,B,B,...,C,C,...,D,D,...and then have them appear asA,B,C,D,A,B,C,D,...? – Jun 23 '19 at 06:59