[Tex/LaTex] Draw an arc between 2 nodes and label it in TikZ

tikz-pgf

I have already drawn two ellipses l1 and l2, l2 is on the left below l1:

\begin{tikzpicture}
  \node (l1) [ellipse, draw=black, fill=white!20, text=black, scale=0.8, text centered]{
    $l_1$};
  \node (l2) [ellipse, draw=black, fill=white!20, text=black, scale=0.8, text centered, below left=1cm of l1]{
    $l_2$};
\end{tikzpicture}

I would like to draw an arc from the south of l1 to the north of l2 with a ->. The aim of drawing arc instead of a line is to make it prettier, so just a little radian will be fine, no need to be very accurate.

Does anyone know how to do it?

Also I would like to label the arc in its middle. The label, which is actually a word, will be ideally displayed horizontally.

Best Answer

You can draw the the arc with an arrow tip by using \draw [bend right,->] (l1) to (l2);. The curvature can be specified using bend right=<angle>.

To add a label, you can add a node halfway along the path by inserting node [auto] {<text>} after to. The auto keyword makes sure that the text doesn't overlap the line. If you want the text on the other side of the line, you can add the keyword swap after auto. The distance along the path can be controlled using at start, very near start, near start (or the equivalent expressions with end), or by specifying a fraction using at=<pos>.

Note that you don't need to set text centered explicitly, as this is the default behaviour.

\documentclass[a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric,positioning}

\begin{document}

\begin{tikzpicture}
  \node (l1) [ellipse, draw=black, fill=white!20, text=black, scale=0.8]{
    $l_1$};
  \node (l2) [ellipse, draw=black, fill=white!20, text=black, scale=0.8, below left=1cm of l1]{
    $l_2$};
\draw[bend left,->]  (l1) to node [auto] {Link} (l2);
\end{tikzpicture}

\end{document}
Related Question