答案1
尝试使用该软件包nicematrix
。易于学习,手册中有大量示例。
% !TeX TS-program = pdflatex
\documentclass[11pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usetheme{default}
\usepackage{nicematrix}
\begin{document}
\begin{frame}
\frametitle{Two matrices}
$ \mathbf{y}_i =
\begin{pNiceMatrix}
x_{i1} \\
\vdots \\
x_{it} \\
\vdots \\
x_{iT}
\end{pNiceMatrix}_{T\,x\,1}
\hfill \mathbf{X}_i =
\begin{pNiceMatrix}
x_{i,1,1} & x_{i,1,2} & x_{i,1,j} & \cdots & x_{i,1,K} \\
\vdots & \vdots & \vdots & & \vdots \\
x_{i,t,1} & x_{i,t,2} & x_{i,t,j} & \cdots & x_{i,1,K} \\
\vdots & \vdots & \vdots & & \vdots \\
x_{i,T,1} & x_{i,T,2} & x_{i,T,j} & \cdots & x_{i,T,K}
\end{pNiceMatrix}_{T\,x\,K} $
\end{frame}
\end{document}
答案2
pmatrix
这个简单的矩阵可以通过包中的定义来写出amsmath
:
\documentclass{beamer}
\usepackage{amsmath}
\begin{document}
\begin{frame}
\frametitle{Two matrices}
\[
\mathbf{y}_i = \begin{pmatrix}
x_{i1} \\
\vdots \\
x_{it} \\
\vdots \\
x_{iT}
\end{pmatrix}_{T\times 1}
\qquad\mathbf{X}_i =
\begin{pmatrix}
x_{i,1,1} & x_{i,1,2} & x_{i,1,j} & \cdots & x_{i,1,K} \\
\vdots & \vdots & \vdots & & \vdots \\
x_{i,t,1} & x_{i,t,2} & x_{i,t,j} & \cdots & x_{i,1,K} \\
\vdots & \vdots & \vdots & & \vdots \\
x_{i,T,1} & x_{i,T,2} & x_{i,T,j} & \cdots & x_{i,T,K}
\end{pmatrix}_{T\times K}
\]
\end{frame}
\end{document}
以下结果仅需一次编译。