将此表装入 Beamer 中

将此表装入 Beamer 中

我需要将下表放入此幻灯片中。我需要一张表格来解释 4 种不同方法的优点和缺点,并且我使用了下面编写的代码。是否可以放入此表格?

在此处输入图片描述

\documentclass{beamer}

\mode<presentation> {


\usetheme{Madrid}

}
\usepackage{color}
\usepackage{amsmath}
\usepackage{systeme}
\usepackage{graphicx} 
\usepackage{booktabs} 

\usepackage{caption, tabularx}
\usepackage{ragged2e}



\title[Title]{Title}

\author{Name} 
\date{\today} 

\begin{document}

\begin{frame}
\titlepage 
\end{frame}

\begin{frame}
\frametitle{Title} 
\tableofcontents 
\end{frame}


\section{Section}
\begin{frame}{Table}
\begin{table}[!htb]
\centering
\setlength{\extrarowheight}{1pt}
\setlength{\tabcolsep}{5pt}
\label{my-label}
\begin{tabularx}{\textwidth}{|p{15mm}|*{2}{>{\compress\RaggedRight\arraybackslash} X |}}
\hline
Methods & Pro & Cons \\
\hline
\begin{center}
    Model 1
\end{center}
& \begin{itemize}
  \item Pro 1;
  \item Pro 2;
  \item Pro 3;
\end{itemize}
& \begin{itemize}
  \item Cons 1;
  \item Cons 2;
  \item Cons 3;
\end{itemize} \\
\hline
\begin{center}
    Model 2
\end{center}
& \begin{itemize}
  \item Pro 1;
  \item Pro 2;
  \item Pro 3;
\end{itemize}
& \begin{itemize}
  \item Cons 1;
  \item Cons 2;
  \item Cons 3;
\end{itemize} \\
\hline
\begin{center}
    Model 3
\end{center}
& \begin{itemize}
  \item Pro 1;
  \item Pro 2;
  \item Pro 3;
\end{itemize}
& \begin{itemize}
  \item Cons 1;
  \item Cons 2;
  \item Cons 3;
\end{itemize} \\
\hline
\begin{center}
    Model 4
\end{center}
& \begin{itemize}
  \item Pro 1;
  \item Pro 2;
  \item Pro 3;
\end{itemize}
& \begin{itemize}
  \item Cons 1;
  \item Cons 2;
  \item Cons 3;
\end{itemize} \\
\hline
\end{tabularx}
\caption{Table.}
\end{table}

\end{frame}

\end{document}

提前致谢!

答案1

附带tabularray包装enumitem

\documentclass{beamer}

\mode<presentation> {
\usetheme{Madrid}
}
%\usepackage{color}     by beamer is loaded xcolor
%\usepackage{amsmath}   loaded by beamer
\usepackage{systeme}
%\usepackage{graphicx}  loaded by beamer
\usepackage{tabularray}
\UseTblrLibrary{booktabs, varwidth} 
% caption package doesn't work well in beamer
\usepackage{enumitem}   


\title[Title]{Title}

\author{Name}
\date{\today}

\begin{document}


\section{Section}
\begin{frame}{Table}
    \begin{table}[!htb]
\setlist[itemize]{nosep,
                 leftmargin=*,
                 label=\textbullet,
                 after =\vspace{-\baselineskip},% <---
                 before=\vspace{-\baselineskip} % <---
                 }
    \small
\begin{tblr}{hlines, vlines,
             colspec = {Q[l,m] X[l,h] X[l,h]},
              row{1} = {font=\bfseries},
             measure = vbox}
Methods & Pro & Cons \\
Model 1
    & \begin{itemize}
      \item Pro 1;
      \item Pro 2;
      \item Pro 3;
    \end{itemize}
    & \begin{itemize}
      \item Cons 1;
      \item Cons 2;
      \item Cons 3;
    \end{itemize} \\
Model 2
    & \begin{itemize}
      \item Pro 1;
      \item Pro 2;
      \item Pro 3;
    \end{itemize}
    & \begin{itemize}
      \item Cons 1;
      \item Cons 2;
      \item Cons 3;
    \end{itemize} \\
Model 3
    & \begin{itemize}
      \item Pro 1;
      \item Pro 2;
      \item Pro 3;
    \end{itemize}
    & \begin{itemize}
      \item Cons 1;
      \item Cons 2;
      \item Cons 3;
    \end{itemize} \\
Model 4
    & \begin{itemize}
      \item Pro 1;
      \item Pro 2;
      \item Pro 3;
    \end{itemize}
    & \begin{itemize}
      \item Cons 1;
      \item Cons 2;
      \item Cons 3;
    \end{itemize} \\
\end{tblr}
    \caption{Table.}
    \end{table}
\end{frame}
\end{document}

在此处输入图片描述

相关内容