What I am up to is writing a periodic table. The original code I am working with did not include much information and was able to use a command to put everything into a "minipicture" for each element. Mine includes much more information and the command would include more than 9 arguments, which apparently is too many.
So I've switched to arrays. I can do this by putting all of the information into a 2D array: Elements[0][...] is a vector for Hydrogen, Elements[1][...] is a vector for He, etc. The problem here is that the matrix Elements is rather large and seems to be slowing the system considerable when compiling.
So I thought I'd try the following idea: I know(?) that it is possible to create a variable name, something like x\i, where \i is a variable. So, instead of one big 2D array, I'd create a list of 108 individual arrays ordered by atomic number. So now Element1[...] would be a vector representing H, Element2[...] would represent He, etc.
So we get to the code. If I have to manually enter each array we have the code below for two "elements", x and y. I have to put in code to make a minipicture for each of x and y. But is there a way I can call them x1 and x2 and reference them (something like) x\i[...] in a foreach loop?
Thanks!
-Dan
Code: Select all
\def\print#1{\pgfmathparse{#1}\pgfmathresult}
\def\x{{1,2,3,4}}
\def\y{{1,2,3,4}}
\begin{tikzpicture}
\node at (0,0) {
\begin{tikzpicture}[x=1cm,y=1cm]
{\node at (0.12,-0.12) {\print{\x[0]}};}
{\node at (0.88,-0.12) {\print{\x[1]}};}
{\node at (0.88,-0.88) {\print{\x[2]}};}
{\node at (0.12,-0.88) {\print{\x[3]}};}
\end{tikzpicture}
};
\node at (2,0) {
\begin{tikzpicture}[x=1cm,y=1cm]
{\node at (0.12,-0.12) {\print{\y[0]}};}
{\node at (0.88,-0.12) {\print{\y[1]}};}
{\node at (0.88,-0.88) {\print{\y[2]}};}
{\node at (0.12,-0.88) {\print{\y[3]}};}
\end{tikzpicture}
};
\end{tikzpicture}