An inline xymatrix is, by default, surrounded by a non-0 amount of space:

[\(\xymatrix{A}\)] vs.\ [\(A\)]


Illustration of spacing around xymatrix

How do I adjust (in fact remove) that spacing? Edited to add, after @Sebastiano's answer: if possible, I'd like to do this by some appropriate \setlength or by passing some appropriate argument to xymatrix, rather than by manually adding spacing commands before or after.

1 Answer 1


There are several (somewhat cryptic) commands in xy to adjust spacing. See section 3.3 of the manual for details. In your case I think you want to set the margin (@M) to 0pt.

There is also the "special code" @1 that is designed for "one-line" diagrams to improve the placement on the line:

enter image description here

[\(\xymatrix@M=0pt{A}\)] vs.\ [\(A\)] vs.\ [\(\xymatrix@1{A}\)]
  • 1
    As always with the best answers, this answers the question I asked, as well as the one I probably should have asked. Thanks!
    – LSpice
    Jun 20, 2023 at 20:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .