# Oversized parentheses around xymatrix

This must have been asked somewhere here before, but I cannot seem to find it.

I am using \left( and \right) around an xymatrix, but the parenthesis are far too big;

with the following code;

 \begin{equation*}
\left(\xymatrix{ A \ar[r] \ar[d]    & B  \ar[d] \\
X     \ar[r]_f    &   Y}\right)
\end{equation*}

-
See also tex.stackexchange.com/q/1023/484 which was asked with this scenario, among others, in mind. –  Charles Staats May 2 '12 at 21:00

This is caused because the \xymatrix{ } sets the first line of the matrix on the baseline, the lower line goes beyond the baseline resulting in a large depth. The \left and \right macros are always centered on the baseline, and therefore are extended upwards as far the matrix goes down. Use the \vcenter macro to push the matrix up.

\documentclass{article}

\usepackage{amsmath}
\usepackage{xypic}

\begin{document}
\begin{equation*}
\left(
\vcenter{\xymatrix{ A \ar[r] \ar[d] & B \ar[d] \\ X \ar[r]_f & Y}}
\right)
\end{equation*}
\end{document}

-
Great, two birds with one stone. –  BBischof Jul 11 '11 at 16:55
small nitpicking: \valign isn't a macro, it's a primitive. –  morbusg Jul 11 '11 at 17:03
@morbusg: I'm actually using \vcenter not \valign, but both are indeed primitives ;-) –  Martin Scharrer Jul 11 '11 at 17:53
A "pure LaTeX" solution is to enclose \xymatrix in a gathered environment. Using \vcenter in other cases can lead to surprises and head scratching; for example, TeX is not in math mode inside a \vcenter. Here it doesn't matter, since \xymatrix can be used in text mode and, most importantly, it builds a box. –  egreg Jul 11 '11 at 18:10
:-O facepalm –  morbusg Jul 11 '11 at 18:53