如何设计并排的表格

如何设计并排的表格

我有两个表的 LaTeX 代码:

\begin{table}[h]
    \scriptsize
    \centering
    \begin{tabular}{c|c}
       \textbf{Brand} & \textbf{Customer Engagement Average}   \\ \hline
     Apple & 1,937,852.45  \\ 
     Huawei & 156,962.065  \\ 
     Samsung & 174,166.98  \\ 
      
         \end{tabular}
    \caption{Average Brand Customer Engagement}
    \label{brand_ce}
%\end{table}

%\begin{table}[h]
    \scriptsize
    \centering
    \begin{tabular}{c|c}
       \textbf{Brand} & \textbf{Customer Satisfaction Score Average}   \\ \hline
     Apple & 3.37  \\ 
     Huawei & 4.049  \\ 
     Samsung & 3.76  \\ 
      
         \end{tabular}
    \caption{Average Brand Customer Satisfaction Score}
    \label{brand_sscore}
\end{table}

这些表格相互叠放如下图所示:

在此处输入图片描述

我需要将这些表并排放置。

答案1

我建议使用floatrowS第二列的列类型,以便将数字对齐到小数点。请注意,传统上,表格都有自己的标题多于表格,这是由 float row 自动完成的。此外,加载时geometry,您将拥有更合理的边距(假设您不需要边注)。

\documentclass[11pt]{article}
\usepackage{geometry} 
\usepackage{makecell}
\renewcommand{\theadfont}{\small\bfseries}
\usepackage{siunitx} 
\usepackage{caption, floatrow}

\begin{document}

\begin{table}[h]
\centering
\setlength{\extrarowheight}{2pt}
\sisetup{table-number-alignment=center, group-separator={,}}
\captionsetup{format=hang, justification=raggedright}
\begin{floatrow}
\ttabbox{\caption{Average Brand Customer Engagement} \label{brand_ce}}%
    {\centering\begin{tabular}{r|S[table-format=7.3]}
       \textbf{Brand} & {\thead{Customer Engagement\\ Average}} \\ \hline
     Apple & 1937852.45 \\
     Huawei & 156962.065 \\
     Samsung & 174166.98
         \end{tabular}}
\qquad
   \ttabbox{\caption{Average Brand Customer Satisfaction Score} \label{brand_sscore}}%
   {\begin{tabular}{r|S[table-format=1.3]}
       \thead[b]{Brand} & {\thead{Customer Satisfaction\\ Score Average}} \\ \hline
     Apple & 3.37 \\
     Huawei & 4.049 \\
     Samsung & 3.76
      \end{tabular}}
\end{floatrow}
\end{table}

\end{document} 

在此处输入图片描述

答案2

从上面的评论来看

在此处输入图片描述

\begin{table}[h]
    \scriptsize
    \centering
    \begin{tabular}{c|cc}
        \textbf{Brand} & \multicolumn{2}{c}{\textbf{Customer Average}}  \\ 
        &\textbf{-Engagement-} &\textbf{-Satisfaction Score-}\\\hline
        Apple & 1,937,852.45& 3.37   \\ 
        Huawei & 156,962.065  & 4.049  \\ 
        Samsung & 174,166.98& 3.76  \\ 
    \end{tabular}
    \caption{Average Brand Customer Engagement}
    \label{brand_ce}

\end{table}

相关内容