# Unequally spaced columns in XYpic

I often need to create a diagram in XYpic where the distance between the columns varies. This is usually when one has a map to some object X where the definition of X is in the diagram itself, like

\begin{equation*}
\xymatrix{
A \ar[r] & B = \{c \in C \mid f(c) = 0 \}
\\
a \ar@{|->}[r] & b
}
\end{equation*}


If you actually typeset this, the lower b will be aligned to the center of the rather large second column, while one wants it below the upper B. A solution is to write

\begin{equation*}
\xymatrix{
A \ar[r] & B & = \{c \in C \mid f(c) = 0 \}
\\
a \ar@{|->}[r] & b
}
\end{equation*}


so that the definition of B is in the third column. The problem is now that the equal sign is too far from the B to which it refers.

Such a thing is easy to do in kuvio, but kuvio does not support pdflatex, and moreover my coworkers have chosen xypic instead.

-

\documentclass{minimal}
\usepackage{xypic,mathtools}
\begin{document}

\begin{equation*}
\xymatrix{
A \ar[r] & \mathrlap{B = \{c \in C \mid f(c) = 0 \}}
\\
a \ar@{|->}[r] & b
}
\end{equation*}

\end{document}

-
This one is definitely the best solution. Still it is not perfect since the long entry now has 0 width, which may not be good for the layout. It is still disappointing that XYpic does not allow to move columns. –  Andrea Dec 27 '10 at 18:41
I withdraw my previous comment: of course only part of the column may be put inside mathrlap. This is definitely THE solution. Thank you very much! –  Andrea Dec 27 '10 at 18:48
@Andrea: you can add a  & \rule{2cm}{0pt}  after the rlap line, then it will be shifted to the left –  Herbert Dec 27 '10 at 19:54

You can also use the excursion command described on page 9 of xyguide.pdf:

\begin{equation*}
\xymatrix{
A \ar[r] & B &
\save[]+<1.75em,0em>*{= \{c \in C \mid f(c) = 0 \}}\restore  \\
a \ar@{|->}[r] & b
}
\end{equation*}

-

I was able to get the desired spacing by adapting your proposed solution. I just made the column width negligible and added in an extra column. I don't know if there is a better way of accomplishing the desired result.

\begin{equation*}
\xymatrix@C=-2pt{
A \ar[rr] &\qquad& B &= \{c \in C \mid f(c) = 0 \}
\\
a \ar@{|->}[rr]& & b
}
\end{equation*}

-
Uhm... thank you, but if this is the only solution I may just use aligned equations and manually adjust horizontal position by adding spaces. I was hoping XYpic could do better... :-( –  Andrea Dec 26 '10 at 20:04