如何使两个表格并排显示?

如何使两个表格并排显示?

我有一个包含三个表格的文档。这三个表格目前对于页面来说太长了,所以我想让两个表格并排显示,然后让第三个表格显示在它们下面。这样,所有表格都可以放在同一页中。

这是我的 MWE:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{microtype}
\usepackage[margin=2.54cm]{geometry}
\usepackage{graphicx,booktabs,tabularx}
\usepackage[table]{xcolor}
\usepackage{array}

%define some nice colors
\definecolor{middleware_green}{RGB}{82, 119, 17}
\definecolor{middleware_white}{RGB}{255, 255, 255}
\definecolor{middleware_light_gray}{RGB}{239, 239, 239}
\definecolor{middleware_dark_gray}{RGB}{153, 153, 153}

\renewcommand{\tabularxcolumn}[1]{>{\small}m{#1}}
\newcolumntype{L}{>{\leavevmode\ignorespaces\raggedleft\arraybackslash\sffamily}X}%
\newcolumntype{C}{>{\leavevmode\ignorespaces\centering\arraybackslash\sffamily}X}%
\rowcolors{2}{middleware_white}{middleware_light_gray}

\begin{document}

\begin{table}[htbp]

\begin{tabularx}{0.45\textwidth}{|L|L|L|L|}
\hline\rowcolor{middleware_green}
\multicolumn{ 4}{|c|}{\textcolor{white}{\textbf{1 Source, 1 Session, 1 Client, Exp0}}} \\ \hline
\rowcolor{middleware_dark_gray}
\multicolumn{1}{|C}{\footnotesize\textcolor{white}{\textbf{Mes\-sa\-ges per mi\-nu\-te per sour\-ce}}} & 
\multicolumn{1}{|C}{\footnotesize\centering\textcolor{white}{\textbf{Mid\-dle\-ware Exec. Ti\-me (s)}}} & 
\multicolumn{1}{|C}{\footnotesize\centering\textcolor{white}{\textbf{De\-lay (s)}}} & 
\multicolumn{1}{|C|}{\footnotesize\textcolor{white}{\textbf{Ave\-ra\-ge De\-lay (s)}}} \\ \hline
 & 60 & 0 &  \\ \cline{ 2- 3}
60 & 60 & 0 & 0.00 \\ \cline{ 2- 3}
 & 60 & 0 &  \\ \hline
 & 60 & 0 &  \\ \cline{ 2- 3}
120 & 60 & 0 & 0.00 \\ \cline{ 2- 3}
 & 60 & 0 &  \\ \hline
 & 60 & 0 &  \\ \cline{ 2- 3}
240 & 60 & 0 & 0.00 \\ \cline{ 2- 3}
 & 60 & 0 & \\ \hline
 & 69 & 9 &  \\ \cline{ 2- 3}
480 & 69 & 9 & 16.67 \\ \cline{ 2- 3}
 & 92 & 32 &  \\ \hline
 & 159 & 99 &  \\ \cline{ 2- 3}
1000 & 173 & 113 & 109.67 \\ \cline{ 2- 3}
 & 177 & 117 &  \\ \hline
 & 391 & 331 &  \\ \cline{ 2- 3}
2000 & 383 & 323 & 311.00 \\ \cline{ 2- 3}
 & 339 & 279 &  \\ \hline
 & 561 & 501 & \\ \cline{ 2- 3}
4000 & 631 & 501 & 512.33 \\ \cline{ 2- 3}
 & 595 & 535 &  \\ \hline
\end{tabularx}


\begin{tabularx}{0.45\textwidth}{|L|L|L|L|}
\hline\rowcolor{middleware_green}
\multicolumn{ 4}{|c|}{\textcolor{white}{\textbf{1 Source, 1 Session, 1 Client, Exp0}}} \\ \hline
\rowcolor{middleware_dark_gray}
\multicolumn{1}{|C}{\footnotesize\textcolor{white}{\textbf{Mes\-sa\-ges per mi\-nu\-te per sour\-ce}}} & 
\multicolumn{1}{|C}{\footnotesize\centering\textcolor{white}{\textbf{Mid\-dle\-ware Exec. Ti\-me (s)}}} & 
\multicolumn{1}{|C}{\footnotesize\centering\textcolor{white}{\textbf{De\-lay (s)}}} & 
\multicolumn{1}{|C|}{\footnotesize\textcolor{white}{\textbf{Ave\-ra\-ge De\-lay (s)}}} \\ \hline
 & 60 & 0 &  \\ \cline{ 2- 3}
60 & 60 & 0 & 0.00 \\ \cline{ 2- 3}
 & 60 & 0 &  \\ \hline
 & 60 & 0 &  \\ \cline{ 2- 3}
120 & 60 & 0 & 0.00 \\ \cline{ 2- 3}
 & 60 & 0 &  \\ \hline
 & 60 & 0 &  \\ \cline{ 2- 3}
240 & 60 & 0 & 0.00 \\ \cline{ 2- 3}
 & 60 & 0 & \\ \hline
 & 69 & 9 &  \\ \cline{ 2- 3}
480 & 69 & 9 & 16.67 \\ \cline{ 2- 3}
 & 92 & 32 &  \\ \hline
 & 159 & 99 &  \\ \cline{ 2- 3}
1000 & 173 & 113 & 109.67 \\ \cline{ 2- 3}
 & 177 & 117 &  \\ \hline
 & 391 & 331 &  \\ \cline{ 2- 3}
2000 & 383 & 323 & 311.00 \\ \cline{ 2- 3}
 & 339 & 279 &  \\ \hline
 & 561 & 501 & \\ \cline{ 2- 3}
4000 & 631 & 501 & 512.33 \\ \cline{ 2- 3}
 & 595 & 535 &  \\ \hline
\end{tabularx}

\begin{tabularx}{0.45\textwidth}{|L|L|L|L|}
\hline\rowcolor{middleware_green}
\multicolumn{ 4}{|c|}{\textcolor{white}{\textbf{1 Source, 1 Session, 1 Client, Exp0}}} \\ \hline
\rowcolor{middleware_dark_gray}
\multicolumn{1}{|C}{\footnotesize\textcolor{white}{\textbf{Mes\-sa\-ges per mi\-nu\-te per sour\-ce}}} & 
\multicolumn{1}{|C}{\footnotesize\centering\textcolor{white}{\textbf{Mid\-dle\-ware Exec. Ti\-me (s)}}} & 
\multicolumn{1}{|C}{\footnotesize\centering\textcolor{white}{\textbf{De\-lay (s)}}} & 
\multicolumn{1}{|C|}{\footnotesize\textcolor{white}{\textbf{Ave\-ra\-ge De\-lay (s)}}} \\ \hline
 & 60 & 0 &  \\ \cline{ 2- 3}
60 & 60 & 0 & 0.00 \\ \cline{ 2- 3}
 & 60 & 0 &  \\ \hline
 & 60 & 0 &  \\ \cline{ 2- 3}
120 & 60 & 0 & 0.00 \\ \cline{ 2- 3}
 & 60 & 0 &  \\ \hline
 & 60 & 0 &  \\ \cline{ 2- 3}
240 & 60 & 0 & 0.00 \\ \cline{ 2- 3}
 & 60 & 0 & \\ \hline
 & 69 & 9 &  \\ \cline{ 2- 3}
480 & 69 & 9 & 16.67 \\ \cline{ 2- 3}
 & 92 & 32 &  \\ \hline
 & 159 & 99 &  \\ \cline{ 2- 3}
1000 & 173 & 113 & 109.67 \\ \cline{ 2- 3}
 & 177 & 117 &  \\ \hline
 & 391 & 331 &  \\ \cline{ 2- 3}
2000 & 383 & 323 & 311.00 \\ \cline{ 2- 3}
 & 339 & 279 &  \\ \hline
 & 561 & 501 & \\ \cline{ 2- 3}
4000 & 631 & 501 & 512.33 \\ \cline{ 2- 3}
 & 595 & 535 &  \\ \hline
\end{tabularx}

\label{tables_test}
\caption{three tables!}
\end{table}


\end{document}

我该如何实现这一点?如何才能让这三个表格适合一页?

答案1

表格环境使用与字母相同的规则来定位,例如X它们仅在垂直方向上间隔开,因为每个段落之间都有一个段落分隔符(空行)。

相关内容