2

I want to draw an edge between two TikZ nodes specified using the to path construct and place a node (a label) along the edge. Placing node[options] {text} after the edge does not seem to work.

MWE:

\documentclass{minimal}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \node[draw, circle, radius=1] (q0) at (0,0) {};
  \node[draw, circle, radius=1] (q1) at (2,0) {};
  \draw (q0) edge[to path={.. controls (1,1) .. (\tikztotarget)}, ->] node[above] {x} (q1)
             edge[->, bend right=15] node[below] {y} (q1);
\end{tikzpicture}
\end{document}

enter image description here

The second edge gets labeled by "y" and I can control its position using the pos option to the node. The first edge has no label at all.

How can I label the first edge in a similar fashion to the second? In particular, I'd like to avoid having to add a new \draw, \path, \node or similar since I'm constructing my diagrams programmatically from some tables of data.

2

The problem is that the option to path will have "grater priority" the way it is set than the node command (that is ignored)... This, happens because of the (\tikztoterget) that is there (and being replaced later) before the command for the node

You could try this way:

\documentclass{minimal}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \node[draw, circle, radius=1] (q0) at (0,0) {};
  \node[draw, circle, radius=1] (q1) at (2,0) {};
  \draw (q0) edge[to path={.. controls (1,1) ..node[above] {x} (\tikztotarget)}, ->]  (q1)
             edge[->, bend right=15] node[below] {y} (q1);
\end{tikzpicture}
\end{document}

That gives:

enter image description here

  • Welcome... The comments above is the way I understand the procedure from the code and the results... So, don't pay more attention that needed... :P – koleygr Jan 24 '18 at 2:56

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.