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 it possible to label an arrow with a matrix in Xy-pic? In the following diagram I want to label the arrows with 2x2 matrices to represent linear maps between vector spaces, in the place of a,b and c.




{\bullet}^{V_1}\ar[r]^a &{\bullet}^{V_2}\ar[d]^b

It is for a diagram of a quiver representation.

share|improve this question
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). – egreg Nov 12 '12 at 18:08

You could just substitute the a, b, c for the matrix or whatever you want in brackets (I've added the - before so that the label is aligned in the middle of the arrow, not the middle of the row/column). Here's an example:

    \xymatrix @R=2cm @C=2cm { 
    {\bullet}^{V_1} \ar[r]^-{a = \begin{pmatrix}
        a_1 & a_2 \\ a_3 & a_4
    \end{pmatrix}} & {\bullet}^{V_2} \ar[d]^-{b = \begin{pmatrix}
        b_1 & b_2 \\ b_3 & b_4
    \end{pmatrix}} \\
    & {\bullet}^{V_3} \ar[ul]^-{c = \begin{pmatrix}
        c_1 & c_2 \\ c_3 & c_4

And may be you would like to write into an smallmatrix, which could be enough for your needs:

    \xymatrix @R=2cm @C=2cm { 
    {\bullet}^{V_1} \ar[r]^-{a = \left(\begin{smallmatrix}
        a_1 & a_2 \\ a_3 & a_4
    \end{smallmatrix}\right)} & {\bullet}^{V_2} \ar[d]^-{b = \left(\begin{smallmatrix}
        b_1 & b_2 \\ b_3 & b_4
    \end{smallmatrix}\right)} \\
    & {\bullet}^{V_3} \ar[ul]^-{c = \left(\begin{smallmatrix}
        c_1 & c_2 \\ c_3 & c_4

The @R=X and the @C=Y in the xymatrix command gives you the chance to change row and column separation.

There is a package tikz-cd (here is the manual at CTAN) which, in my opinion, gives better quality and the language used is easier to understand (i.e. \arrow[hookrightarrow]{rr}{a} instead of the xymatrix \ar@{^{(}->}[rr]^-{a}; or \rar{a} instead of \ar[r]^-{a}). But, in this concrete case there is a problem: tikz-cd causes problems if you want to label an arrow with a matrix (here is a better explanation). That's why I don't include an example here.

share|improve this answer
Probably smallmatrix is the best choice. I'd say \xymatrix @R+1pc @C+1pc{...} rather than setting explicit dimensions (this adds 12pt to both the intercolumn and interrow spaces). – egreg Nov 12 '12 at 18:28
I thought saying it in cm would be more explicit and easy to understand. But that's a good tip. Anyway, to the OP @nick, may be you would like to look for the tikz-cdpackage, which is similar and, in my opinion, easier to understand. – Manuel Nov 12 '12 at 18:33
Why don't you give also a solution based on tikz-cd? – egreg Nov 12 '12 at 18:34
Trying to make it I discover that tikz-cd doesn't recognize matrixes in the labels of the arrows, I get an error. It only separates the rows and not the columns (as a substack)! I don't know. ... And here's the answer link. In this case it wouldn't clarify anything for de OP I think. – Manuel Nov 12 '12 at 19:00

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.