0
\begin{tikzpicture}
\node[state] (x11) {$X_1^1$};
\node[state, right of=x11] (x12) {$X^2_1$};
\node[state, right of=x12] (x13) {$X^3_1$};
\node[state, right of=x13] (x14) {$X^4_1$};
\node[state, right of=x14] (x15) {$X^5_1$};

\node[state, below of=x11,label=left:$s\leq 3$] (x21) {$X^1_2$};
\node[state, below of=x12] (x22) {$X^2_2$};
\node[state, below of=x13] (x23) {$X^3_2$};
\node[state, below of=x14] (x24) {$X^4_2$};
\node[state, below of=x15] (x25) {$X^5_2$};

\node[state, below of=x21] (x31) {$X^1_3$};
\node[state, below of=x22] (x32) {$X^2_3$};
\node[state, below of=x23] (x33) {$X^3_3$};
\node[state, below of=x24] (x34) {$X^4_3$};
\node[state, below of=x25] (x35) {$X^5_3$};

\draw

(x11) edge[above] node{} (x21)
(x11) edge[above] node{} (x22)
(x13) edge[above] node{} (x24)
(x13) edge[above] node{} (x25)
(x15) edge[above] node{} (x23)
(x22) edge[above] node{} (x33)
(x22) edge[above] node{} (x31)
(x23) edge[above] node{} (x32)
(x25) edge[above] node{} (x34)
(x25) edge[above] node{} (x35)
;


\end{tikzpicture}

How come if I change label=left:$s\leq 3$ to label=left:$s=3$ I can no longer compile the code...

I get ! Extra }, or forgotten $.

4

Solution of your problem is given @ferahfeza comment. Note, sign = is used for positioning of node labels. If you have two, parser is lost. Therefore = in equation had to be "hidden" , i.e. had to be enclosed in curly braces. Good practice is enclosed complete equation into curly braces, since with this spacings in equation are retained.

So, I suggest some off-topic improvements using tikz libraries chains, positioning and quotes:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{automata,
                chains,
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[
      node distance = 4mm and 4mm,
        start chain = going right,
state/.append style = {inner sep=0pt, on chain}
                    ]
\node[state] (x11) {$X_1^1$};
\node[state] (x12) {$X^2_1$};
\node[state] (x13) {$X^3_1$};
\node[state] (x14) {$X^4_1$};
\node[state] (x15) {$X^5_1$};
%
\node[state, below= of x11,
      label=left:{$s=3$}]    % <---
             (x21) {$X^1_2$};
\node[state] (x22) {$X^2_2$};
\node[state] (x23) {$X^3_2$};
\node[state] (x24) {$X^4_2$};
\node[state] (x25) {$X^5_2$};
%
\node[state, below= of x21] (x31) {$X^1_3$};
\node[state] (x32) {$X^2_3$};
\node[state] (x33) {$X^3_3$};
\node[state] (x34) {$X^4_3$};
\node[state] (x35) {$X^5_3$};

\draw   (x11) edge ["?"]    (x21)
        (x11) edge          (x22)
        (x13) edge          (x24)
        (x13) edge          (x25)
        (x15) edge          (x23)
        (x22) edge          (x33)
        (x22) edge          (x31)
        (x23) edge          (x32)
        (x25) edge          (x34)
        (x25) edge          (x35)
        ;
    \end{tikzpicture}
\end{document}

enter image description here

  • 1
    Very good improvements (+1). – ferahfeza Aug 24 at 13:27
  • 2
    @ferahfeza, thank you very much! – Zarko Aug 24 at 13:31

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.