12

I have the following:

\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=1em, column sep=3em]{
     \quad & a_1 &  \quad  \\
    b  & a_2 & \{ a_1, a_2 \dots a_n \} \\
     \quad  & a_n &  \quad  \\
     \quad  & \quad &  \quad  \\
};
\path[-latex]
(m-2-1) edge node[above] {$R$} (m-1-2)
(m-2-1) edge node[above] {$R$} (m-2-2)
(m-2-1) edge node[above] {$R$} (m-3-2)
(m-2-3) edge node[above] {$\in$} (m-1-2)
(m-2-3) edge node[above] {$\in$} (m-2-2)
(m-2-3) edge node[above] {$\in$} (m-3-2)
(m-2-2) edge[-, densely dotted] (m-3-2);
\draw[-latex] (m-2-1.south) |- (m-4-1.east) -| (m-2-3);
\end{tikzpicture}

And would like to put a label on the last edge created with draw command but do not know how.

As you can see it is a particular edge.

David Carlisle
  • 757,742
Andry
  • 1,287

1 Answers1

18

You can add a node keyword to your path. If you add it after the -| command, pos=0.5 in the node options will refer to the corner between the horizontal and vertical line segments, pos=0.25 will refer to the halfway point along the horizontal segment, pos=0.75 will refer to the halfway point along the vertical segment, and so on.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=1em, column sep=3em]{
     \quad & a_1 &  \quad  \\
    b  & a_2 & \{ a_1, a_2 \dots a_n \} \\
     \quad  & a_n &  \quad  \\
     \quad  & \quad &  \quad  \\
};
\path[-latex]
(m-2-1) edge node[above] {$R$} (m-1-2)
(m-2-1) edge node[above] {$R$} (m-2-2)
(m-2-1) edge node[above] {$R$} (m-3-2)
(m-2-3) edge node[above] {$\in$} (m-1-2)
(m-2-3) edge node[above] {$\in$} (m-2-2)
(m-2-3) edge node[above] {$\in$} (m-3-2)
(m-2-2) edge[-, densely dotted] (m-3-2);
\draw[-latex] (m-2-1.south) -- (m-4-1.center)-|  node [below,pos=0.25] {Label}(m-2-3);
\end{tikzpicture}

\end{document}
David Carlisle
  • 757,742
Jake
  • 232,450