Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\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?

share|improve this question
3  
\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
1  
Welcome! –  Andrey Vihrov Mar 10 '11 at 8:12

3 Answers 3

up vote 11 down vote accepted

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).

share|improve this answer
    
one typo detected. –  xport Mar 10 '11 at 8:16
2  
@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}
share|improve this answer
\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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.