I'm having trouble writing if statements, I can find next to no documentation on them and what I want to do seems quite simple.
I'm using the orbitals pgf/tikz example from here, and I'd like to write a new atom type, whereby instead of the third argument, it takes phrase describing squashedness
Normally, the code to create an atom looks like this:
\Atom{}{90/west/0,270/east/1}
So I wrote a separate method which I'm trying to modify that
\AtomSquash{}{90/west/sq,270/east/sq}
The code for creating the atoms is as follows
\newcommand{\Atom}[3][AtomNode]{
\node[atomcore] (#1){#2};% {\ce{#2}};
\foreach \ang/\anchor/\n in {#3} {
\orbital{\ang}{#1.\anchor}{\n}
}
}
\newcommand{\AtomSquash}[3][AtomNode]{
\node[atomcore] (#1){#2};
\foreach \ang/\anchor/\squashness in {#3}{
\squashorbital{\ang}{#1.\anchor}{\squashness}
}
}
And the orbital code:
\newcommand{\orbital}[3]{
\begin{scope}[rotate=#1,shift=(#2)]
% These points define the curve for the orbital.
\coordinate (c1) at (-\orbwidth, .6 * \orbheight);
\coordinate (c2) at (-\orbwidth, \orbheight);
\coordinate (c3) at (\orbwidth, \orbheight);
\coordinate (c4) at (\orbwidth, .6 * \orbheight);
\coordinate (top) at (0,\orbheight);
%Coordinates of the electrons
\coordinate (e1) at (0, 0.45*\orbheight);
\coordinate (e2) at (0, 0.75*\orbheight);
\end{scope} \begin{pgfonlayer}{background}
\draw[orbital #3] (#2) .. controls (c1) and (c2) .. (top) ..
controls (c3) and (c4) .. (#2);
\end{pgfonlayer}
% Draw the electrons
\ifnum#3>0
\foreach \n in {1,...,#3} {
%Don't need electrons to be shaded.
%\shade[ball color=electron] (e\n) circle (1mm);
}
\fi
}
What I would especially like to do here, is have the \atom and \atomsquash in a single method, which would decide based on the number of arguments or say the text value of the third argument (is it equal to "sq" or is it a number?). I've tried writing an if statement that looks like the following \iftype=sq but the compiler seriously dislikes this. It doesn't help if I put quotes around the sq, the code will compile then but the if statement never is true.
Help?
\iftype; this is not a defined control sequence as far as I know. Which code did compile? – Hendrik Vogt Oct 28 '10 at 8:47