~tex-sx/tex-sx/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
\immediate\write18{tex matrixcolours.dtx}
\documentclass{article}
\usepackage{tikz}
\usepackage{matrixcolours}


\pgfdeclarelayer{back}
\pgfsetlayers{back,main}

\begin{document}

\begin{tikzpicture}
\matrix [label cells,draw,inner sep=20pt,matrix of nodes, row sep=10mm, column sep=10mm, nodes={draw, thick, circle, inner sep=10pt,minimum size=1cm}] (ma)
     { & 1000000 & &[2mm]|[gray]|1\\
       & & 2 &|[gray]|2\\
      |[gray]|2 & & &|[gray]|2\\[4mm]
       3 & & & 3\\
      };

\begin{pgfonlayer}{back}
\foreach \i in {1,...,4}
\foreach \j in {1,...,4} {
  \pgfmathparse{Mod(\i + \j,2) ? "red" : "blue"}
  \colorlet{sqbg}{\pgfmathresult}
       \fill[sqbg] (ma-cell-\i-\j.north west) rectangle (ma-cell-\i-\j.south east);
}
\end{pgfonlayer}
\end{tikzpicture}

\begin{tikzpicture}
\matrix [matrix of nodes, name=mb, label cells, inner sep=10pt] {
A & B \\
C & D \\
};
\begin{pgfonlayer}{back}
\foreach \i in {1,...,2}
\foreach \j in {1,...,2} {
  \pgfmathparse{Mod(\i + \j,2) ? "red" : "blue"}
  \colorlet{sqbg}{\pgfmathresult}
       \fill[sqbg] (mb-cell-\i-\j.north west) rectangle (mb-cell-\i-\j.south east);
}
\end{pgfonlayer}
\end{tikzpicture}

% Permutations:
% matrix, label cells, name: works
% matrix, name, label cells: works
% label cells, matrix, name: works
% label cells, name, matrix: works
% name, matrix, label cells: works
% name, label cells, matrix: works

\begin{tikzpicture}
\node [matrix,label cells,  matrix of nodes, inner sep=10pt](md) {
A & B \\
C & D \\
};
\begin{pgfonlayer}{back}
\foreach \i in {1,...,2}
\foreach \j in {1,...,2} {
  \pgfmathparse{Mod(\i + \j,2) ? "red" : "blue"}
  \colorlet{sqbg}{\pgfmathresult}
       \fill[sqbg] (md-cell-\i-\j.north west) rectangle (md-cell-\i-\j.south east);
}
\end{pgfonlayer}
\end{tikzpicture}

\end{document}


% Local Variables:
% tex-output-type: "pdf18"
% End: