我希望创建一个包含 4 个组的国际象棋工作表:基本组、兵、2 个兵和小兵+兵。我制作了一个手动工作表。但我希望自动完成此过程。工作表将从\chessboard
每个组中提取数据并将它们设置为并排打印。请参阅我的手动工作表。我不知道如何实现宏来构建它。
\documentclass{article}
\usepackage{graphicx}
\usepackage{xskak,chessboard}
\parindent=0pt
\addtolength{\voffset}{-1in}
\addtolength{\hoffset}{-1in}
\addtolength{\textwidth}{2.95cm}
\addtolength{\textheight}{10\baselineskip}
%*** MACRO BASIC ********************************
\newcommand\groupbasic{
\rotatebox{90}{\makebox[0.28\linewidth]{\textbf{basic}}}}
%******MACRO PAWN LEVEL **********************************
\newcommand\grouppawn{
\rotatebox{90}{\makebox[0.28\linewidth]{\textbf{pawns}}}}
%*****MACRO 2PAWN LEVEL *********************************
\newcommand\grouptwopawn{
\rotatebox{90}{\makebox[0.28\linewidth]{\textbf{2 pawns}}}}
% ***********MACRO MINORPAWNS ********************
\newcommand\groupminorpawn{
\rotatebox{90}{\makebox[0.28\linewidth]{\textbf{Minor + Pawns}}}}
%*****************************************
\begin{document}
%********************** BASIC LEVEL **********************
\chessboard[smallboard,setfen=3k4/8/2Q5/4K3/8/8/8/8 w - - 0 1]
\chessboard[smallboard,setfen=8/8/2k5/7R/6R1/8/5K2/8 w - - 0 1]
\chessboard[smallboard,setfen=1k6/7R/3K4/8/8/8/8/8 w - - 0 1]
%******* PAWN LEVEL *****************
\chessboard[smallboard, setfen=8/8/8/8/8/1k6/7P/4K3 w - - 0 1]
\chessboard[smallboard,setfen=8/8/8/8/4k3/4p3/4K3/8 w - - 0 1]
\chessboard[smallboard, setfen=8/1k6/8/8/1PK5/8/8/8 w - - 0 1]
%************ 2 PAWN LEVEL *******************
\chessboard[smallboard,setfen=8/8/8/4p1K1/2k1P3/8/8/8 w - - 0 1]
\chessboard[smallboard,setfen=,setfen=8/8/8/p7/P7/7k/7P/6K1 w - - 0 1]
\chessboard[smallboard,setfen=k7/P1K5/6p1/7p/7P/8/8/8 w - - 0 1]
%************ MINOR + PAWN LEVEL ********************
\chessboard[smallboard, setfen=4BK2/6P1/5k2/8/8/1b6/8/8 w - - 0 1]
\chessboard[smallboard, setfen=8/8/4k3/2p4n/2P1K3/8/7B/8 w - - 0 1]
\chessboard[smallboard,setfen=8/p7/P5p1/1P4P1/5P2/3kb3/8/3K4 w - - 0 1]
\clearpage
%********************** BASIC LEVEL **********************
\groupbasic
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,setfen=3k4/8/2Q5/4K3/8/8/8/8 w - - 0 1]
\end{minipage}%
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,setfen=8/8/2k5/7R/6R1/8/5K2/8 w - - 0 1]
\end{minipage}%
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,setfen=1k6/7R/3K4/8/8/8/8/8 w - - 0 1]
\end{minipage}%
\vspace{.40cm}
%******* PAWN LEVEL *****************
\grouppawn
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,
setfen=8/8/8/8/8/1k6/7P/4K3 w - - 0 1]
\end{minipage}%
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,setfen=8/8/8/8/4k3/4p3/4K3/8 w - - 0 1]
\end{minipage}%
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,
setfen=8/1k6/8/8/1PK5/8/8/8 w - - 0 1]
\end{minipage}%
\vspace{.40cm}
%************ 2 PAWN LEVEL *******************
\grouptwopawn
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,setfen=8/8/8/4p1K1/2k1P3/8/8/8 w - - 0 1]
\end{minipage}%
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,
setfen=,setfen=8/8/8/p7/P7/7k/7P/6K1 w - - 0 1]
\end{minipage}%
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,setfen=k7/P1K5/6p1/7p/7P/8/8/8 w - - 0 1]
\end{minipage}%
\vspace{.40cm}
%************ MINOR + PAWN LEVEL ********************
\groupminorpawn
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard, setfen=4BK2/6P1/5k2/8/8/1b6/8/8 w - - 0 1]
\end{minipage}%
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard, setfen=8/8/4k3/2p4n/2P1K3/8/7B/8 w - - 0 1]
\end{minipage}%
\begin{minipage}[b]{0.35\linewidth}
\chessboard[smallboard,setfen=8/p7/P5p1/1P4P1/5P2/3kb3/8/3K4 w - - 0 1]
\end{minipage}%
\end{document}
答案1
您的国际象棋包加载了tizk
,因此您可以使用\foreach
。在您的文档中,您会收到大量关于页面过满的投诉,因此我将页面做得稍微宽一些(并添加了showframe
显示它是否有效以及剩余多少空间)。然后您可以在嵌套循环中绘制完整的内容\foreach
。
\documentclass{article}
\usepackage{xskak,chessboard}
\usepackage[showframe,margin=1cm]{geometry}
\begin{document}
\foreach \X/\Y in
{basic/{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},
%******* PAWN LEVEL *****************
pawn/{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},
%************ 2 PAWN LEVEL *******************
2 pawns/{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},
%************ MINOR + PAWN LEVEL ********************
Minor + Pawns/{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.3\linewidth}
\chessboard[smallboard,setfen=\Z]
\end{minipage}}
}
\end{document}
[![在此处输入图片描述][1]][1]
这是 Ulrike Fischer 的评论后的另一个版本(谢谢!)。\par
如果一行中有超过 3 个 FEN,它会添加。
\documentclass{article}
\usepackage{xskak,chessboard}
\usepackage[showframe,margin=1cm]{geometry}
\begin{document}
\foreach \X/\Y in
{basic/{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},
%******* PAWN LEVEL *****************
pawn/{8/8/8/8/8/1k6/7P/4K3 w - - 0 1,
8/8/8/8/4k3/4p3/4K3/8 w - - 0 1,
8/8/8/8/4k3/4p3/4K3/8 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},
%************ 2 PAWN LEVEL *******************
2 pawns/{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},
%************ MINOR + PAWN LEVEL ********************
Minor + Pawns/{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 [count=\Cnt] in \Y
{\pgfmathtruncatemacro{\itest}{ifthenelse(\Cnt==1,1,mod(\Cnt-1,3))}%
\ifnum\itest=0%
\par
\fi%
\begin{minipage}[b]{0.3\linewidth}
\chessboard[smallboard,setfen=\Z]
\end{minipage}%
}
\par
}
\end{document}