并排摆放 2 张桌子

并排摆放 2 张桌子

我怎样才能轻松地将这两张桌子放在一起?

\begin{table}[H]
    \small
    \begin{tabu} to \textwidth {  X[l] | X[c]  X[c]  X[c]  X[c]  X[c] }
%        \hline
        & \multicolumn{5}{c}{Precision} \\
%        \cline{5-6}
        & 0 & 1 & 2 & 3 & 4\\
        \hline
        A & 0.143 & 0.143 & & & \\
        B & 1.518 & 1.518 \\
        C & 0.018 & 0.142 \\
        D & 0.029 & 0.180 \\
        \hline
        \# tr samples & 53k, 187k & 53k, 187k & 53k, 187k \\
        \# te samples & 8k, 26k & \\
%        \hline
        \end{tabu}
    \medskip
    \caption{}
    \label{tab:runtime}     
\end{table}

\begin{table}[H]
    \small
    \begin{tabu} to \textwidth {  X[l] | X[c]  X[c]  X[c]  X[c]  X[c] }
%        \hline
        & \multicolumn{5}{c}{Precision} \\
%        \cline{5-6}
        & 0 & 1 & 2 & 3 & 4\\
        \hline
        A & 0.143 & 0.143 & & & \\
        B & 1.518 & 1.518 \\
        C & 0.018 & 0.142 \\
        D & 0.029 & 0.180 \\
        E & 0.029 & 0.180 \\
        F & 0.029 & 0.180 \\
%        \hline
        \end{tabu}
    \medskip
    \caption{}
    \label{tab:runtime}     
\end{table}

编辑:我尝试将它们放在同一个 \begin{table} 和 \end{table} 下,但它们仍然没有并排。

\begin{table}[H]
    \small
    \begin{tabu} to 0.5\textwidth {  X[l] | X[c]  X[c]  X[c]  X[c]  X[c] }
%        \hline
        & \multicolumn{5}{c}{Precision with label shifted by t seconds} \\
%        \cline{5-6}
        & 0 & 1 & 2 & 3 & 4\\
        \hline
        A & 0.143 & 0.143 & & & \\
        B & 1.518 & 1.518 \\
        C & 0.018 & 0.142 \\
        D & 0.029 & 0.180 \\
        \hline
        \# tr samples & 53k, 187k & 53k, 187k & 53k, 187k \\
        \# te samples & 8k, 26k & \\
%        \hline
        \end{tabu}
    \medskip
    \caption{Models trained and tested on the complete sequence as described in figure 3a.}
    \label{tab:runtime}  

    \small
    \begin{tabu} to 0.5\textwidth {  X[l] | X[c]  X[c]  X[c]  X[c]  X[c] }
%        \hline
        & \multicolumn{5}{c}{Precision with label shifted by t seconds} \\
%        \cline{5-6}
        & 0 & 1 & 2 & 3 & 4\\
        \hline
        A & 0.143 & 0.143 & & & \\
        B & 1.518 & 1.518 \\
        C & 0.018 & 0.142 \\
        D & 0.029 & 0.180 \\
        E & 0.029 & 0.180 \\
        F & 0.029 & 0.180 \\
%        \hline
        \end{tabu}
    \medskip
    \caption{Models trained on the complete sequence (fig 3a) and tested on the truncated sequence (fig 3b).}
    \label{tab:runtime} 

\end{table}

我已经删除了所有空格,但它仍然不起作用

\begin{table}[H]
    \small
    \begin{tabu} to \textwidth {  X[l] | X[c]  X[c]  X[c]  X[c]  X[c] }
        & \multicolumn{5}{c}{Precision} \\
        & 0 & 1 & 2 & 3 & 4\\
        \hline
        A & 0.143 & 0.143 & & & \\
        B & 1.518 & 1.518 \\
        C & 0.018 & 0.142 \\
        D & 0.029 & 0.180 \\
        \hline
        \# tr samples & 53k, 187k & 53k, 187k & 53k, 187k \\
        \# te samples & 8k, 26k & \\
    \end{tabu}
    \caption{}
    \label{tab:runtime}  
    \small\begin{tabu} to \textwidth {  X[l] | X[c]  X[c]  X[c]  X[c]  X[c] }
        & \multicolumn{5}{c}{Precision with label shifted by t seconds} \\
        & 0 & 1 & 2 & 3 & 4\\
        \hline
        A & 0.143 & 0.143 & & & \\
        B & 1.518 & 1.518 \\
        C & 0.018 & 0.142 \\
        D & 0.029 & 0.180 \\
        E & 0.029 & 0.180 \\
        F & 0.029 & 0.180 \\
        \end{tabu}
    \caption{}
    \label{tab:runtime} 
\end{table}

答案1

此解决方案可对齐标题。对齐中心或第一行相对容易。否则您可能需要使用\raisebox

我还在\columnsep它们之间添加了一个间隙。

\documentclass{article}
\usepackage{tabu}

\begin{document}
\begin{table}[htp]% 
\begin{minipage}[b]{\dimexpr 0.5\textwidth-0.5\columnsep}
    \small
    \begin{tabu} to \textwidth {  X[l] | X[c]  X[c]  X[c]  X[c]  X[c] }
%        \hline
        & \multicolumn{5}{c}{Precision} \\
%        \cline{5-6}
        & 0 & 1 & 2 & 3 & 4\\
        \hline
        A & 0.143 & 0.143 & & & \\
        B & 1.518 & 1.518 \\
        C & 0.018 & 0.142 \\
        D & 0.029 & 0.180 \\
        \hline
        \# tr samples & 53k, 187k & 53k, 187k & 53k, 187k \\
        \# te samples & 8k, 26k & \\
%        \hline
        \end{tabu}
    \medskip
    \caption{}
    \label{tab:runtime}
    \end{minipage}\hfill% add gap of \columnsep between tabus and captions
    \begin{minipage}[b]{\dimexpr 0.5\textwidth-0.5\columnsep}
    \small
    \begin{tabu} to \textwidth {  X[l] | X[c]  X[c]  X[c]  X[c]  X[c] }
%        \hline
        & \multicolumn{5}{c}{Precision} \\
%        \cline{5-6}
        & 0 & 1 & 2 & 3 & 4\\
        \hline
        A & 0.143 & 0.143 & & & \\
        B & 1.518 & 1.518 \\
        C & 0.018 & 0.142 \\
        D & 0.029 & 0.180 \\
        E & 0.029 & 0.180 \\
        F & 0.029 & 0.180 \\
%        \hline
        \end{tabu}
    \medskip
    \caption{}
    \label{tab:runtime}
\end{minipage}
\end{table}
\end{document}

演示

答案2

我更喜欢下面的表格设计:

在此处输入图片描述

(红线表示文字边框)

\documentclass{article}
\usepackage{geometry}
\usepackage{booktabs, tabularx}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
\begin{document}
\begin{table}[ht]
\small
    \begin{tabularx}{\linewidth}{@{} 
                    >{\hsize=1.1\hsize}X 
                    >{\hsize=0.9\hsize\raggedleft\arraybackslash}X @{}}
\caption{}
\label{tab:runtime}
\begin{tabular}[t]{@{} l*{5}{>{\centering\arraybackslash}p{2.5em}} @{}}
    \toprule
    & \multicolumn{5}{@{} c @{}}{Precision} \\
    \cmidrule{2-6}
    & 0 & 1 & 2 & 3 & 4\\
    \midrule
A               & 0.143     & 0.143     &           & & \\
B               & 1.518     & 1.518     &           & & \\
C               & 0.018     & 0.142     &           & & \\
D               & 0.029     & 0.180     &           & & \\
    \hline
\# tr samples   & 53k, 187k & 53k, 187k & 53k, 187k & & \\
\# te samples   & 8k, 26k   &           &           & & \\
    \bottomrule
    \end{tabular}
&
    \caption{}
    \label{tab:runtime} 
\begin{tabular}[t]{@{} l*{5}{>{\centering\arraybackslash}p{2.5em}} @{}}
    \toprule
    & \multicolumn{5}{@{} c @{}}{Precision with label shifted by t seconds } \\
    \cmidrule{2-6}
    & 0     & 1     & 2 & 3 & 4 \\
    \midrule
A   & 0.143 & 0.143 &   &   &   \\
B   & 1.518 & 1.518 &   &   &   \\
C   & 0.018 & 0.142 &   &   &   \\
D   & 0.029 & 0.180 &   &   &   \\
E   & 0.029 & 0.180 &   &   &   \\
F   & 0.029 & 0.180 &   &   &   \\
    \bottomrule
    \end{tabular}       
    \end{tabularx}
\end{table}
\end{document}

相关内容