# how to use “count” feature?

I want to draw something like this.

But I am not able to get x1,x2, ..., x5 labels. What I am getting is as follows:

So, I included count feature. My code is as follows :

\begin{tikzpicture}[thick]
\tikzset{input/.style={}}
\tikzset{block/.style={rectangle,draw}}

\node [input, name=input] {};
\node [block, right=1cm of input,minimum width=3cm, minimum height=2.5cm] (a) { };
\node [block, right of=a,minimum width=3cm, minimum height=5cm,node distance=5cm] (b) {};

\begin{scope}[->,>=latex]

\draw[->] (input) -- (a);

\foreach \i [count=\xi] in {2,...,-2}{%
\draw[->] ([yshift=\i * 0.4 cm]a.east) -- ([yshift=\i * 0.8 cm]b.west) node[right]{\footnotesize{$x_{\xi}$}} ;}

\end{scope}
\end{tikzpicture}


But I am getting a compilation error like this:

 Use of \i doesn't match its definition ... node[right]{\footnotesize{$x_{\xi}$}} ;}

-
Works just fine with me. Maybe you have an older version of tikz and should update? – Count Zero May 27 '12 at 13:31
The count feature was added to PGF for version 2.1; however, older TeX distros just ship version 2.0. So my first assumption would be that your PGF package is a bit outdated. – Daniel May 27 '12 at 13:56
Add \pgfversion after \begin{document}to see your pgf version – Alain Matthes May 27 '12 at 14:02
When you post code it is preferable create a minimal working example with the documentclass and packages you use. – Claudio Fiandrino May 27 '12 at 14:13
I had installed it using Synaptic Package Manager. How do I update it now ? – tikzlearner May 27 '12 at 17:36

No problem to compile but in your example you need to use the library positioning. I think it's preferable to give us a complete example, to see if a conflict appears between packages. It's interesting also when you get an error like this to give us the version of the packages that you used.
You can find a lot of examples on tex.se with [count=\xi].
  /pgf/foreach/count=⟨macro⟩from⟨value⟩ (no default)

By default the first value of \xi is 1, and you can count the number of iterations for -2 to 2 the last value is 5.