# Why doesn't ellipse (\p and 1) work?

\documentclass{article}

\usepackage{tikz}

\begin{document}

% DOES NOT WORK
%\tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (\p and 1);

%WORKS
\tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (1 and \p);

\end{document}


(1 and \p) works but (\p and 1) does not, why?

-
\p{} and 1, however, works. –  Andrey Vihrov Mar 10 '11 at 7:58
@Andrey: If you make your comment as an answer, I will mark it as the answer. –  xport Mar 10 '11 at 8:05
Welcome! –  Andrey Vihrov Mar 10 '11 at 8:12

Spaces after TeX commands are ignored, thus by using \p and 1 you'll get an equivalent of, say, 1and 1, which you can verify to give the same error. Therefore we just need to restore the space:

\tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (\p{} and 1);


Note that, as Jake mentions, this syntax is deprecated (refer to the TikZ manual).

-
one typo detected. –  xport Mar 10 '11 at 8:16
@xport: you can also write ({\p} and 1 ) but I think {\p}and \p{ } are not fine , the better way is x radius =and y radius= –  Alain Matthes Mar 10 '11 at 9:00
@Altermundus: OK. Thanks. –  xport Mar 10 '11 at 9:15

The (<x radius> and <y radius>) syntax is old and, if not deprecated, at least not encouraged any more. The current way to do is is to use [x radius] and [y radius]:

\documentclass{article}

\usepackage{tikz}

\begin{document}

% WORKS with current syntax
\tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse [x radius=\p, y radius=1];

%WORKS
\tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse [x radius=1, y radius=\p];

\end{document}

-
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (\p cm and 1 cm);
\tikz \foreach \p in {1,2,...,3} \draw (\p,0) ellipse (1 cm and \p cm);
\end{document}


problem with the parser, I suppose ! and the remark of Jake is fine, better now it's to use x radius and y radius

-