I have the following code:
\begin{tikzpicture} [shorten >=1pt, node distance=4cm, auto]
\node [state, initial] (00) {$(0, 0)$};
\node [state] (10) [right = of 00] {$(1, 0)$};
\node [state] (20) [right = of 10] {$(2, 0)$};
\node [state] (01) [above = of 00] {$(0, 1)$};
\node [state] (11) [right = of 01] {$(1, 1)$};
\node [state, accepting] (21) [right = of 11] {$(2, 1)$};
\path [->]
(00) edge node {a, b} (21)
(10) edge node {a} (01)
(11) edge [bend right] node {b} (10)
(10) edge [bend right] node {b} (11)
(20) edge node {a} (11)
(20) edge [bend right] node {b} (21)
(01) edge node {a, b} (20)
(11) edge node {a} (00)
(21) edge node {a} (10)
(21) edge [bend right] node {b} (20);
\end{tikzpicture}
which results in this drawing:
Now how do I ensure that the labels are clearly readable without changing the position of the nodes?
xshift
and/oryshift
.(00) edge node[yshift=-22pt] {a, b} (21)
.pos
key or the predefinednear start
(pos = .25
) andnear end
(pos = .75
) keys to change the position along the arrow. You canswap
the position of the label to the other side. And lastly, yes, you can shift the position of the label directly. You can also usesloped
which rotates the label such that it follows the direction of the arrow.