0

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}
user92127
  • 187
  • If I understand well, you want the output to show A, B, C, D, A, B, C, D in this order? Also, I suppose we can assume that there is always the same number of diagrams defined for each group? – frougon Jun 23 '19 at 06:15
  • 4
    Possible duplicate of foreach loop error in generating diagrams As highlighted above, this is the same question as before...please edit the original question! –  Jun 23 '19 at 06:48
  • I don't know why you are asking the same question a third time. Rather than reposting the question you should edit the original question to make it clearer. This said, surely the answer to your question is to change the order of the groups in the second \foreach loop: currently you have them in order A,A,B,B,C,C,D,D so you get the output in this order. If you change the input order to A,B,C,D,A,B,C,D then, if I understand what you are asking, you will get the output that you want? –  Jun 23 '19 at 06:56
  • ...or are you actually asking how you can input the groups as A,A...,B,B,...,C,C,...,D,D,... and then have them appear as A,B,C,D,A,B,C,D,...? –  Jun 23 '19 at 06:59
  • 1
    @Andrew I answered here because the input data is slightly different (groupA, groupB, etc.). I believe my answer would be a bit confusing with the data from the question you linked. Gasp! I just noticed the “duplicate” flag, so used the other question in the end... – frougon Jun 23 '19 at 08:06
  • I will input as AA, BB, CC, DD. Then, the output will be in ABCD, ABCD, etc. – user92127 Jun 23 '19 at 14:32
  • @user92127 That's what I did in my answer to your original question. Why didn't you mark it as accepted? (see How do you accept an answer? in case you don't know what this means) – frougon Jun 23 '19 at 17:06
  • Problem solved, thanks. We can stay on the original question now. – frougon Jun 24 '19 at 05:52
  • Problem solved? This means you are able to use overleaf? Did you look at my project? It still doesn't work. Here's my past bin: https://pastebin.com/gF8N3kAm – user92127 Jun 24 '19 at 20:24

0 Answers0