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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to draw something like this. enter image description here

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

enter image description here

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


\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) {};


\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}$}} ;}


But I am getting a compilation error like this:

 Use of \i doesn't match its definition ... node[right]{\footnotesize{$x_{\xi}$}} ;} 
share|improve this question
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) 

This key allows ⟨macro⟩ to hold the position in the list of the current item. The optional from ⟨value⟩ statement allows the counting to begin from ⟨value⟩.

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.

share|improve this answer

Your Answer


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.