[Xy-pic] Vertical alignment in xymatrix

Ross Moore ross at ics.mq.edu.au
Fri Mar 7 00:02:48 CET 2003

Michael wrote:
> I think the issue is this:
> 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.
> Is this analysis correct?


If you were to use a graphics program, such as Adobe Illustrator,
then this is possibly exactly what you would do, using its alignment
The alternative would require you to be very careful with rulers,
and probably would not end up looking as good.

> 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 really what I'm trying

Sort of.
At least this is what happens using \xymatrix ...

> to get at, and why I was so dismissive about your answers (I do apologise;
> I didn't mean to be rude).

The problem is that \xymatrix uses TeX's \halign  based on the \ialign primitive.
This is what is used by most aligned environments in LaTeX, whether math
or otherwise. 
You cannot align the top rows of a {tabular} environment unless the top line
has the same height in adjacent cells.
In this case you are actually aligning via the top of the cell, not aligning
via the baseline.

> If this really is the case, and this is actually a deficiency in xy, how

There are many diagrams for which \xymatrix is not the best environment to use.

The reason \xymatrix is so popular, and usually the first choice for
things that look like commutative diagrams, is that it has a familiar syntax.
Thus it's easy to learn to use quickly, even though it is limited in its
capabilities.  Nevertheless, it gives better commutative diagrams than
other packages, in most cases --- excluding Barr's diagram package,
which is based upon Xy-pic. :-)

One alternative is to use  \xygraph .

This lets you control the placement of elements much more accurately.
But you may have to work a little bit harder to master the syntax,
and you may need to plan ahead to a greater extent than with \xymatrix .

In particular, you will have to explicitly name  <object>s that are to be
used as targets of arrows, since there is no assumption that everything
lies within a regular grid of cells.

> difficult will it be to create an option which computes the xy box with
> the centre in the *right* place?

Within the context of \xymatrix  yes, that is actually rather hard.

Using \xygraph, or explicit Xy-pic kernel commands, this can indeed be
done --- at the expense of a more complicated syntax.
It also will depend on the specific definition of "right place"
that you wish to adopt.

I hope this helps you to better understand the nature of the problem.


	Ross Moore

> _______________________________________________
> Xy-pic mailing list
> http://tug.org/mailman/listinfo/xy-pic

More information about the Xy-pic mailing list