如何在 tikz 中绘制非直箭头并减少形状的宽度?

如何在 tikz 中绘制非直箭头并减少形状的宽度?

我有以下图表tikz。我需要绘制一个箭头,该箭头从水平开始,然后从决策形状垂直到带有标签的末端no。我尝试使用-|而不是--但这会产生错误。

1)如何绘制箭头(如我为了说明而添加的红色箭头?

2)如何减小io形状的宽度(\tikzstyle{io})?

这是我的形状: 在此处输入图片描述

我的脚本是:

\documentclass[10pt]{llncs}
\usepackage{tikz} 
\usetikzlibrary{shapes.geometric, arrows} 
\title{title}
\author{Authors here\\
    \small{Department here}\\
    \small{University here, Country}\\
}
\date{}

\begin{document}
\maketitle

\section{Chart}
\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=3cm, 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]

\begin{tikzpicture}[node distance=2cm]
\node (start) [startstop] {Start};
\node (in01) [io, below of = start] {xxxxxxx xxxx};
\node (proc01) [process, below of = in01] {aaaaaaa aaaaaaa aaaaaaa};
\node (proc02) [process, below of = proc01] {ccccccc};
\node (dec01) [decision, below of = proc02] {bbb-bb?};
\node (proc03) [process, below of = dec01, , yshift=-0.5cm] {aaaaaaa aaaaaaa aaaaaaa};
\node (proc04) [process, below of = proc03] {ccccccc};
\node (end) [startstop, below of = proc04] {End};

\draw [arrow] (start) -- (in01);
\draw [arrow] (in01) -- (proc01);
\draw [arrow] (proc01) -- (proc02);
\draw [arrow] (proc02) -- (dec01);
\draw [arrow] (dec01) -- node[anchor=east]{Yes} (proc03);
%\draw [arrow] (dec01) -- node[anchor=east]{No} (end);
\draw [arrow] (proc03) -- (proc04);
\draw [arrow] (proc04) -- (end);
\end{tikzpicture}
\end{document}

答案1

您需要添加trapezium stretches body。(也转换\tikzstyle为更现代的语法。)编辑:已添加编号。

\documentclass[border=3.14mm,tikz,x11names,dvipsnames,svgnames]{standalone}
\usetikzlibrary{shapes.geometric, arrows} 
\begin{document}
\tikzset{startstop/.style={rectangle, rounded corners, minimum width=3cm, minimum
height=1cm,text centered, draw=black, fill=red!30},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum
width=1cm,   %<- changed
trapezium stretches body,%<- added
 minimum height=1cm, text centered, draw=black, fill=blue!30},
process/.style={rectangle, minimum width=3cm, minimum height=1cm, text centered,
text width=3cm, draw=black, fill=orange!30},
decision/.style={diamond, minimum width=3cm, minimum height=1cm, text centered,
draw=black, fill=green!30},
arrow/.style={thick,->,>=stealth}}

\begin{tikzpicture}[node distance=2cm]
\node (start) [startstop] {Start};
\node (in01) [io, below of = start] {xxxxxxx xxxx};
\node (proc01) [process, below of = in01] {aaaaaaa aaaaaaa aaaaaaa};
\node (proc02) [process, below of = proc01] {ccccccc};
\node (dec01) [decision, below of = proc02] {bbb-bb?};
\node (proc03) [process, below of = dec01, , yshift=-0.5cm] {aaaaaaa aaaaaaa aaaaaaa};
\node (proc04) [process, below of = proc03] {ccccccc};
\node (end) [startstop, below of = proc04] {End};

\draw [arrow] (start) -- (in01);
\draw [arrow] (in01) -- (proc01);
\draw [arrow] (proc01) -- (proc02);
\draw [arrow] (proc02) -- (dec01);
\draw [arrow] (dec01) -- node[anchor=east]{Yes} (proc03);
%\draw [arrow] (dec01) -- node[anchor=east]{No} (end);
\draw [arrow] (proc03) -- (proc04);
\draw [arrow] (proc04) -- (end);
\draw [arrow,rounded corners,red,thick] (dec01.east) -- ++(1cm,0) |- (end)
node[pos=0.1,sloped,above]{No};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

作为补充土拨鼠答案(解决你的问题)主要是作为练习如何为你的简单流程图编写更短的代码......

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, chains, shapes.geometric}

\tikzset{FlowChart/.style = {% for distinguish from other tikz sets used in your document
     base/.style = {rectangle, draw,
                    minimum width=3cm, minimum height=1cm, align=center,
                    text width =\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner xsep},
                    on chain, join=by arrow},
startstop/.style = {base, fill=red!30, rounded corners},
       io/.style = {trapezium, trapezium left angle=70, trapezium right angle=110,
                    trapezium stretches body,
                    draw=black, fill=blue!30,
                    minimum width=1cm, minimum height=1cm, align=center,
                    on chain, join=by arrow},
   process/.style = {base, fill=orange!30},
  decision/.style = {diamond, aspect=1.2, draw, fill=green!30,
                     minimum width=3cm, minimum height=1cm, align=center,
                     on chain, join=by arrow},
     arrow/.style = {thick,-Stealth}}
        }

\begin{document}
    \begin{tikzpicture}[FlowChart,
  node distance = 6mm and 12mm,
    start chain = going below]
% nodes
\node (start)   [startstop] {Start};
\node (in01)    [io]        {xxxxxxx xxxx};
\node (proc01)  [process]   {aaaaaaa aaaaaaa aaaaaaa};
\node (proc02)  [process]   {ccccccc};
\node (dec01)   [decision]  {bbb-bb?};
\node (proc03)  [process]   {aaaaaaa aaaaaaa aaaaaaa};
\node (proc04)  [process]   {ccccccc};
\node (end)     [startstop] {End};
% extra paths
\path           (dec01) -- node[right] {Yes} (proc03);
\draw [arrow]   (dec01.east) -- node[above] {No} ++(1cm,0) |- (end);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容