如何使用两个变量和一个值列表进行 foreach 迭代

如何使用两个变量和一个值列表进行 foreach 迭代

当我使用包含两个变量的列表时,foreach 迭代会带来错误,正如您在 mwe 中看到的那样。有解决方案吗?正如输出 PDF 所示,尝试使用列表时会发生错误。如何集成 mwe?

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}

\begin{document}
%two variables
\foreach \x   in    {1.00,1.033,...,2.000,2.033,2.083,...,3.000,3.050,3.15,...,4.000}
{
   x \x ;
}

% output 3 series of variables(x and y). 1. between 1 and 2 thirty steps,   2. betw. 2 a. 3 twenty steps, 3. betw. 3 a. 4 ten steps. thats the aim. here  shortened to the end of three(3.000)
\foreach \x / \y in 
   %{1.00/1.033,1.033/1.066}% 0 errors, pdf ok
   {1.00/1.033,1.033/1.066,...,2.000/2.033} % 63 errors, pdf output gen  erated! shows wrong variable contents
   % third version 88 errors, but pdf generated! shows wrong variable values
   %{1.00/1.033,1.033/1.066,...,2.000/2.033,2.033/2.066,2.116/2.166,...,3.000/3.050}
   {
      x1: \x,  y1: \y \\
   }
\end{document}

相关内容