我正在尝试制作一个 I 形图,其中包含两个框,一个在另一个上方,以及两个箭头:我希望箭头是弯曲的(那将是一种圆形流程图)并且只朝一个方向。虽然我自己搜索到的最好结果是一条直线双向垂直箭头。有人能帮我吗?
编辑
我还想了解其他类型的箭。我正在寻找一种更厚实的箭,但还没找到。有人能给我指点一下吗?
附加问题
如何使箭头旁边的文字水平放置?
我使用的代码是:
\begin{document}
\usepackage{color, colortbl}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes,backgrounds,fit}
\begin{figure}[ht]
\centering
\scalebox{.8}{
\begin{tikzpicture}[
node distance= 9em and 4em,
sloped]
\tikzset{
box/.style = {
fill=blue!15,
shape=rectangle,
rounded corners,
draw=blue!40,
align=center,
%minimum size={10pt},
text = black,
font=\fontsize{12}{12}\selectfont},
dummybox/.style = {
shape=circle,
align=center,
minimum size={width("rrrrrrrrrrr")+2pt}},
arrow/.style={
color=black,
draw=blue,
-latex,
font=\fontsize{8}{8}\selectfont},
}
\node[box](B1){Node $A$};
\node[box, below = of B1](S1){Node $B$};
\draw[arrow](B1) to node[above]{Flow: $\alpha$ } (S1);
\draw[arrow](S1) to node[above]{Flow: $-\beta$ } (B1);
\end{tikzpicture}}
\end{figure}
\end{document}
答案1
编辑: 或者:
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows.meta, positioning}
\begin{document}
\begin{tikzpicture}
\tikzset{
node distance = 9em and 4em,
sloped,
box/.style = {%
shape=rectangle,
rounded corners,
draw=blue!40,
fill=blue!15,
align=center,
font=\fontsize{12}{12}\selectfont},
arrow/.style = {%
draw=blue!30,
line width=2mm,% <-- select desired width
-{Triangle[length=3mm]},
shorten >=1mm, shorten <=1mm,
font=\fontsize{8}{8}\selectfont},
}
\node[box](B1){Node $A$};
\node[box, below = of B1](S1){Node $B$};
\draw[arrow](B1) to [bend left,looseness=1.2] node[above] {Flow: $\alpha$} (S1);
\draw[arrow](S1) to [bend left,looseness=1.2] node[above] {Flow: $-\beta$} (B1);
\end{tikzpicture}
\end{document}
附录:
由于slanted
中的选项,箭头处的文本与其对齐\tikzset{...}
。如果删除它,文本将显示为水平对齐:
在这种情况下,如果在库的帮助下将箭头处的文本输入为标签,那么它也会对齐quotes
:
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows.meta, positioning, quotes}
\begin{document}
\begin{tikzpicture}
\tikzset{
node distance = 9em and 4em,
% sloped, % <-- removed for horizontal align of arrows labels
box/.style = {%
shape=rectangle,
rounded corners,
draw=blue!40,
fill=blue!15,
align=center,
font=\fontsize{12}{12}\selectfont},
arrow/.style = {%
draw=blue!30,
line width=2mm,% <-- select desired width
-{Triangle[length=3mm]},
shorten >=1mm, shorten <=1mm,
font=\fontsize{8}{8}\selectfont},
}
\node[box](B1){Node $A$};
\node[box, below = of B1](S1){Node $B$};
\draw[arrow](B1) to [bend left,looseness=1.2,"Flow: $\alpha$"] (S1);
\draw[arrow](S1) to [bend left,looseness=1.2,"Flow: $-\beta$"] (B1);
\end{tikzpicture}
\end{document}
答案2
您可以使用 获得弯曲的箭头to[out=alpha,in=beta]
。其中alpha
是曲线离开起始坐标的角度,beta
是曲线到达目标坐标的角度。
代码
\documentclass{article}
\usepackage{color, colortbl}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes,backgrounds,fit}
\begin{document}
\begin{figure}[ht]
\centering
\scalebox{.8}{
\begin{tikzpicture}[
node distance= 9em and 4em,
sloped]
\tikzset{
box/.style = {
fill=blue!15,
shape=rectangle,
rounded corners,
draw=blue!40,
align=center,
%minimum size={10pt},
text = black,
font=\fontsize{12}{12}\selectfont},
dummybox/.style = {
shape=circle,
align=center,
minimum size={width("rrrrrrrrrrr")+2pt}},
arrow/.style={
color=black,
draw=blue,
-latex,
font=\fontsize{8}{8}\selectfont},
}
\node[box](B1){Node $A$};
\node[box, below = of B1](S1){Node $B$};
\draw[arrow](B1.west) to [out=190,in=170] node[above]{Flow: $\alpha$ } (S1.west);
\draw[arrow](S1.east) to [out=10,in=-10] node[above]{Flow: $-\beta$ } (B1.east);
\end{tikzpicture}}
\end{figure}
\end{document}
结果