! 软件包 tikz 错误:缺少分号

! 软件包 tikz 错误:缺少分号

我从这里找到了这个代码示例:LaTeX 中的框图生成。最初我在编译代码时遇到了一些问题,我解决了这些问题,因为复制粘贴功能导致一些字符被更改。虽然代码对我来说似乎是正确的,但我一直收到此错误:

! 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);
 ? 

由于我是 tikz 包的新手,我看不到错误,节点的所有部分似乎都有分号。我在这里遗漏了什么?

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

答案1

@Johannes_B 你说得完全正确,对于从未使用过 tikz 的人来说,这么小的事情也会产生很多问题。感谢大家的时间和精力。我还会发布更新版本,以防有人可能遇到与我相同的错误。

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

相关内容