According to the TEX in a Nutshell, Petr Olšák, page 16/29, we get:
\ifnum ⟨number 1⟩ ⟨relation⟩ ⟨number 2⟩ . The ⟨relation⟩ could be < or = or >. It returns true if the comparison of the two numbers is true.
I am looking for a more powerful conditional command to include (~=) (not equal to) relation.
- Do we have such a conditional command?
The reason I asked is related to page 1005/1318 TikZ manual. Which I modified the code a little bit to generate an array of elliptical objects as below:
I rotated all ellipses 45 degree clockwise. What I want to do is not to rotate the highlighted ellipses in yellow so the rot=0
for them.
- How to do it with a conditional command?
Below is my code:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {1,...,4}
\foreach \y in {1,...,4}
{
\fill[red!50] (\x,\y) ellipse [x radius=3pt, y radius=6pt, rotate=-45];
\ifnum {\x<\y} & {\x>1}
\breakforeach
\fi
}
\draw [|-|] (.895,1) -- ++(0.211,0);
\end{tikzpicture}
\end{document}
It seems ifthen package is the answer. I used the code below using \ifthenelse, but got an error:
\documentclass{standalone}
\usepackage{tikz,ifthen}
\begin{document}
\ifthenelse{1>2 \AND 3=3}{yes}{no}
\begin{tikzpicture}
\foreach \x in {1,...,4}
\foreach \y in {1,...,4}
{
\newcommand{\first}{\(\x=1 \and \y=1\)}
\newcommand{\second}{\(\x=2 \and \y=1\) }
\ifthenelse{\(\first\) \or \(\second\)}
{\fill[red!50] (\x,\y) ellipse [x radius=3pt , y radius= 6pt, rotate=0];}
{\fill[red!50] (\x,\y) ellipse [x radius=3pt , y radius= 6pt, rotate=-45];}
\ifnum \x<\y
\breakforeach
\fi
}
\draw [|-|] (.895,1) -- ++(0.211,0);
\end{tikzpicture}
\end{document}
Error: ! Extra \or. ...=1) } \ifthenelse {(\first ) \or (\second )} {\fill [red!... Do you know how to debug this code to make it work?