5

I'm new on using the latex package Tikz, and I'm trying to write a Tableau. My problem is to create sufficient space between sibling so that I can put a label in the center. This is what I've done. I would like to avoid manual spacing as much as possible, so I'm looking for a general solution.

 \begin{tikzpicture}[auto, node distance=1.3cm]


 \node (A) {$X^1$};
 \node (B) [below of=A] {$X^2$};
 \node (C) [below of=B] {$X^3$};
 \node (D) [below of=C] {$X^4$};
 \node (E) [below of=D] {$X^5$};  
 \node (F) [label={[label distance=-1cm] \color{green}{Complete}}, below left of=E,left=1cm] {$X^6$};
 \node (G) [below right of=E, right=1cm] {$X^7$};
 \node (H) [below left of=G,left=1cm] {$X^8$};
 \node (I) [label={[label distance=-1cm] \color{red}{Closed}}, below right of=G, right=1cm] {$X^9$};
 \node (L) [label={[label distance=-1cm] \color{red}{Closed}}, below of=H] {$X^{10}$};


 \path (A) edge  (B);
 \path (B) edge (C);
 \path (C) edge (D);
 \path (D) edge (E);
 \path (E) edge  node [below=0.3cm, right=0.4cm]{PB-Rule}  (F)
        edge (G);
  \path (G) edge node [below=0.3cm, right=0.4cm] {PB-Rule} (H)
        edge  (I);          
 \path (H) edge node {E-Rule} (L);

\end{tikzpicture}

Any Suggestion ?

pchaigno
  • 11,313
  • 2
  • 29
  • 54
Discipulos
  • 423
  • 8
  • 23
  • 1
    If I understand correctly, you'd like to get rid of these manual spacings: `[below=0.3cm, right=0.4cm]`? – pchaigno Aug 09 '17 at 13:10

1 Answers1

6

To place the label between siblings, you can use the !0.5! syntax:

\begin{tikzpicture}[auto, node distance=1.3cm]
  \node (A) {$X^1$};
  \node (B) [below of=A] {$X^2$};
  \node (C) [below of=B] {$X^3$};
  \node (D) [below of=C] {$X^4$};
  \node (E) [below of=D] {$X^5$}; 
   \node (F) [label={[label distance=-1cm] \color{green}{Complete}}, below left of=E,left=1cm] {$X^6$};
  \node (G) [below right of=E, right=1cm] {$X^7$};
  \node (H) [below left of=G,left=1cm] {$X^8$};
  \node (I) [label={[label distance=-1cm] \color{red}{Closed}}, below right of=G, right=1cm] {$X^9$};
  \node (L) [label={[label distance=-1cm] \color{red}{Closed}}, below of=H] {$X^{10}$};

  \node (label1) at ($(F)!0.5!(G)$) {PB-Rule};
  \node (label2) at ($(H)!0.5!(I)$) {PB-Rule};

  \path (A) edge  (B);
  \path (B) edge (C);
  \path (C) edge (D);
  \path (D) edge (E);
  \path (E) edge (F);
  \path (E) edge (G);
  \path (G) edge (H);
  \path (G) edge (I);
  \path (H) edge node {E-Rule} (L);
\end{tikzpicture}

Note: you will need the calc tikz library for that syntax.

enter image description here

pchaigno
  • 11,313
  • 2
  • 29
  • 54