Note: This is a major edit to my original question. I intended to ask another question for the second problem separately, but it has already been initiated in the comment and probably already answered here. So I have edited this question instead to cover all two of them.
FIRST Problem: Illegal unit of measure: (pt inserted)
I am facing a similar problem as "Illegal unit of measure (pt inserted)" using arithmetic in TikZ foreach. Except that I am using negative decimal numbers as well as positive decimal numbers and I have used three dots here for the interval. The MWE is as below:
\documentclass[border=3mm,tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x/\y in {-1.4/-1.4,-1.2/-1.2,...,1.6/1.6}{
\filldraw (\x,\y) circle [radius=2pt];}
\end{tikzpicture}
\end{document}
How do I fix this? I know there is an alternative way to get the same picture. But I am experimenting with this for some purpose. I have passed here equal values of x and y. The problem is not that if there is an alternative way to make the same picture. The problem is that if there is a way to workaround with this error and get rid of it. This is because I may change the values of y and may still find the same error lurking in.
SECOND Problem: Using two foreach to make an ordered pair
The second problem is how I can use two foreach
commands to make an ordered pair so that one doesn't iterate over the iteration of the other, but forms a one-to-one correspondence or something like that. Some suggests to use evaluate
in foreach
. This is okay when I know y depends on x. But how about when y doesn't depend on x at all? When y has some random values for example? The MWE is
\documentclass[border=3mm,tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \x in {1,...,9}
\foreach \y in {2,5,4,6,9,1,3,8,7}
\filldraw (\x,\y) circle [radius=10pt];
\end{tikzpicture}
\end{document}
which gives:
What I want is:
evaluate
.