# Aligning fractions in a matrix diagram

The fractions at the top row of the first diagram below are not aligned (and the fractions of the bottom aren't either), as the expressions of the top rows are in the second diagram. How can I align them?

\documentclass[11pt]{beamer}
\usepackage{pgfpages,amsmath,amssymb,mathtools,color, graphicx, amsfonts, braket}
\usepackage{subfig}
\usetheme{Madrid}
\usepackage{empheq}
\usepackage{multicol}

\begin{document}

\begin{frame}
$\begin{pmatrix} \begin{matrix} \begin{matrix} \cfrac{\ \rho \ }{\ \alpha \ }\\ \\ \texttt{left-exp}\\ \\ \cfrac{\ \operatorname{f[\;])}\ }{\ x\ }\\ \end{matrix} \hspace{2cm} \begin{matrix} \cfrac{\ \rho \ }{\ \alpha \to \beta\ }\\ \\ \texttt{right-exp}\\ \\ \cfrac{\ \operatorname{g[\;])}\ }{\ y\ }\\ \end{matrix} \end{matrix} \end{pmatrix} = \begin{matrix} \cfrac{\ \rho\ }{\ \beta\ }\\ \text{left-exp right-exp}\\ \cfrac{\ \operatorname{f[g[\;]])}\ }{\ A x y\ }\\ \end{matrix}$

$\begin{pmatrix} \begin{matrix} e \\ \text{John} \\ j \end{matrix} & \begin{pmatrix} e \to e \to t & e \\ \text{saw} & \text{Mary}\\ \operatorname{saw} & m \end{pmatrix} \end{pmatrix} = \begin{matrix} t\\ \text{John saw Mary}\\ \operatorname{saw}(j, m)\\ \end{matrix}$

\end{frame}

\end{document}

## 1 Answer

Rather than trying to build the top matrix as a collection of individual vectors, use the tabbed matrix approach, in order to achieve vertical alignment across the cells in a given row.

\documentclass[11pt]{beamer}
\usepackage{pgfpages,amsmath,amssymb,mathtools,color, graphicx, amsfonts, braket}
\usepackage{subfig}
\usetheme{Madrid}
\usepackage{empheq}
\usepackage{multicol}

\begin{document}

\begin{frame}
$\begin{pmatrix} \begin{matrix} \cfrac{\ \rho \ }{\ \alpha \ }&\kern15pt&\cfrac{\ \rho \ }{\ \alpha \to \beta\ }\\ &&\\ \texttt{left-exp}&&\texttt{right-exp}\\ &&\\ \cfrac{\ \operatorname{f[\;])}\ }{\ x\ }&&\cfrac{\ \operatorname{g[\;])}\ }{\ y\ } \end{matrix} \end{pmatrix} = \begin{matrix} \cfrac{\ \rho\ }{\ \beta\ }\\ \\ \text{left-exp right-exp}\\ \\ \cfrac{\ \operatorname{f[g[\;]])}\ }{\ A x y\ } \end{matrix}$

$\begin{pmatrix} \begin{matrix} e \\ \text{John} \\ j \end{matrix} & \begin{pmatrix} e \to e \to t & e \\ \text{saw} & \text{Mary}\\ \operatorname{saw} & m \end{pmatrix} \end{pmatrix} = \begin{matrix} t\\ \text{John saw Mary}\\ \operatorname{saw}(j, m)\\ \end{matrix}$

\end{frame}

\end{document}