enter image description here

I am trying to reproduce this state transition diagram in LaTeX. This is the first paper I've written using LaTeX so my knowledge is limited. I am struggling to find a way to get the arrows to bend in the rectangular way shown in the image and to also control the height of how far the arrow goes from the nodes. The code I currently have is below:

\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]

\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);

You could use a TikZ-Matrix:

enter image description here

\documentclass[margin=5pt, tikz]{standalone}
% \usepackage{pgf} % loaded by tikz
% \usetikzlibrary{shapes.geometric, arrows} % not used

\begin{tikzpicture}[>=latex, rounded corners, 
\matrix (m) [matrix of math nodes, nodes in empty cells,
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$};  
  • 2
    matrix of nodes and matrix of math nodes fixes node's alignment to base. This is the reason of not horizontal arrows between $X$ and $Y_1$ or $Y_2$. I suggest to add nodes={anchor=center} to avoid this problem. More details in tex.stackexchange.com/q/78964/1952 – Ignasi Apr 6 '20 at 14:23
  • OK...................... – cis Apr 6 '20 at 14:40
  • 1
    Just what I needed thank you so much. – Leah Apr 6 '20 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.