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.

How do I rotate the label on a arrow in xymatrix? Say, I want the label texts parallel with the arrow?

\documentclass[12pt, a4paper]{article}% a minimal example

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[all]{xy}
\xyoption{pdf}
\begin{document}
  \[
  \xymatrix{
    x\ar[d]^{looooooong}\\
    y
    }
  \]
\end{document}
share|improve this question

3 Answers 3

up vote 2 down vote accepted

Perhaps xy has it's own rotation support, but I think not, but you can use standard LaTeX rotations:

enter image description here

\documentclass[12pt, a4paper]{article}% a minimal example

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern,graphicx}
\usepackage[all]{xy}
\xyoption{pdf}
\begin{document}
  \[
  \xymatrix{
    x\ar[d]^{\rotatebox{90}{$\scriptstyle looooooong$}}\\
    y
    }
  \]
\end{document}
share|improve this answer
    
i think you need a longer arrow ... –  barbara beeton Jun 18 '13 at 17:55
    
Thanks a lot. How do I set globally that the labels parallel with the arrows? –  Ma Ming Jun 18 '13 at 18:04

You can add \xyoption{rotate}. The explanation for rotation of labels or any object appears in the page 29 in XY-pic reference manual.

\documentclass[12pt, a4paper]{article}% a minimal example
\usepackage[all]{xy}
\xyoption{rotate}
\xyoption{pdf}
\begin{document}
  \[
  \xymatrix{
    x\ar[d]^[@!-90]{\scriptstyle looooooong}\\
    y
    }
  \]
\end{document}

or

\documentclass[12pt, a4paper]{article}% a minimal example
\usepackage[all]{xy}
\xyoption{rotate}
\xyoption{pdf}
\begin{document}
  \[
  \xymatrix{
    x\ar[d]^[right]{\scriptstyle looooooong}\\
    y
    }
  \]
\end{document}
share|improve this answer
    
Welcome to TeX.SX! If you select text and click the button marked {} (or use Ctrl+K) the text will be highlighted as code. Then there's no need for the <br>s. –  Torbjørn T. Jun 9 at 22:28

If you are willing to use tikz-cd instead of xy, you could just rotate the label like you would do for any TikZ-node.

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{mathtools} % for the \text{} command
\begin{document}
\[
\begin{tikzcd}
x  \ar{d}[%
    ,rotate=+90 % counter clockwise rotation
    ,below % attach label to the right of the arrow
    ,yshift=-0.3ex % optional for movement to the right. 
    ]{\text{looooooong}}\\
y
\end{tikzcd}
\]
\end{document}

enter image description here

Update

In comment you asked for an automatic solution for rotated labels. Done in tikz-cd, this could look like this:

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}
\tikzset{mystyle/.style={sloped, anchor=south}}
\usepackage{mathtools} % for the \text{} command

\begin{document}
\[
\begin{tikzcd}[every label/.append style={mystyle}]
\bullet & \bullet & \bullet\\
\bullet & x  \ar{ul}{xy} \ar{u}{xy} \ar{ur}{xy} \ar{l}{xy} \ar{r}{xy} \ar{dl}{xy} \ar{d}{\text{looooooong}} \ar{dr}{xy} & \bullet\\
\bullet & y & \bullet
\end{tikzcd}
\]
\end{document}

enter image description here

In my opinion, each label should be readable from the right or from below. So instead of using every label/.append style={mystyle} for the whole image, I would write \ar{ul}[mystyle]{xy} for any arrow and use my first solution for the down-arrow-case.

share|improve this answer

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.