如果有人能正确设置箭头,我将不胜感激。提前谢谢大家。
\documentclass{article}
\usepackage{tikz, ulem}
\usetikzlibrary{shapes,shadows,arrows,positioning}
\begin{document}
\tikzstyle{decision} = [diamond, draw, fill = white, font = \footnotesize, minimum height = 2mm, text centered,
minimum width= 5cm, text width = 5cm , node distance = 15em]
\tikzstyle{line} = [draw, -stealth', thick, font = \footnotesize]
\tikzstyle{elli} = [draw, ellipse, fill = white, text centered,
minimum height = 7mm, text width = 10em, minimum width=1.5cm, font=\footnotesize ,node distance = 17em]
\tikzstyle{box}=[draw, rectangle, fill = white, font = \footnotesize, minimum width=1.5cm, text centered,
text width = 12em, minimum height = 8mm , node distance = 17em]
\begin{figure}
\centering
\footnotesize
\resizebox{0.85\textwidth}{!}{%
\begin{tikzpicture}[
thick,scale = 0.5, every node /.style ={scale=0.5}%,
]%
\node[elli](step1){ \textbf{\uline{Si}} \\ };
\node[box, right of= step1](step2){ \textbf {\uline{Hai una problema?}} \\ };
\node[elli, right of= step2](step3){\textbf {\uline{No}} \\ };
\node[box, below of= step1]%, yshift = +9em]
(step11){{\centering\textbf{} \par}
Puoi fare qualcosa?};
\node[decision, below of= step3, yshift = -20em] %, yshift = +7em]
(step31){{\centering\textbf{} \par}
Non ti preoccupare.
};
\node[elli, below of= step11, xshift = -16em ] % , yshift = +5em]
(step21){{\centering\textbf{Si} \par} };
\node[elli, below of= step11, xshift = +16em ] % , yshift = +5em]
(step22){{\centering\textbf{No} \par} };
\draw [->, very thick] (step2) to [out=150,in=30] (step1);
\draw [->, very thick] (step2) to [out=30,in=150] (step3);
\path[line](step1)--(step11);
\path[line](step11)--(step21);
\path[line](step11)--(step22);
\path[line](step3)--(step31);
%\path[line](step21)--(step31);
%\path[line](step22)--(step31);
\draw [->, very thick] (step21) to [out=270,in=180] (step31);
\draw [->, very thick] (step22) to [out=270,in=200] (step31);
%\draw[->] (step21) -| (step31);
%\end{scope}
\end{tikzpicture}
}%
\caption{Non ti preoccupi }
\label{fig:theworkflow}
%\end{center}
\end{figure}
\end{document}
答案1
这看上去还好吗?
您已经知道如何使用xshift
/添加手动换档yshift
,因此您可以做更多这样的操作来移动事物,但我重写了一些内容以简化和现代化。摘要:
\tikzstyle
被认为已被弃用,我改用stylename/.style={...}
a 中的多个\tikzset
。below of=
我使用了而不是。前一种语法被视为已弃用,而后一种语法由您已加载的库below=of
定义。positioning
- 我从节点中删除了所有
\\
、\centering
等,我真的不认为它们是必要的?\par
- 我定义了“你有问题吗”节点第一的,并将是/否节点相对于该节点放置,而不是先定义是节点。
- 我从节点样式中删除了所有
node distance=...
和。fill=white
- 是/否节点与
below left=of ...
和放在一起below right=of ...
。 - 一般节点距离设置为
1cm and 0cm
。即垂直方向为1cm,水平方向为0cm。below left
也会设置anchor=north east
。 below=2cm of ...
通过说而不是仅仅 ,将最后一个节点向下推一点below=of ...
。- 我还删除了所有额外的缩放比例
scale
和resizebox
。我真的不认为它们有什么意义。\resizebox
我认为,这通常是缩放此类图表的最后手段。
\documentclass{article}
\usepackage{tikz, ulem}
\usetikzlibrary{shapes,shadows,arrows.meta,positioning}
\tikzset{
decision/.style={diamond, draw, font = \footnotesize, minimum height = 2mm, text centered,},
line/.style={-Stealth, thick},
elli/.style={draw, ellipse, -Stealth, text centered,
minimum height = 7mm, text width = 5em, minimum width=1.5cm, font=\footnotesize},
box/.style={draw, rectangle, font = \footnotesize, minimum width=1.5cm, text centered,
text width = 12em, minimum height = 8mm}
}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[node distance=1cm and 0cm]
\node[box](step2){ \textbf {\uline{Hai una problema?}}};
\node[elli, below left=of step2] (step1) {\textbf{\uline{Si}}};
\node[elli, below right=of step2] (step3) {\textbf{\uline{No}}};
\node[box, below=of step1] (step11) {Puoi fare qualcosa?};
\node[decision, below=2cm of step3] (step31) {Non ti preoccupare.};
\node[elli, below left=1cm and 0mm of step11, anchor=north] (step21){\textbf{Si}};
\node[elli, below right=1cm and 0mm of step11, anchor=north] (step22) {\textbf{No}};
\draw [line] (step2) -- (step1);
\draw [line] (step2) -- (step3);
\draw [line] (step1) -- (step11);
\draw [line] (step11) -- (step21);
\draw [line] (step11) -- (step22);
\draw [line] (step3) -- (step31);
\draw [line] (step21) to [out=270,in=230] (step31);
\draw [line] (step22) to [out=270,in=200] (step31);
\end{tikzpicture}
\caption{Non ti preoccupi }
\label{fig:theworkflow}
\end{figure}
\end{document}