8

The xymatrix diagram does not seem to vertically align when grouped in an equation environment. For example, this code produces the following image (which seems to place the xymatrix 2.5em lower than it should be). How can I remedy this without using \raisebox{2.5em}?

\[\boxed{
\begin{array}{ccc}
A & B & C \\
A & B & C \\
A & B & C \\
A & B & C \\
A & B & C \\
\end{array}
}
\quad 
\boxed{
\begin{array}{ccc}
A & B & C \\
A & B & C \\
A & B & C \\
A & B & C \\
A & B & C \\
\end{array}
}
\qquad\boxed{
\xymatrix@-1pc{
A & B & C \\
A & B & C \\
A & B & C \\
}}
\]

Example diagram

7

Use \vcenter to vertically center within math mode. For some strange reason is seems to require (at least sometimes) an inner \vbox. As in:

\documentclass{article}
\usepackage[all]{xy}
\begin{document}
 \begin{equation}
  x\,
   \vcenter{\vbox{
   \xymatrix@-1pc{
   A & B & C \\
   A & B & C \\
   A & B & C \\
   }
   }}
 \end{equation}
\end{document}

As an aside, your example doesn't compile for me because I don't know where the \boxed command is from. You should give a complete LaTeX (or TeX) file in your questions.

  • Also \vcenter{\hbox{...}} could be used. – Stefan Kottwitz Apr 8 '11 at 19:08
  • @Stefan: Thanks; I've just been copying that along for years since I first read it somewhere. I don't really get why it's necessary. – Ryan Reich Apr 8 '11 at 19:14
  • Oh, sorry. I think it's defined in the amsmath package – Alex Apr 8 '11 at 19:20
  • With amsmath there's an easier way: \begin{gathered}\xymatrix{...}\end{gathered} – egreg Apr 8 '11 at 19:35
  • I tried gathered, and it didn't work for me. – Alex Apr 9 '11 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.