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

相關內容