我有一個包含三個表的文檔。目前這三個表格對於頁面來說太長了,所以我想讓兩個表格並排出現,然後讓第三個表格出現在它們下面。這樣,所有表格都將適合同一頁。
這是我的 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
它們僅在垂直方向上間隔,因為每個環境之間都有段落分隔符號(空白行)。