This code draws the first hexagram of the I Ching:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{math}
\usepackage{ifthen}
\begin{document}
\begin{tikzpicture}
\tikzset{
hexagram/.pic={
\foreach \d [count=\n] in {#1}{
\ifthenelse{\d=0}
{\draw [yshift=\n*2cm, line width=1cm, purple] (-6,0) -- (-1,0) (1,0) -- (6,0);}
{\draw [yshift=\n*2cm, line width=1cm, purple] (-6,0) -- (6,0);}
}}
}
\pic at (15,0) {hexagram = {0,0,0,0,0,0}};
\end{tikzpicture}
\end{document}
When I try to draw all the remaining 63 hexagrams with a foreach I obtain an error, as if foreach was not able to cope with lists whose elements are lists: replacing the line
\pic at (15,0) {hexagram = {0,0,0,0,0,0}};
with, say,
\foreach [count=\n] \m in {{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 1, 1},
{0, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 0, 1},
{0, 0, 0, 1, 1, 0},
{0, 0, 0, 1, 1, 1}}{
\pic at (\n*15,0) {hexagram = \m};
}
I obtain a
./iching2.tex:28: Missing = inserted for \ifnum. [}]
./iching2.tex:28: Missing number, treated as zero. [}]
error. What shall I do?
