桌子摆放整齐

桌子摆放整齐

我目前正试图将这些桌子整齐地摆放,但似乎遇到了问题。

\begin{tabular}{|c|c|c|}
\hline Word & No. times Action occured & Action  \\ 
\hline A & 4 & D  \\ 
\hline Eight & 2 & D  \\ 
\hline B & 1 & D \\ 
\hline C & 1 & D \\ 
\hline Eighty & 1 & D \\ 
\hline 
\end{tabular} 

\begin{tabular}{|c|c|c|}
\hline Word & No. times Action occured & Action  \\ 
\hline A & 4 & I  \\ 
\hline E & 3 & I  \\ 
\hline O & 3 & I \\ 
\hline Eight & 1 & I \\ 
\hline GO & 1 & I \\ 
\hline 
\end{tabular} 

\begin{tabular}{|c|c|c|c|}
\hline Word & No. times Action occured & Action & Output \\ 
\hline OH & 6 & S & O \\ 
\hline A & 5 & S & K\\ 
\hline D & 4 & S & T\\ 
\hline L & 4 & S & O\\ 
\hline M & 4 & S & N\\ 
\hline 
\end{tabular} 

如何将前两个表格彼此相邻放置,并将第三个表格置于前两个表格下方的中心位置。

像这样:

在此处输入图片描述

编辑:是否可以将子标题和总标题添加到表中,以便可以单独交叉引用它们,也可以单独引用它们。

答案1

在此处输入图片描述

您的表格太宽了,所以我使用 `geometry 包来缩小页面边距。注意:表格之间的空行意味着您需要下一个表格转到下一行:

\documentclass[12pt]{article}
\usepackage[margin=25mm]{geometry}

\begin{document}
    \begin{center}
\begin{tabular}{|c|c|c|}
\hline Word & No. times Action occured & Action  \\
\hline A & 4 & D  \\
\hline Eight & 2 & D  \\
\hline B & 1 & D \\
\hline C & 1 & D \\
\hline Eighty & 1 & D \\
\hline
\end{tabular}
\hfill
\begin{tabular}{|c|c|c|}
\hline Word & No. times Action occured & Action  \\
\hline A & 4 & I  \\
\hline E & 3 & I  \\
\hline O & 3 & I \\
\hline Eight & 1 & I \\
\hline GO & 1 & I \\
\hline
\end{tabular}

\medskip
\begin{tabular}{|c|c|c|c|}
\hline Word & No. times Action occured & Action & Output \\
\hline OH & 6 & S & O \\
\hline A & 5 & S & K\\
\hline D & 4 & S & T\\
\hline L & 4 & S & O\\
\hline M & 4 & S & N\\
\hline
\end{tabular} 
    \end{center}
\end{document}

您应该考虑将表格中的第二列变窄(如果允许的话),方法是将列标题分成两行:

在此处输入图片描述

\documentclass[12pt]{article}
\usepackage{makecell}
\renewcommand\theadfont{\normalsize}
\usepackage{caption}

\begin{document}
    \begin{table}
    \centering
\caption{my tables}
    \label{tab:table}
\begin{tabular}{|c|c|c|}
\hline \thead[b]{Word} & \thead{No. times\\ Action occurred} & \thead{Action}  \\
\hline A & 4 & D  \\
\hline Eight & 2 & D  \\
\hline B & 1 & D \\
\hline C & 1 & D \\
\hline Eighty & 1 & D \\
\hline
\end{tabular}
\hfil
\begin{tabular}{|c|c|c|}
\hline \thead[b]{Word} & \thead{No. times\\ Action occurred} & \thead{Action}  \\
\hline A & 4 & I  \\
\hline E & 3 & I  \\
\hline O & 3 & I \\
\hline Eight & 1 & I \\
\hline GO & 1 & I \\
\hline
\end{tabular}

\medskip
\begin{tabular}{|c|c|c|c|}
\hline \thead[b]{Word} & \thead{No. times\\ Action occurred} 
    & \thead{Action}    & \thead{Output}  \\
\hline OH & 6 & S & O \\
\hline A & 5 & S & K\\
\hline D & 4 & S & T\\
\hline L & 4 & S & O\\
\hline M & 4 & S & N\\
\hline
\end{tabular} 
    \end{table}
\end{document}

附录: 考虑到您的最后一条评论并使用subfig包。同样,您可以使用包获得subcaption,但是它需要提前定义表格宽度...:

\documentclass[12pt]{article}
\usepackage{makecell}
\renewcommand\theadfont{\normalsize}
\usepackage{caption}
\usepackage{subfig}

\begin{document}
    \begin{table}
    \centering
\caption{my tables}
    \label{tab:table}
\subfloat[ table 1]{
\begin{tabular}{|c|c|c|}
\hline \thead[b]{Word} & \thead{No. times\\ Action occurred} & \thead{Action}  \\
\hline A & 4 & D  \\
\hline Eight & 2 & D  \\
\hline B & 1 & D \\
\hline C & 1 & D \\
\hline Eighty & 1 & D \\
\hline
\end{tabular}
}
\hfil
\subfloat[ table 2]{
\begin{tabular}{|c|c|c|}
\hline \thead[b]{Word} & \thead{No. times\\ Action occurred} & \thead{Action}  \\
\hline A & 4 & I  \\
\hline E & 3 & I  \\
\hline O & 3 & I \\
\hline Eight & 1 & I \\
\hline GO & 1 & I \\
\hline
\end{tabular}
}

\subfloat[ table 3]{
\begin{tabular}{|c|c|c|c|}
\hline \thead[b]{Word} & \thead{No. times\\ Action occurred} 
    & \thead{Action}    & \thead{Output}  \\
\hline OH & 6 & S & O \\
\hline A & 5 & S & K\\
\hline D & 4 & S & T\\
\hline L & 4 & S & O\\
\hline M & 4 & S & N\\
\hline
\end{tabular} 
}
    \end{table}
\end{document}

在此处输入图片描述

相关内容