如何将多个表格放在一行中

如何将多个表格放在一行中

我必须制作三个表格并使用下面的代码。

\begin{table}[ht]
\caption{Performance of each band on recognizing classes 1 and 2} \label{tab1}
\begin{tabularx}{\textwidth}{|*{4}{L|}}
\hline
    \multirow{2}{*}{Band} &
      \multicolumn{2}{c}{CCS} & \\
      & {Class 1} & {Class 2} \\
      \midrule
    Alpha & 61 & 55 & \\
\hline
    Beta & 70 & 59 &\\
\hline
    Theta & 55 & 65 &\\
\hline
\end{tabularx}
\end{table}

\begin{table}[ht]
\caption{Performance of each band on recognizing classes 1 and 3} \label{tab1}
\begin{tabularx}{\textwidth}{|*{4}{L|}}
\hline
    \multirow{2}{*}{Band} &
      \multicolumn{2}{c}{CCS} & \\
      & {Class 2} & {Class 3} \\
      \midrule
    Alpha & 49 & 56&\
\hline
    Beta & 73 & 36&\\
\hline
    Theta & 52 & 57& \\
\hline
\end{tabularx}
\end{table}

\begin{table}[ht]
\caption{Performance of each band on recognizing classes 2 and 3} \label{tab1}
\begin{tabularx}{\textwidth}{|*{4}{L|}}
\hline
    \multirow{2}{*}{Band} &
      \multicolumn{2}{c}{CCS} & \\
      & {Class 2} & {Class 3} \\
      \midrule
    Alpha & 58 & 57 &\\
\hline
    Beta & 62 & 52 & \\
\hline
    Theta & 66 & 58 & \\
\hline
\end{tabularx}
\end{table}

正如预期的那样,我得到了如下图所示的表格。 在此处输入图片描述

但这占用了太多空间。我想将这三个表并排放在一行中。我该怎么做?

答案1

像这样:

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs, multirow, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\NewExpandableDocumentCommand\mcc{O{1}m}{\multicolumn{#1}{c}{#2}}
\usepackage{setspace}
\usepackage[skip=1ex, 
            font={footnotesize,sf,stretch=0.88},
            labelfont=bf
            ]{caption}

\begin{document}
    \begin{table}[ht]
    \small
\begin{tabularx}{\textwidth}{@{} *{3}{C} @{}}
\caption{Performance of each band on recognizing classes 1 and 2} 
\label{tab1}
    \begin{tabular}{@{} lcc @{}}
    \toprule
\multirow{2.3}{*}{Band} 
    & \mcc[2]{CCS}          \\
    \cmidrule(l){2-3}
    & Class 1   & Class 2   \\
    \midrule
Alpha   & 61    & 55        \\
Beta    & 70    & 59        \\
Theta   & 55    & 65        \\
    \bottomrule
    \end{tabular}   &   \caption{Performance of each band
                                   on recognizing classes 2 and 3} \label{tab1}
                    \begin{tabular}{@{} lcc @{}}
                    \toprule
                \multirow{2.3}{*}{Band}
                    & \mcc[2]{CCS}          \\
                    \cmidrule(l){2-3}
                    & Class 1   & Class 2   \\
                    \midrule
                Alpha   & 61    & 55        \\
                Beta    & 70    & 59        \\
                Theta   & 55    & 65        \\
                    \bottomrule
                    \end{tabular}   &   \caption{Performance of each band
                                    on recognizing classes 2 and 3} \label{tab1}
                                    \begin{tabular}{@{} lcc @{}}
                                    \toprule
                                \multirow{2.3}{*}{Band}
                                    & \mcc[2]{CCS}          \\
                                    \cmidrule(l){2-3}
                                    & Class 1   & Class 2   \\
                                    \midrule
                                Alpha   & 61    & 55        \\
                                Beta    & 70    & 59        \\
                                Theta   & 55    & 65        \\
                                    \bottomrule
                                    \end{tabular}
\end{tabularx}
    \end{table}
\end{document}

相关内容