# Aligning matrices across examples

How can I align the two identical blocks in the following (the blocks consisting of rows with words in)?

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

\begin{document}

\begin{frame}

\begin{exe}
\ex
$\begin{matrix} \begin{matrix} Semantic\;type:\\ \texttt{expression}:\\ Semantic\; term:\\ \end{matrix} \hspace{2cm} \begin{matrix} e\\ \text{John}\\ \operatorname{j}\\ \end{matrix} \end{matrix}$

\ex
$\begin{matrix} \begin{matrix} Semantic\;type:\\ \texttt{expression}:\\ Semantic\; term:\\ \end{matrix} \hspace{2cm} \begin{matrix} \cfrac{\ \operatorname{t}\ }{\ e\ }\\ \texttt{every linguist}\\ \cfrac{\ \operatorname{ev.ling(\lambda x.[\;])}\ }{\ x\ }\\ \end{matrix} \end{matrix}$

\end{exe}

\end{frame}

\end{document}

• Unrelated: empheq already loads mathtools, which in turn loads amsmath. beamer automatically loads amssymb (and thus amsfonts) as well as color and graphicx. – campa Apr 10 at 14:11

This solution forces beamer to use leqn equations and uses \mathmakebox to center the aligned matrices. The 4cm width is adjustable to taste.

\documentclass[11pt]{beamer}
\makeatletter
\tagsleft@true
\makeatother
\usepackage{braket}
\usepackage{pgfpages}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{empheq}
\usepackage{multicol}
\usepackage{gb4e}

\begin{document}

\begin{frame}

\begin{align}
\begin{matrix}
Semantic\;type:\\
\texttt{expression}:\\
Semantic\; term:\\
\end{matrix}
&\mathmakebox[4cm]{\begin{matrix}
e\\
\text{John}\\
\operatorname{j}\\
\end{matrix}}
\\
\begin{matrix}
Semantic\;type:\\
\texttt{expression}:\\
Semantic\; term:\\
\end{matrix}
&
\mathmakebox[4cm]{\begin{matrix}
\cfrac{\ \operatorname{t}\ }{\ e\ }\\
\texttt{every linguist}\\
\cfrac{\ \operatorname{ev.ling(\lambda x.[\;])}\ }{\ x\ }\\
\end{matrix}}
\end{align}

\end{frame}

\end{document}


like this:

with using only tabular:

\documentclass[11pt]{beamer}
\usepackage{empheq,
nccmath} % for \mfrac
\usepackage{gb4e}
\usepackage{array}

\begin{document}

\begin{frame}%[fragile]
\begin{exe}%\raggedright
\ex
\begin{tabular}[t]{>{\raggedleft\arraybackslash}p{0.45\linewidth}
>{$}l<{$}
}
Semantic type:          &   e           \\
\texttt{expression:}    &   $John$      \\
Semantic term:          &   \mathsf{j}

\end{tabular}

\ex
\begin{tabular}[t]{>{\raggedleft\arraybackslash}p{0.45\linewidth}
>{$}l<{$}
}
Semantic type:          &   \mfrac{\ \mathsf{t}\ }{e}   \\
\texttt{expression:}    &   $\texttt{every linguist}$   \\
Semantic term:          &   \mfrac{\ \mathsf{ev.ling}(\lambda x.[~])\ }
{x}

\end{tabular}
\end{exe}
\end{frame}
\end{document}


edit: from your comment can be gues that you like to have something like this:

difference to the first solution is in removed position option [t] and reduced size of the first column in tables. also in increased vertical space between \ex (examples).

\documentclass[11pt]{beamer}
\usepackage{empheq,
nccmath} % for \mfrac
\usepackage{gb4e}
\usepackage{array}

\begin{document}

\begin{frame}%[fragile]
\begin{exe}%\raggedright
\ex
\begin{tabular}{>{\raggedleft\arraybackslash}p{0.3\linewidth}
>{$}l<{$}
}
Semantic type:          &   e           \\
\texttt{expression:}    &   $John$      \\
Semantic term:          &   \mathsf{j}

\end{tabular}
\bigskip

\ex
\begin{tabular}{>{\raggedleft\arraybackslash}p{0.3\linewidth}
>{$}l<{$}
\texttt{expression:}    &   $\texttt{every linguist}$   \\

• @user65526, your question is not clear. please clarify it with some sketch, what you like to have. so far we can only guess what should be align. you can make first column of tabula narrower if you like to have column context closer to qex number. – Zarko Apr 10 at 15:33