2

How to put a label on a bend arrow in TIKZ. So currently I have currently managed to add a label in between the arrow, but I am unable to bend the arrow. Also, when I bend the arrow, I am unable to add the label in between.

\draw[->] (q2)--(q3) node[midway,color=red,fill=white]{0};

I have used the above code to add a label in between the arrow.

How I want it to look How I want it to look

How it is currently looking How it is currently looking

2 Answers 2

4

Always post compilable code, so other do not have to guess how you make your nodes, bend, ... -and to help others help you.

\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node[draw, circle](q2){q2};
\draw (0,-2) node[draw, circle](q3){q3};
\draw[->] (q2) edge[bend left] node[midway, color=red, fill=white]{1} (q3);
\end{tikzpicture}
\end{document}
 

Two nodes with bend arrow

2
  • +1 for your answer. But have you changhed your default gravatar? :-)
    – Sebastiano
    Aug 27, 2021 at 19:20
  • 2
    @Sebastiano: If it is too much work, I just complain. If it is easy, I complain and answer. Aug 27, 2021 at 19:30
3

By use of the quotes library:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{quotes}

\begin{document}
    \begin{tikzpicture}[
                C/.style = {circle, draw},
every edge quotes/.style = {fill=white, font=\footnotesize, inner sep=2pt, anchor=center}
                        ] 
\node (q2) [C] {q2};
\node (q3) [C] at (0,-2)   {q2};
\draw[->] (q2) to[color=red, bend left, "1"] (q3);
    \end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .