我正在尝试在 中重现此状态转换图LaTeX
。这是我使用 撰写的第一篇论文,LaTeX
因此我的知识有限。我正在努力寻找一种方法来让箭头以图像中所示的矩形方式弯曲,并控制箭头与节点之间的距离的高度。我目前拥有的代码如下:
\usepackage{tikz}
\usepackage{pgf}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{block1}=[rectangle, minimum width=1.5cm, minimum height=0.7cm, text centered, draw=black]
\tikzstyle{block2}=[rectangle, minimum width=0.8cm, minimum height=0.6cm, text centered, draw=black]
%\tikzstyle{doublearrow}=[thick,<->,>=stealth,<=stealth]
\tikzstyle{arrow}=[thick,->,>=stealth]
\begin{tikzpicture}[node distance=2cm]
\node (X) [block2] {$X$};
\node (Y1) [block2, left of=X,xshift=-1cm] {$Y_1$};
\node (Z1) [block2, left of=Y1,xshift=-1cm] {$Z_1$};
\node (Y2) [block2, right of=X,xshift=1cm] {$Y_2$};
\node (Z2) [block2, right of=Y2,xshift=1cm] {$Z_2$};
\draw [arrow,above] (X) -- node{{\scriptsize $\beta_1XY_1$}} (Y1);
\draw [arrow] (Y1) -- node {{\scriptsize $\gamma_1Y_1$}} (Z1);
\draw [arrow] (Z1) |- node{{\scriptsize $\delta_1\beta_1Y_1Z_1$}} (Y1);
\draw [arrow] (Z1) |- node {{\scriptsize $\lambda_1Z_1$}} (X);
\draw [arrow,above] (X) -- node[anchor=west] {{\scriptsize $\beta_2XY_2$}} (Y2);
\draw [arrow] (Y2) -- node{{\scriptsize $\gamma_2Y_2$}} (Z2);
\draw [arrow] (Z2) |- node{{\scriptsize $\delta_2\beta_2Y_2Z_2$}} (Y2);
\draw [arrow] (Z2) |- node{{\scriptsize $\lambda_2Z_2$}} (X);
\end{tikzpicture}
答案1
您可以使用 TikZ-Matrix:
\documentclass[margin=5pt, tikz]{standalone}
\usepackage{tikz}
% \usepackage{pgf} % loaded by tikz
% \usetikzlibrary{shapes.geometric, arrows} % not used
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[>=latex, rounded corners,
]
\matrix (m) [matrix of math nodes, nodes in empty cells,
nodes={anchor=center},
column sep=5em, row sep=2em,
]{
& & & & \\
Z_1 & Y_1 & X & Y_2 & Z_2 \\
& & & & \\
%1 & 2 & 3 & 4 & 5 \\
};
% Annotations
\draw[->] (m-2-1) -- (m-1-1.center) -- (m-1-2.center) node[midway, above]{$a b c$} -- (m-2-2);
\draw[->] (m-2-4) -- (m-1-4.center) -- (m-1-5.center) node[midway, above]{$c d e$} -- (m-2-5);
\draw[->] (m-2-1) -- (m-3-1.center) -- (m-3-3.center) node[midway, above]{$f g h$} -- (m-2-3);
\draw[] (m-2-3) -- (m-3-3.center) -- (m-3-5.center) node[midway, above]{$i j k$} -- (m-2-5);
\foreach[evaluate={\Col=int(\col+1)}] \col/\text in {1/A,2/B}
\draw[<-] (m-2-\col) -- (m-2-\Col) node[midway, above]{$\text$};
\foreach[evaluate={\Col=int(\col+1)}] \col/\text in {3/C,4/D}
\draw[->] (m-2-\col) -- (m-2-\Col) node[midway, above]{$\text$};
\end{tikzpicture}
\end{document}