3

Often, when I have Xy-picture with a self-loop at the top, the arrow collides with the text above it:

\documentclass{article}
\usepackage[all]{xy}
\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit
\[\xymatrix{
    A\ar@(ul, ur)
}\]
\end{document}

enter image description here

How can I fix this?

Here are some of the things I tried already:

  • This problem doesn't occur if the preceding line is the end of a paragraph. But in the context where this occurs, the diagram should be in the middle of a paragraph.
  • Using \vspace works in this example, but sometimes adds space after the diagram instead. If possible, I'm interested in a solution for which I don't have to manually set spacing for each diagram.
  • If I try to encase the diagram in an \mbox, it adds some space – but not enough.
  • The amount of space depends greatly on latent variables: for example, if you use A\ar@(ul, ur)^\phi instead of A\ar@(ul, ur), the diagram has the correct spacing. I'm interested in knowing why this happens.

Because this occurs multiple times in preexisting code, I would prefer an Xy solution rather than having to port everything to tikz-cd.

  • 1
    I'm not sure why this happens (which is why this is a comment), but enclose the xymatrix in an fbox to see what's really happening. Somehow the arrow being drawn is not taken into account when the 'bounding box' is calculated if a label is not specified. An uneducated guess at a fix would be to use A\ar@(ul, ur)^{} instead. – Troy May 21 '17 at 3:39
  • @Troy: that worked, see egreg's answer below. – Arun Debray May 21 '17 at 13:40
2

Curved arrows are drawn with a \special and they are outside the control of TeX as far as determining the bounding box is concerned, because they're typeset in a box with no width and height.

Adding a dummy label solves the issue:

\documentclass{article}

\usepackage[all,cmtip]{xy} % otherwise arrow tips are ugly

\begin{document}

\noindent % just to make alike lines
Lorem ipsum dolor sit amet, consectetuer adipiscing elit
\[\xymatrix{
    A\ar@(ul, ur)
}\]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit
\[\xymatrix{
    A\ar@(ul, ur)^{}
}\]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit
\[\xymatrix{
    A\ar@(ul, ur)_{}
}\]
\end{document}

enter image description here

  • Wow, thanks! So is the reason this works that the arrow is drawn with \special but any label, even an empty label, is typeset normally with a nonzero width and height? – Arun Debray May 21 '17 at 13:41
  • 1
    @ArunDebray I don't know whether the empty label contributes height (I'd say no, as the result is the same with ^ and _); however its place contributes to the bounding box. Most likely the empty box containing the special is where the curved arrow starts; a small contribute comes from the arrow tip, but is insufficient. – egreg May 21 '17 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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