TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using xy package to draw a simple graph representation. How can I add the labels to the egdes?

Here is the code I've produced so far:

!{(0,1) }*+{\bullet_{r}}="r"
!{(3,0) }*+{\bullet_{k1}}="k1"
!{(4,1) }*+{\bullet_{a}}="a"
!{(2,1) }*+{\bullet_{b}}="b"
!{(3,2) }*+{\bullet_{c}}="c"
!{(2,3) }*+{\bullet_{d}}="d"
!{(1,2) }*+{\bullet_{e}}="e"
"k1":"a" "k1":"b"
"b":"c" "a":"c"
"c":"d" "d":"e"
share|improve this question
up vote 4 down vote accepted

For the record:

There are a few possibilities to add labels to edges.

  • "a":"b"^{e_1} adds the label above the edge (above as when going from a to b)
  • "a":"b"_{e_1} adds the label below the edge
  • "a":"b"|{e_1} adds the label on the edge

When placing a label on the edge itself, it makes sense to do it like "a":"b"|*+{e_1}, as this ensures the edge is broken and the text easily readable.

You could also change the position of the label using "a":"b"^(0.2){e_1}, which places the label 20 % into the edge. This works with all three ways.

It is amazing what you can do using xypic once you begin to understand it - which I am far away from...

share|improve this answer

Your Answer


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.