1

I finished my phd a couple of months ago, compiled it then completely just fine. I opened it today to make changes and during compilation I get error messages about "missing number treated as zero". I realized it is about brackets are used when computing a value.

for instance this works :

\documentclass{article}
\usepackage{pgfplots}
\usepackage{tikz}

\begin{document}
 \begin{tikzpicture}
 \def\x{5};
 \def\y{4.5};
\foreach \p in {180,160,...,20}
{
\draw (0,0) -- (\x*\p:\y*\p/100);
}
\end{tikzpicture}
\end{document}

and this does not work, whereas it worked perfectly fine 2 months ago

\documentclass{article}
\usepackage{pgfplots}
\usepackage{tikz}

\begin{document}

 \begin{tikzpicture}
 \def\x{5};
 \def\y{4.5};
\foreach \p in {180,160,...,20}
{
\draw (0,0) --({\x*(\p-20)}:{\y*({1.80-\p/100})});
}
\end{tikzpicture}

\end{document}
Thorsten
  • 12,872
  • Your distribution must have updated. I get identical results with the current TeXLive2011 and the older TeXLive2010, which has not changed in many months. – Peter Grill Jan 23 '12 at 22:10
  • @PeterGrill I've a problem with the last version of pgf and the last TL with the second code – Alain Matthes Jan 23 '12 at 22:19
  • The code can be made to work again with \draw (0,0) --({\x*(\p-20)}:{\y*(1.80-\p/100});. But still the reason eludes me. – percusse Jan 23 '12 at 22:29
  • @Altermundus: Sorry if I was not clear. I meant I get Missing number, treated as zero. in both TeXLive2011 and the older TexLive2010. But the OP suggested that this used to work a few months ago but is not now. – Peter Grill Jan 23 '12 at 22:57

1 Answers1

3

Perhaps a bug. I've also this problem with pgf 2.1 cvs. Look at this question.

Update : it was a bug, thanks cjorssen for correcting it.

The solution is no useful but it's sometimes a good idea to use variables.

A solution is

\documentclass{article}
\usepackage{pgfplots}
\usepackage{tikz}

\begin{document}

 \begin{tikzpicture}
 \def\x{5};
 \def\y{4.5};
\foreach \p in {180,160,...,20}
{%
\pgfmathsetmacro{\tmp}{\y*(1.80-\p/100)}
\draw (0,0) --({\x*(\p-20)}:\tmp);
}
\end{tikzpicture}

\end{document} 

Another one is :

   \draw (0,0) --({\x*(\p-20)}:\y*(1.80-\p/100);

but I don't like this hack

Alain Matthes
  • 95,075