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.

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 :

\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}$}} ;} 
share|improve this question
1  
Works just fine with me. Maybe you have an older version of tikz and should update? –  Count Zero May 27 '12 at 13:31
1  
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
1  
Add \pgfversion after \begin{document}to see your pgf version –  Alain Matthes May 27 '12 at 14:02
1  
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
add comment

1 Answer

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
add comment

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.