表的行分割问题

表的行分割问题

在此处输入图片描述

     \documentclass{beamer}
      \usepackage{mathtools}
      \usepackage{array}
      \usepackage{rotating,amsmath,booktabs,graphicx}

      \usepackage{amsmath}
      \usepackage{tabularx}


      \usepackage{tikz}
      %\usetheme{Boadilla}

       \usetikzlibrary{decorations.pathmorphing}

       \usetheme{Warsaw}

      \setbeamercolor{structure}{fg=cyan!90!black}
       \begin{document}

       \begin{frame}

       \begin{table}[]
       \begin{tabular}{|l|l|l|}
       \hline
        \textbf{Har class Class} & \textbf{XYZ (in words)}   & 
      \textbf{Truple}    \\ \hline
    General vktm        & $\mathcal{O}(1)$ & $\mathcal{O}(1)$ \\ \hline
     It is only a text          & $\mathcal{O}(1)$ & $\mathcal{O}(1)$ \\ \hline
     Grfingiignigijfi \\jnferf    & $\mathcal{O}(n)$ & $\mathcal{O}(1)$ \\ \hline
   jvjtntg   & $\mathcal{O}(n)$ & $\mathcal{O}(1)$ \\ \hline
    frcjnrtgvtng  & $\mathcal{O}(n)$ & $\mathcal{O}(1)$ \\ \hline
    \end{tabular}
    \end{table}






    \end{frame}

    \end{document}

问题:表格中有裂缝。我该如何修复它?

答案1

正如 @daleif 在评论中所述,\\将始终创建新行。 您还可以使用\newline,但对于支持多行的列,如p、、等。 在您的例子中,您可以在左对齐列中使用。当然,您需要添加包mb\makecell[l]{..}makecell

     \documentclass{beamer}
      \usepackage{mathtools}
      \usepackage{array,makecell}
      \usepackage{rotating,amsmath,booktabs,graphicx}

      \usepackage{amsmath}
      \usepackage{tabularx}


      \usepackage{tikz}
      %\usetheme{Boadilla}

       \usetikzlibrary{decorations.pathmorphing}

       \usetheme{Warsaw}

      \setbeamercolor{structure}{fg=cyan!90!black}
       \begin{document}

       \begin{frame}

       \begin{table}[]
       \begin{tabular}{|l|l|l|}
       \hline
        \textbf{Har class Class} & \textbf{XYZ (in words)}   & 
      \textbf{Truple}    \\ \hline
    General vktm        & $\mathcal{O}(1)$ & $\mathcal{O}(1)$ \\ \hline
     It is only a text          & $\mathcal{O}(1)$ & $\mathcal{O}(1)$ \\ \hline
     \makecell[l]{Grfingiignigijfi \\jnferf} & $\mathcal{O}(n)$ & $\mathcal{O}(1)$ \\ \hline
   jvjtntg   & $\mathcal{O}(n)$ & $\mathcal{O}(1)$ \\ \hline
    frcjnrtgvtng  & $\mathcal{O}(n)$ & $\mathcal{O}(1)$ \\ \hline
    \end{tabular}
    \end{table}

    \end{frame}

    \end{document}

在此处输入图片描述

答案2

也许你喜欢:-):

在此处输入图片描述

没有垂直规则,水平规则来自booktabs包,重新排列序言:

\documentclass{beamer}
%\usetheme{Boadilla}
\usetheme{Warsaw}
\setbeamercolor{structure}{fg=cyan!90!black}

\usepackage{mathtools}% it also load "amsmath"
\usepackage{array,booktabs, makecell, tabularx}
\renewcommand\theadfont{\small\bfseries}
\renewcommand\theadgape{}
\usepackage{rotating} % graphicx is loaded by "beamer"
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}


\begin{document}
\begin{frame}
\frametitle{My table \dots}
    \centering
    \setcellgapes{3pt}
    \makegapedcells
\begin{tabular}{ l *{2}{>{$}c<{$}} }
    \toprule
\thead{Har class Class} 
    &   \text{\thead{XYZ (in words)}}   
        &   \text{\thead{Truple}}           \\ 
    \midrule
General vktm       
    &   \mathcal{O}(1)  &   \mathcal{O}(1)  \\ 
It is only a text          
    &   \mathcal{O}(1)  &   \mathcal{O}(1)  \\
\makecell[l]{Grfingiignigijfi \\jnferf} 
    &   \mathcal{O}(1)  &   \mathcal{O}(1)  \\
jvjtntg   
    &   \mathcal{O}(1)  &   \mathcal{O}(1)  \\
frcjnrtgvtng 
    &   \mathcal{O}(1)  &   \mathcal{O}(1)  \\
    \bottomrule
\end{tabular}
\end{frame}
\end{document}

笔记graphicx包是 加载的包集合之一beamer

相关内容