Tikz 文本错误

Tikz 文本错误

当我使用 tikz 文本时遇到此错误,您能告诉我哪里出了问题吗?

Package pgfkeys Error: The key '/tikz/text' requires a value. I
am going to ignore this key.

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

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text            centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]

\tikzstyle{text} = [text width=0.5cm,text centered]


\title{Communication protocol}
\author{beltagymohamed }
\date{June 2015}

\begin{document}

\maketitle

\section{Introduction}

\newpage
%sadas

\begin{tikzpicture}[node distance=2cm]

\node (in1) [io, below of=start] {Enter Command };
\node (okok) [decision, below of=done, yshift= -2.5cm] {Every thing is O.K.?};                    

% Connect okok yes to enter command 
\draw [arrow] (okok)-|   ([xshift=1.5cm]  okok.east) |-   (in1) ;
\node[text, below left of=okok,xshift= 3.6cm,yshift= 1.6cm] (okokyes) {Yes}; 


\end{tikzpicture}

\end{document}

答案1

节点startdone未定义,因此我无法使用它们。text正如@Daniel Schlegel 指出的那样,错误在于您无法重新定义它。如果您将其更改为,则Mytext一切正常。

我对您的图表做了一些小改动,请检查是否一切符合您的要求。

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{tikz}

\usetikzlibrary{shapes.geometric, arrows, positioning}
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{Mytext} = [text width=0.5cm,text centered]

\title{Communication protocol}
\author{beltagymohamed }
\date{June 2015}

\begin{document}

\maketitle

\section{Introduction}

\newpage

\begin{tikzpicture}[node distance=2cm]

%Nodes
\node (start) [startstop] {START};
\node (in1) [io, below =of start] {Enter Command };
\node (okok) [decision, below =of in1, yshift= -2.5cm] {Every thing is O.K.?};
\node (stop) [startstop,below = of okok] {STOP};

% Arrows
\draw[arrow] (start.south) to (in1.north);
\draw[arrow] (in1.south) to (okok.north);
\draw [arrow] (okok) -| node[Mytext,pos=0.1,above] (okokyes) {Yes}  ([xshift=1.5cm]  okok.east) |-   (in1) ;
\draw [arrow] (okok.south) -- node[Mytext,pos=0.1,right] (okokno) {No} (stop);
\end{tikzpicture}

\end{document}

得出的结果为:

在此处输入图片描述

相关内容