# How can we correctly implement a list of two (calculated) variables?

I want to use foreach to loop through two variables at the same time, in Tikz. I'd like to go through the variable \y from 0 to 7. At the same time, I'd like to go through \yy from 0 to 14, by increments of 2. I'd like to know how to do this without writing out the entire list.

For example, the following code works:

 \foreach \y / \yy in {0/0, 1/2, 2/4, 3/6, 4/8, 5/10, 6/12, 7/14}
\node at (0,\y) {\y -- \yy};


But I can't seem to get this code to work:

 \foreach \y / \yy in {0/0, 1/2, ..., 7/14}
\node at (0,\y) {\y -- \yy};


I'm planning on using LOTS of loops like this, so I'm really trying to figure out how to get a double loop with the dots to work. Any suggestions?

-

Why not using a single variable and evaluate?

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\foreach \y [evaluate=\y as \yy using int(2*\y)] in {0,...,7}
\node at (0,\y) {\y -- \yy};
\end{tikzpicture}

\end{document}


-
Evaluate, from what I've seen, gives values like 2.0 and 4.0. I just want the integer value. But thanks for the idea, +1 for you! By the way, is there a way to get evaluate to give integer values? –  Matt Groff Feb 22 at 3:28
@MattGroff Of course, you can truncate the value. –  Gonzalo Medina Feb 22 at 3:28
@MattGroff: int(2*\y) –  Heiko Oberdiek Feb 22 at 3:29
@MattGroff as Heiko said in his comment, or with \pgfmathroundto. –  Gonzalo Medina Feb 22 at 3:30

Possible also

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\foreach \y in {0,...,7}
{ \pgfmathtruncatemacro{\yy}{2*\y}
\node  at (0,\y) {\y -- \yy};
}
\end{tikzpicture}


\end{document}

-
Just for fun with fp.
\documentclass[preview,border=12pt,12pt,varwidth]{standalone}
\multido{\i=0+1}{10}{\FPeval\temp{round(sin(\i):6)} $(\i,\temp)$\endgraf}