Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 14 down vote accepted

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}
share|improve this answer
    
Thankyou very much :) –  Andry Apr 5 '12 at 7:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.