1

I have found this sample of code from here: Block diagram generation in LaTeX. Initially I had some problems while I was compiling the code and I solved them due to copy paste features some of the characters where altered. Although that the code seems correct to me, I keep getting this error:

! Package tikz Error: Giving up on this path. Did you forget a semicolon?.

 See the tikz package documentation for explanation.
 Type  H <return>  for immediate help.
 ...                                              

 l.20 \draw [->] (controller)
                                �� node[name=u] {$u(k)$} (system);
 ? 

Since I am new to tikz package I can not see the error, all parts of the node seems to have the semi-column. What am I missing here?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,automata}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}

\begin{document}

\tikzstyle{block} = [draw, rectangle, minimum height=2em, minimum width=4em]
%fill=blue!20
\tikzstyle{sum} = [draw, fill=blue!20, circle, node distance=1cm]
\tikzstyle{input} = [coordinate] \tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]

\begin{tikzpicture}[auto, node distance=2cm,>=latex']
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum, node distance=3.5cm] (controller) {$C(z^{-1})$};
\node [block, right of=controller, pin={[pinstyle]above:$d(k)$}, node distance=4cm] (system) {$P(z^{-1})$};
\draw [->] (controller) – node [name=u] {$u(k)$} (system);
\node [output, right of=system] (output) {};
\node [block, below of=u] (measurements) {$F(z^{-1})$};
\draw [draw,->] (input) – node {$r(k)$} (sum);
\draw [->] (sum) – node {$e(k)$} (controller);
\draw [->] (system) – node [name=y] {$y(k)$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$} node [near end] {$y_m(k)$} (sum);
\end{tikzpicture}

\end{document}

closed as off-topic by egreg, Jesse, Claudio Fiandrino, Svend Tveskæg, Peter Jansson Mar 13 '14 at 13:47

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    -- have been converted to an en-dash from your editor. you need to replace them. – Johannes_B Mar 13 '14 at 11:22
  • Your posted code contains strange characters/control characters, e.g. at (controller) - node and similar lines. Remove those and it should work. – user31729 Mar 13 '14 at 11:22
  • I think you have an en-dash (–) instead of a hyphen (-). Hard to spot in most fonts, but the black ? marks in the error are a bit of a give away. – Thruston Mar 13 '14 at 11:23
  • 4
    This question appears to be off-topic because it is about a non reproducible problem due to invisible characters in the input – egreg Mar 13 '14 at 13:01
  • @egreg you mean I should change the title of the question? Because the code and errors are reproducible? Thanks for the advices. – Thanos Mar 13 '14 at 13:46
3

You are absolutely right @Johannes_B, something so small can produce so many problems when someone has never used tikz. Thank you all for your time and effort. I will also post the updated version just in case that someone might occur the same error as me.

 \documentclass{article}
 \usepackage{tikz}
 \usetikzlibrary{shapes,arrows,automata}
 \usepackage{pgfplots}
 \pgfplotsset{compat=1.8}

\begin{document}

\tikzstyle{block} = [draw, rectangle, minimum height=2em, minimum width=4em] %fill=blue!20
\tikzstyle{sum} = [draw, fill=blue!20, circle, node distance=1cm]
\tikzstyle{input} = [coordinate] \tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]

\begin{tikzpicture}[auto, node distance=2cm,>=latex']
\node [input, name=input] {};
\node [sum, right of=input] (sum) {};
\node [block, right of=sum, node distance=3.5cm] (controller) {$C(z^{-1})$};
\node [block, right of=controller, pin={[pinstyle]above:$d(k)$}, node distance=4cm] (system) {$P(z^{-1})$};
\draw [->] (controller) -- node [name=u] {$u(k)$} (system);
\node [output, right of=system] (output) {};
\node [block, below of=u] (measurements) {$F(z^{-1})$};
\draw [draw,->] (input) -- node {$r(k)$} (sum);
\draw [->] (sum) -- node {$e(k)$} (controller);
\draw [->] (system) -- node [name=y] {$y(k)$}(output);
\draw [->] (y) |- (measurements);
\draw [->] (measurements) -| node[pos=0.99] {$-$} node [near end] {$y_m(k)$} (sum);
\end{tikzpicture}

\end{document}

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