[Xy-pic] Vertical alignment in xymatrix

Alexander Perlis alexanderperlis at yahoo.com
Thu Mar 6 04:22:53 CET 2003

Michael Abbott <michael at araneidae.co.uk> wrote:
> I'll try and understand what the \entrymodifiers solution is
> doing...

Vadim's elegant solution (a few posts ago) is probably what you want.
He also posted it back in 2001. I studied this alignment problem half
a year ago and wrote up my tribulations in an article for TUGboat and
arrived at essentially the same solution. A preprint is available at:


> Now the problem is how this centre relates to the mbox (the typeset
> mathematical expression) being placed.  I can't find the reference,
> but I seem to recall that every bit of mathematical text has, as
> well as the normal baseline with height and depth, a mathematical
> centre-line -- which is, I think, at a defined vertical offset
> above the baseline.  As I recall it, the - sign is *on* the
> centre-line.

That special line is the "axis". That's what \vcenter uses, and
vertical delimiters (such as parenthesis) have equal height and depth
when measured from the axis.

> So what I don't understand is this: how does xymatrix determine the
> "centre" of an mbox being placed in the matrix?  Is the centre
> literally half way between top and bottom?

Each entry has a bounding box, and the Xy-pic reference point
defaults to the center of that box.

> What I'm hoping to achive is some way in
> which the centre can be *on* the mathematical centre-line, in other
> words, at the standard offset from the baseline.

Actually, that's already the case. Xy-pic aligns dropped objects so
that the reference point (which defaults to the center) lands on the

Take a look at my article (see above for URL), which discusses this
matter and includes illustrations.

Vadim's solution (also illustrated in my article) is to move the
Xy-pic reference point away from the center of the bounding box, in
such a way that when that reference point gets placed on the axis,
the usual TeX reference point (lower-left-corner of letters) lands on
the usual baseline.

>> [...] using \vphantom [...]

I am not a fan of the \vphantom technique (used by the @1
construction) to affect alignment. It does so, but also affects the
bounding box, which subsequently affects arrows between objects.

> All the solutions so far seem to involve hacking the math text so
> that its height and depth match up so that the resulting text is
> symmetrical around the centre-line.

The solution Vadim and I use is *not* of this nature.

> In particular, is it really the case that xy just throws away the
> baseline of the text when converting it into a box?

That's true, but you still have access to the distance between the
baseline and the center while the box is being formed. That distance
is \fontdimen22\textfont2. (If you change \objectstyle to, say,
\scriptstyle, then you'll want \fontdimen22\scriptfont2.)

> If this really is the case, and this is actually a deficiency in
> xy, how difficult will it be to create an option which computes
> the xy box with the centre in the *right* place?

I agree that Xy-pic ought to support an option to automatically move
the reference point using \fontdimen22. In fact, at the end of my
article (see above for URL) I make suggestions concerning the syntax
of such an option. If any reader knows the Xy-pic source code well
enough to implement these ideas, please do so! (I'm hardly
qualified.) And of course I would welcome a discussion of my
suggestions. More users will benefit ultimately if the matter is
given careful thought through a community discussion prior to


Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more

More information about the Xy-pic mailing list