下面这行
\foreach \x / \y in {0.422201/1.000000,1.000000/2.368540}
{\draw[very thin] (0,0) ellipse (\x and \y)};
给出
ERROR: Package PGF Math Error: Unknown operator `a' or `an' (in '0.422201and 1.000000').
然后我尝试了一下,(\x{} and \y)
因为它看起来像是一个空间问题,但它也不起作用。
ERROR: Undefined control sequence.
--- TeX said ---
\pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@
l.10 ...aw[very thin] (0,0) ellipse (\x{} and \y)}
这是文档
\documentclass{article}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-1.5,-1.5) rectangle (4,4);
\begin{scope}[rotate=12.549]
\foreach \x / \y in {0.422201/1.000000,1.000000/2.368540}
{\draw[very thin] (0,0) ellipse (\x and \y)};
% \draw[very thin] (0,0) ellipse (0.422201 and 1.000000);
% \draw[very thin] (0,0) ellipse (1.000000 and 2.368540);
\draw[very thin] (0,0) ellipse (1.349721 and 3.196868);
\draw[very thin] (0,0) ellipse (1.625882 and 3.850967);
\draw[very thin] (0,0) ellipse (1.861515 and 4.409073);
\draw[very thin] (0,0) ellipse (2.070504 and 4.904071);
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
以及预期结果
答案1
您必须将\x
and括\y
在括号内(最好是安全的),因为后面的空格\x
会被吞掉,从而形成0.422201and
。此外,您必须将;
右括号放在
{\draw[very thin] (0,0) ellipse ({\x} and {\y});}
用这些,
\documentclass{article}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-1.5,-1.5) rectangle (4,4);
\begin{scope}[rotate=12.549]
\foreach \x / \y in {0.422201/1,1/2.368540,1.349721/3.196868,1.625882/3.850967,1.861515/4.409073,2.070504/4.904071}
{\draw[very thin] (0,0) ellipse ({\x} and {\y});
}
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
答案2
您可以使用省略号的替代语法:
% arara: pdflatex
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-1.5,-1.5) rectangle (4,4);
\begin{scope}[rotate=12.549]
\foreach \x/\y in {0.422201/1.000000,1.000000/2.368540,1.349721/3.196868,1.625882/3.850967,1.861515/4.409073,2.070504/4.904071}
\draw[very thin] (0,0) ellipse [x radius=\x,y radius=\y];
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}