# Centering a xy matrix inside beamer frame and figure

In the following beamer frame, I want the description text to stay top-left, while the xymatrix-figure should be centered. However, whatever I tried with \centering, \begin{center} and other online found solution, I've always gotten the diagram aligned left.

\begin{frame}
\frametitle{Butterfly network}

Some text

\begin{figure}[b]
\begin{center}
\begin{displaymath}
\xymatrix@R=0.9pc@C=3.5pc{
S_1 \ar@{.>}[rd] \ar@{.>}[ddd] & & S_2 \ar@{.>}[ld] \ar@{.>}[ddd] \\
& A_1 \ar@{.>}[d] & \\
& A_2 \ar@{.>}[ld] \ar@{.>}[rd] & \\
R_2 &  & R_1 \\
}
\end{displaymath}
\end{center}
\end{figure}
\end{frame}


PS I'm quite new to LaTeX, explanation why this solution doesn't work would be very welcome.

EDIT: Wrapping \xymatrix inside \centerline has made the diagram appear almost in the middle, a little to far right...

PSS Running TexLive 2013 on OpenSuSe 13.1

-
I get it al right: i.stack.imgur.com/n3R6P.png – Harish Kumar May 20 '14 at 15:38
I've removed custom theme from preamble and still get this: imgur.com/HePuUxi – Maverick May 20 '14 at 15:49
@IlyaE. the link in your comment is broken. – Gonzalo Medina May 20 '14 at 15:52
Are you sure? Works here well. – Maverick May 20 '14 at 15:58

I don't know, what the problem is for you, but as you do not provide a complete MWE, I can only do as you requested. The matrix is centred. I reduced the code a little bit.

% arara: pdflatex

\documentclass{beamer}
\usepackage[all]{xypic}

\begin{document}
\begin{frame}
\frametitle{Butterfly network}
Some text
\begin{displaymath}
\xymatrix@R=0.9pc@C=3.5pc{
S_1 \ar@{.>}[rd] \ar@{.>}[ddd] & & S_2 \ar@{.>}[ld] \ar@{.>}[ddd] \\
& A_1 \ar@{.>}[d] & \\
& A_2 \ar@{.>}[ld] \ar@{.>}[rd] & \\
R_2 &  & R_1}
\end{displaymath}
\end{frame}
\end{document}


If you are still having problems, you may try the tikz-cd package instead. Maybe, this is working for you.

% arara: pdflatex

\documentclass{beamer}
\usepackage{tikz-cd}

\begin{document}
\begin{frame}[fragile]
\frametitle{Butterfly network}
Some text
$\begin{tikzcd}[row sep=small] S_1 \ar[dotted]{rd} \ar[dotted]{ddd} & & S_2 \ar[dotted]{ld} \ar[dotted]{ddd} \\ & A_1 \ar[dotted]{d} & \\ & A_2 \ar[dotted]{ld} \ar[dotted]{rd} & \\ R_2 & & R_1 \end{tikzcd}$
\end{frame}
\end{document}

-
Sorry for forgetting about MWE. I've switched to tikzcd and now it appears centered (without any outer code change). The mysteries of ..TeX... Thank you! – Maverick Jun 5 '14 at 11:14